Browse Source

修改菜单布局

main
dark 6 months ago
parent
commit
967629a1f5
  1. 6
      src/layout/RootLayout.tsx
  2. 2
      src/types/system/menus.d.ts

6
src/layout/RootLayout.tsx

@ -53,9 +53,11 @@ export default () => {
}
const [ rootMenuKeys, setRootMenuKeys ] = useState<string[]>(() => {
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<MenuItem[]>([])
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 ])

2
src/types/system/menus.d.ts

@ -6,6 +6,8 @@ export interface MenuButton {
export interface Meta {
affix: boolean,
name: string
}
export interface IMenu {

Loading…
Cancel
Save