mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-06-30 09:24:46 +08:00
perf: 优化获取顶级菜单逻辑
This commit is contained in:
parent
0934c97413
commit
699b174f95
@ -367,9 +367,23 @@ function hasAuth(value: string | Array<string>): boolean {
|
|||||||
return isAuths ? true : false;
|
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 {
|
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);
|
tag && useMultiTagsStoreHook().handleTags("push", topMenu);
|
||||||
return topMenu;
|
return topMenu;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user