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,13 +99,16 @@
() => currentRoute.fullPath, () => currentRoute.fullPath,
() => { () => {
updateMenu(); updateMenu();
const matched = currentRoute.matched;
state.openKeys = matched.map((item) => item.name);
const activeMenu: string = (currentRoute.meta?.activeMenu as string) || '';
selectedKeys.value = activeMenu ? (activeMenu as string) : (currentRoute.name as string);
} }
); );
function updateSelectedKeys() {
const matched = currentRoute.matched;
state.openKeys = matched.map((item) => item.name);
const activeMenu: string = (currentRoute.meta?.activeMenu as string) || '';
selectedKeys.value = activeMenu ? (activeMenu as string) : (currentRoute.name as string);
}
function updateMenu() { function updateMenu() {
if (!settingStore.menuSetting.mixMenu) { if (!settingStore.menuSetting.mixMenu) {
menus.value = generatorMenu(asyncRouteStore.getMenus); menus.value = generatorMenu(asyncRouteStore.getMenus);
@@ -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();
} }
// 点击菜单 // 点击菜单