From 3f2cff9bb9cf44482fb3458ee2b7ed333c72bb93 Mon Sep 17 00:00:00 2001 From: katherinehhh Date: Wed, 27 Dec 2023 16:12:58 +0800 Subject: [PATCH] refactor: pluginsetting --- packages/core/client/src/pm/PluginSetting.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/packages/core/client/src/pm/PluginSetting.tsx b/packages/core/client/src/pm/PluginSetting.tsx index bf52314f97..d825bf7d00 100644 --- a/packages/core/client/src/pm/PluginSetting.tsx +++ b/packages/core/client/src/pm/PluginSetting.tsx @@ -30,6 +30,7 @@ export const AdminSettingsLayout = () => { const compile = useCompile(); const settings = useMemo(() => { const list = app.pluginSettingsManager.getList(); + console.log(list); // compile title function traverse(settings: PluginSettingsPageType[]) { settings.forEach((item) => { @@ -43,6 +44,7 @@ export const AdminSettingsLayout = () => { traverse(list); return list; }, [app.pluginSettingsManager, compile]); + console.log(settings); const getFirstDeepChildPath = useCallback((settings: PluginSettingsPageType[]) => { if (!settings || !settings.length) { return '/admin'; @@ -73,17 +75,21 @@ export const AdminSettingsLayout = () => { if (!currentSetting) { return null; } - return settings.find((item) => item.name === currentSetting.topLevelName); + return settings.find( + (item) => item.name === currentSetting.parentLevelName || item.name === currentSetting.topLevelName, + ); }, [currentSetting, settings]); const sidebarMenus = useMemo(() => { - return getMenuItems(settings.map((item) => ({ ...item, children: null }))); + return getMenuItems(settings.filter((v) => v.isTop !== false).map((item) => ({ ...item, children: null }))); }, [settings]); if (!currentSetting || location.pathname === ADMIN_SETTINGS_PATH || location.pathname === ADMIN_SETTINGS_PATH + '/') { return ; } - if (location.pathname === currentTopLevelSetting.path && currentTopLevelSetting.children?.length > 0) { - return ; + if (location.pathname === currentTopLevelSetting?.path && currentTopLevelSetting?.children?.length > 0) { + return ; } + console.log(sidebarMenus); + console.log(currentSetting, currentTopLevelSetting, currentSetting?.topLevelName); return (
@@ -104,7 +110,7 @@ export const AdminSettingsLayout = () => { theme={'light'} > { const plugin = settings.find((item) => item.name === key); @@ -136,7 +142,7 @@ export const AdminSettingsLayout = () => { }} selectedKeys={[currentSetting?.name]} mode="horizontal" - items={getMenuItems(currentTopLevelSetting.children)} + items={getMenuItems(currentSetting.children || currentTopLevelSetting.children)} > ) }