fix(系统设置): 模块设置不生效问题

--bug=1034864 --user=宋昌昌 【系统设置】系统-组织与项目-创建项目-模块设置-不勾选XXXX模块-未生效 https://www.tapd.cn/55049933/s/1489092
This commit is contained in:
song-cc-rock 2024-04-07 15:47:27 +08:00 committed by 刘瑞斌
parent 5ceccd1a77
commit fbd120bb51
1 changed files with 7 additions and 3 deletions

View File

@ -85,12 +85,16 @@ export function composePermissions(userRoleRelations: UserRoleRelation[], type:
export function topLevelMenuHasPermission(route: RouteLocationNormalized | RouteRecordRaw) { export function topLevelMenuHasPermission(route: RouteLocationNormalized | RouteRecordRaw) {
const userStore = useUserStore(); const userStore = useUserStore();
const appStore = useAppStore(); const appStore = useAppStore();
const { currentMenuConfig } = appStore;
if (!currentMenuConfig.includes(route.name as string)) {
// 没有配置的菜单不显示
return false;
}
if (userStore.isAdmin) { if (userStore.isAdmin) {
// 如果是超级管理员,或者是系统设置菜单,或者是项目菜单,都有权限 // 如果是系统管理员, 包含项目, 组织, 系统层级所有菜单权限
return true; return true;
} }
const { currentMenuConfig } = appStore; return hasAnyPermission(route.meta?.roles || []);
return currentMenuConfig.includes(route.name as string) && hasAnyPermission(route.meta?.roles || []);
} }
// 有权限的第一个路由名如果没有找到则返回IndexRoute // 有权限的第一个路由名如果没有找到则返回IndexRoute