feat(rbac-web): 前端页面级权限与「权限与角色」管理页

- 新增 rbac 的 api/types/mock,对接后端 catalog/roles/users;mock 模式与后端 PageCatalog 完全对齐
- EffectivePermissions 增加 allowedPages,auth store 新增 hasPage 判定
- 路由守卫按 route.name = 页面 Key 做页面级放行,无权时跳转到 scope 内首个可访问页面;AppShell 菜单按 hasPage 过滤
- 路由守卫 switchScope 失败自动重试一次;新增懒加载 chunk 失败整页自愈 onError,修复切页白屏
- PermissionGuard hidden 态改为友好空态提示;AuthRoleView 重写为完整的用户/角色/权限编辑界面
This commit is contained in:
zhaowei.huang
2026-05-29 23:51:57 +08:00
parent 37680a0ae7
commit 00cfcf2897
11 changed files with 976 additions and 106 deletions
@@ -85,6 +85,16 @@ export const useAuthStore = defineStore('auth', {
(widgetId: string): 'hidden' | 'readonly' | 'interactive' => {
const grant = s.effectivePermissions?.visibleWidgets.find((w) => w.widgetId === widgetId)
return grant?.visibility ?? 'interactive'
},
/**
* 当前用户在当前 scope 下是否可访问指定页面(route.name)。
* '*' 视为全部页面(兜底兼容)。菜单过滤与路由守卫共用此判断。
*/
hasPage:
(s) =>
(key: string): boolean => {
const pages = s.effectivePermissions?.allowedPages ?? []
return pages.includes('*') || pages.includes(key)
}
},
actions: {