Files
crawler-plugin/admin-frontend-vue/src/config/company-scope.ts
T
huangzd1997 1f23369629 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,意图不降反强)
2026-10-04 18:28:43 +08:00

29 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/** 公司口径的唯一清单(设计文档 §8)。
* 单独成文件而不是塞进 routes.ts:routes.ts 被 menu-route-map.ts import,
* 而护栏用例要从这里反过来读注册表,放在一起会成环。 */
/** 角色内在闸门:只有超管可见可读写,与 user_column_permission 无关。 */
export const SUPER_ADMIN_ONLY_MENU_KEYS: readonly string[] = ['admin_companies']
export interface CompanyScopedPage {
/** 与 routes.ts 的 menuKey 逐字一致。 */
menuKey: string
/** 相对 admin-frontend-vue 的 api/取数模块路径;护栏逐文件断言它真的带了 company_id。 */
apiFiles: string[]
/** 页面组件路径;护栏断言它 watch 了 tab.activeId(否则切 tab 不重取数,tab 是装饰品)。 */
pageFiles: string[]
}
/** 参与公司 tab 的页(spec §3 归属普查:批次 1 = 9 个 A 类页里除去依赖二期 V145 的去重库)。
* 后续批次往里加行时,同一笔提交必须带上对应 api 文件的 company_id,否则新用例红。 */
export const COMPANY_SCOPED_PAGES: readonly CompanyScopedPage[] = [
{ menuKey: 'admin_task_center', apiFiles: ['src/api/task-center.ts', 'src/pages/task-center/task-center-model.ts'], pageFiles: ['src/pages/task-center/TaskCenterBoardPage.vue'] },
{ menuKey: 'admin_image_video_tasks', apiFiles: ['src/pages/tasks/image-video-api.ts'], pageFiles: ['src/pages/tasks/ImageVideoTasksPage.vue'] },
{ menuKey: 'admin_user_secret_usage', apiFiles: ['src/api/user-secret-usage.ts'], pageFiles: ['src/pages/account/UserSecretUsagePage.vue'] },
{ menuKey: 'admin_user_secrets', apiFiles: ['src/api/user-secrets.ts'], pageFiles: ['src/pages/account/UserSecretsPage.vue'] },
{ menuKey: 'admin_history', apiFiles: ['src/pages/records/history-api.ts'], pageFiles: ['src/pages/records/RecordsHistoryPage.vue'] },
{ menuKey: 'admin_device_logs', apiFiles: ['src/api/device-logs.ts'], pageFiles: ['src/pages/records/DeviceLogsPage.vue'] },
{ menuKey: 'admin_group_manage', apiFiles: ['src/pages/account/shop-group-api.ts'], pageFiles: ['src/pages/account/GroupsPage.vue'] },
{ menuKey: 'admin_shop_manage', apiFiles: ['src/pages/shop/shop-manage-api.ts'], pageFiles: ['src/pages/shop/ShopManagePage.vue'] },
]