|
|
@ -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 ]) |
|
|
|