diff --git a/src/router/utils.ts b/src/router/utils.ts index ba5a29d323..35065c7238 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -367,9 +367,23 @@ function hasAuth(value: string | Array): boolean { return isAuths ? true : false; } +function handleTopMenu(route) { + if (route?.children && route.children.length > 1) { + if (route.redirect) { + return route.children.filter(cur => cur.path === route.redirect)[0]; + } else { + return route.children[0]; + } + } else { + return route; + } +} + /** 获取所有菜单中的第一个菜单(顶级菜单)*/ function getTopMenu(tag = false): menuType { - const topMenu = usePermissionStoreHook().wholeMenus[0]?.children[0]; + const topMenu = handleTopMenu( + usePermissionStoreHook().wholeMenus[0]?.children[0] + ); tag && useMultiTagsStoreHook().handleTags("push", topMenu); return topMenu; }