Merge pull request #156 from yirandidi/main

fix: 路由配置activeMenu的bug
This commit is contained in:
Ah jung
2022-07-25 20:11:23 +08:00
committed by GitHub

View File

@@ -99,12 +99,15 @@
() => currentRoute.fullPath, () => currentRoute.fullPath,
() => { () => {
updateMenu(); updateMenu();
}
);
function updateSelectedKeys() {
const matched = currentRoute.matched; const matched = currentRoute.matched;
state.openKeys = matched.map((item) => item.name); state.openKeys = matched.map((item) => item.name);
const activeMenu: string = (currentRoute.meta?.activeMenu as string) || ''; const activeMenu: string = (currentRoute.meta?.activeMenu as string) || '';
selectedKeys.value = activeMenu ? (activeMenu as string) : (currentRoute.name as string); selectedKeys.value = activeMenu ? (activeMenu as string) : (currentRoute.name as string);
} }
);
function updateMenu() { function updateMenu() {
if (!settingStore.menuSetting.mixMenu) { if (!settingStore.menuSetting.mixMenu) {
@@ -116,6 +119,7 @@
const activeMenu: string = currentRoute?.matched[0].meta?.activeMenu as string; const activeMenu: string = currentRoute?.matched[0].meta?.activeMenu as string;
headerMenuSelectKey.value = (activeMenu ? activeMenu : firstRouteName) || ''; headerMenuSelectKey.value = (activeMenu ? activeMenu : firstRouteName) || '';
} }
updateSelectedKeys();
} }
// 点击菜单 // 点击菜单