From 967629a1f5bf68531fb6b00ba622f5fcf90a8ea3 Mon Sep 17 00:00:00 2001 From: dark Date: Mon, 10 Jun 2024 02:42:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=8F=9C=E5=8D=95=E5=B8=83?= =?UTF-8?q?=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/RootLayout.tsx | 6 ++++-- src/types/system/menus.d.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/layout/RootLayout.tsx b/src/layout/RootLayout.tsx index 45b9fa2..289d617 100644 --- a/src/layout/RootLayout.tsx +++ b/src/layout/RootLayout.tsx @@ -53,9 +53,11 @@ export default () => { } const [ rootMenuKeys, setRootMenuKeys ] = useState(() => { const item = menusFlatten.current?.find(item => item.path === location.pathname) + if (item?.meta.affix) { + return [ item.meta.name ] + } return item ? item.parentName : [] }) - const childMenuRef = useRef([]) childMenuRef.current = menuData.find(item => { @@ -64,7 +66,7 @@ export default () => { useEffect(() => { const item = menusFlatten.current?.find(item => item.path === location.pathname) - if (item && item.key !== rootMenuKeys?.[0]) { + if (item && item.meta.name !== rootMenuKeys?.[0]) { setRootMenuKeys(item.parentName) } }, [ location.pathname ]) diff --git a/src/types/system/menus.d.ts b/src/types/system/menus.d.ts index 429c945..607b3a3 100644 --- a/src/types/system/menus.d.ts +++ b/src/types/system/menus.d.ts @@ -6,6 +6,8 @@ export interface MenuButton { export interface Meta { + affix: boolean, + name: string } export interface IMenu {