From 5701165b0c54fbebb272963a9adce048772a0f27 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Fri, 20 Aug 2021 11:22:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E4=B8=80?= =?UTF-8?q?=E7=BA=A7=E8=8A=82=E7=82=B9=E7=9A=84=E9=9D=A2=E6=9D=BF=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/GroupPanelItem.tsx | 2 +- web/src/components/GroupSection.tsx | 2 +- web/src/routes/Main/Content/Group/Sidebar.tsx | 47 +++++++++++-------- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/web/src/components/GroupPanelItem.tsx b/web/src/components/GroupPanelItem.tsx index 786d89bb..afeaab9d 100644 --- a/web/src/components/GroupPanelItem.tsx +++ b/web/src/components/GroupPanelItem.tsx @@ -15,7 +15,7 @@ export const GroupPanelItem: React.FC<{ const isActive = location.pathname.startsWith(to); return ( - +
{props.header}
{ const { groupId } = useParams(); @@ -21,24 +21,33 @@ export const Sidebar: React.FC = React.memo(() => {
-
+
{groupPanels - .filter((panel) => panel.type === GroupPanelType.GROUP) - .map((group) => ( - - {groupPanels - .filter((panel) => panel.parentId === group.id) - .map((panel) => ( -
- #
} - to={`/main/group/${groupId}/${panel.id}`} - /> -
- ))} - - ))} + .filter((panel) => !isValidStr(panel.parentId)) + .map((panel) => + panel.type === GroupPanelType.GROUP ? ( + + {groupPanels + .filter((sub) => sub.parentId === panel.id) + .map((sub) => ( +
+ #
} + to={`/main/group/${groupId}/${sub.id}`} + /> +
+ ))} + + ) : ( + #
} + to={`/main/group/${groupId}/${panel.id}`} + /> + ) + )}
);