Files
crawler-plugin/admin-frontend-vue/src/router/routes.ts
T
huangzd1997 052f2bd4a5 revert(gating): 后管 Gating 页与入口回滚
删除品牌Gating库页面、API/导入/模型与测试,摘掉静态路由、操作指引条目与
ops-cell 列宽登记;菜单行由 V166 移除,后端模块保留但无授权入口。
2026-10-24 09:20:36 +08:00

74 lines
5.8 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.
import type { RouteRecordRaw } from 'vue-router'
export interface AdminPageMeta {
title: string
menuKey?: string
/** 角色内在闸门:非超管一律不可进(spec §2 的 A 类)。 */
superAdminOnly?: boolean
/** 参与公司 tab:取数必须带 company_id(spec §3)。 */
companyScoped?: boolean
}
export interface AdminPageDef extends AdminPageMeta {
/** 相对 /admin-vue/ 基准的子路径,不带前导斜杠、不带 base 前缀。 */
path: string
/** 异步组件加载器(页面按路由分包)。 */
load: () => Promise<{ default: unknown }>
}
/** 业务域路由注册表(任务 8):首批 account 域;后续按业务域在此登记页面。 */
export const adminPages: AdminPageDef[] = [
{ path: 'account/users', menuKey: 'admin_users', title: '用户管理', companyScoped: true, load: () => import('@/pages/account/UsersPage.vue') },
{ path: 'account/menus', menuKey: 'admin_columns', title: '菜单管理', companyScoped: true, load: () => import('@/pages/account/MenusPage.vue') },
{ path: 'account/groups', menuKey: 'admin_group_manage', title: '数据权限分组', companyScoped: true, load: () => import('@/pages/account/GroupsPage.vue') },
{ path: 'account/user-secrets', menuKey: 'admin_user_secrets', title: '密钥管理', companyScoped: true, load: () => import('@/pages/account/UserSecretsPage.vue') },
{ path: 'account/user-secret-usage', menuKey: 'admin_user_secret_usage', title: '密钥用量统计', companyScoped: true, load: () => import('@/pages/account/UserSecretUsagePage.vue') },
{ path: 'account/companies', menuKey: 'admin_companies', title: '公司管理', superAdminOnly: true, load: () => import('@/pages/account/CompaniesPage.vue') },
{ path: 'shop-center/duplicate-check', menuKey: 'admin_shop_data_duplicate_check', title: '店铺撞款监控', companyScoped: true, load: () => import('@/pages/tasks/DuplicateCheckPage.vue') },
{ path: 'shop-center/keys', menuKey: 'admin_shop_keys', title: '店铺密钥管理', companyScoped: true, load: () => import('@/pages/shop/ShopKeysPage.vue') },
{ path: 'shop-center/shops', menuKey: 'admin_shop_manage', title: '店铺管理', companyScoped: true, load: () => import('@/pages/shop/ShopManagePage.vue') },
{ path: 'records/history', menuKey: 'admin_history', title: '生成记录', companyScoped: true, load: () => import('@/pages/records/RecordsHistoryPage.vue') },
{ path: 'records/software-version', menuKey: 'admin_version', title: '软件版本管理', companyScoped: false, load: () => import('@/pages/records/RecordsSoftwareVersionPage.vue') },
{ path: 'records/tutorial', menuKey: 'admin_tutorial', title: '教程管理', companyScoped: false, load: () => import('@/pages/records/RecordsTutorialPage.vue') },
{ path: 'records/device-logs', menuKey: 'admin_device_logs', title: '日志管理', companyScoped: true, load: () => import('@/pages/records/DeviceLogsPage.vue') },
{ path: 'task-center/board', menuKey: 'admin_task_center', title: '客户端任务管理', companyScoped: true, load: () => import('@/pages/task-center/TaskCenterBoardPage.vue') },
{ path: 'records/digital-human-version', menuKey: 'digital_human_version', title: '数字人版本管理', load: () => import('@/pages/records/RecordsDigitalHumanVersionPage.vue') },
{ path: 'records/image-video-tasks', menuKey: 'admin_image_video_tasks', title: '视频任务记录', companyScoped: true, load: () => import('@/pages/tasks/ImageVideoTasksPage.vue') },
{ path: 'shop-center/data-tasks', menuKey: 'admin_shop_data_crawl_tasks', title: '店铺数据记录', companyScoped: true, load: () => import('@/pages/tasks/ShopDataTasksPage.vue') },
{ path: 'asin-center/registry', menuKey: 'admin_dedupe_total_data', title: '数据去重总数据', companyScoped: true, load: () => import('@/pages/asin/DedupeRegistryPage.vue') },
{ path: 'asin-center/invalid', menuKey: 'admin_invalid_asin_data', title: '品牌数据库', companyScoped: false, load: () => import('@/pages/asin/AsinInvalidPage.vue') },
{ path: 'asin-center/query', menuKey: 'admin_query_asin', title: '查询ASIN', companyScoped: true, load: () => import('@/pages/asin/QueryAsinPage.vue') },
{ path: 'asin-center/categories', menuKey: 'admin_product_categories', title: '商品类目', companyScoped: false, load: () => import('@/pages/asin/ProductCategoryPage.vue') },
{ path: 'asin-center/skip-price', menuKey: 'admin_skip_price_asin', title: '最低价ASIN', companyScoped: true, load: () => import('@/pages/asin/SkipPricePage.vue') },
]
export function routeOf(page: AdminPageDef): RouteRecordRaw {
if (!page.path || !page.load || !page.title) {
throw new Error(`路由注册表页面定义非法,需 path/load/title 齐全: ${JSON.stringify(page)}`)
}
const meta: Record<string, string | boolean> = { title: page.title }
if (page.menuKey) meta.menuKey = page.menuKey
if (page.superAdminOnly) meta.superAdminOnly = true
return { path: page.path, component: page.load, meta }
}
export const adminRouteRecords: RouteRecordRaw[] = adminPages.map(routeOf)
/** 校验注册表完整性:路径唯一、title/load 齐全、路径为相对子路径。返回问题清单。 */
export function validateAdminPages(pages: AdminPageDef[]): string[] {
const issues: string[] = []
const seen = new Set<string>()
for (const page of pages) {
if (!page.path || page.path.startsWith('/')) {
issues.push(`页面路径必须是相对子路径(不带 / 与 base 前缀): ${page.path || '(空)'}`)
} else if (seen.has(page.path)) {
issues.push(`页面路径重复: ${page.path}`)
}
seen.add(page.path)
if (!page.title) issues.push(`页面缺少标题: ${page.path}`)
if (!page.load) issues.push(`页面缺少异步加载器: ${page.path}`)
if (page.path.includes('/admin-vue')) issues.push(`页面路径不得包含 base 前缀: ${page.path}`)
}
return issues
}