feat(前端): 公司管理加角色内在闸门(注册表+守卫+剪枝)
- 新建 src/config/company-scope.ts:SUPER_ADMIN_ONLY_MENU_KEYS=['admin_companies'] 与 COMPANY_SCOPED_PAGES(批次 1 的 8 页口径清单,后续任务的唯一分母) - routes.ts:AdminPageDef 加 superAdminOnly/companyScoped;公司管理标 superAdminOnly: true, 8 个 A 类页标 companyScoped: true,C 类两页显式写 false(声明而非留空) - helpers.ts:pruneSuperAdminOnly 纯函数(超管原样返回,非超管递归剪掉专属节点) - router/index.ts:菜单授权之外补一条与菜单树无关的角色判定 - admin-session.ts:菜单树唯一写点内接剪枝(顺序仍在 fetchCurrentUser 之后) - 新增 tests/company-super-admin-only.test.ts 5 支护栏 - task-29 的主路径断言随唯一写点改写(原断言只认 canonicalize 裸赋值, 剪枝并入同一写点后必然失配;改为同时要求 prune + canonicalize,意图不降反强)
This commit is contained in:
@@ -48,6 +48,11 @@ router.beforeEach(async (to) => {
|
||||
if (to.path === '/') {
|
||||
return session.firstVisible || true
|
||||
}
|
||||
// 角色内在闸门:与菜单树无关。超管恒 true 会让"只剪菜单树"这条对超管无效,
|
||||
// 而非超管即使被历史授权过 admin_companies 也进不来(spec §8.1:两处缺一处就留旁路)。
|
||||
if (to.meta.superAdminOnly && !session.isSuperAdmin) {
|
||||
return session.firstVisible || '/'
|
||||
}
|
||||
// 页面级权限:无 menuKey 开放页放行;越权页回退首个可见页,全无则回根空态。
|
||||
if (!isRouteAllowed(session.isSuperAdmin, to.meta.menuKey, session.menuTree)) {
|
||||
return session.firstVisible || '/'
|
||||
|
||||
Reference in New Issue
Block a user