|
@ -53,9 +53,11 @@ export default () => { |
|
|
} |
|
|
} |
|
|
const [ rootMenuKeys, setRootMenuKeys ] = useState<string[]>(() => { |
|
|
const [ rootMenuKeys, setRootMenuKeys ] = useState<string[]>(() => { |
|
|
const item = menusFlatten.current?.find(item => item.path === location.pathname) |
|
|
const item = menusFlatten.current?.find(item => item.path === location.pathname) |
|
|
|
|
|
if (item?.meta.affix) { |
|
|
|
|
|
return [ item.meta.name ] |
|
|
|
|
|
} |
|
|
return item ? item.parentName : [] |
|
|
return item ? item.parentName : [] |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
const childMenuRef = useRef<MenuItem[]>([]) |
|
|
const childMenuRef = useRef<MenuItem[]>([]) |
|
|
|
|
|
|
|
|
childMenuRef.current = menuData.find(item => { |
|
|
childMenuRef.current = menuData.find(item => { |
|
@ -64,7 +66,7 @@ export default () => { |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
|
const item = menusFlatten.current?.find(item => item.path === location.pathname) |
|
|
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) |
|
|
setRootMenuKeys(item.parentName) |
|
|
} |
|
|
} |
|
|
}, [ location.pathname ]) |
|
|
}, [ location.pathname ]) |
|
|