From 87741c59ff865afc279d4dd21a5c0c0189efd4e6 Mon Sep 17 00:00:00 2001 From: zxr <271055687@qq.com> Date: Sat, 21 Mar 2026 17:13:47 +0800 Subject: [PATCH] fix --- src/router/menu-data.ts | 27 +++++++++++++++++---------- src/router/routes/modules/ops.ts | 2 +- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/router/menu-data.ts b/src/router/menu-data.ts index 1b33029..a69c164 100644 --- a/src/router/menu-data.ts +++ b/src/router/menu-data.ts @@ -181,10 +181,16 @@ function extractRelativePath(childPath: string, parentPath: string): string { * @param parentIsFull 父级菜单的 is_full 字段 * @returns 子路由配置数组 */ -/** 服务端未配置 component 时按 menu_path 绑定视图(避免误用 redirect 导致白屏) */ -const MENU_PATH_COMPONENT_FALLBACK: { test: (fullPath: string) => boolean; component: string }[] = [ - { test: (p) => p.includes('license-center'), component: 'ops/pages/system-settings/license-center' }, -] +/** 许可授权中心菜单路径(严格匹配末段,避免 menu_path 中含 query 等导致误伤其它菜单如用户管理) */ +const LICENSE_CENTER_VIEW = 'ops/pages/system-settings/license-center' + +function isLicenseCenterMenuPath(fullPath: string): boolean { + const path = String(fullPath ?? '') + .trim() + .split('?')[0] + .replace(/\/+$/, '') + return path.endsWith('/license-center') || path === 'license-center' +} function transformChildRoutes( children: ServerMenuItem[], @@ -193,14 +199,15 @@ function transformChildRoutes( parentIsFull?: boolean ): AppRouteRecordRaw[] { return children.map((child) => { - // 计算子路由的相对路径(需先于 component 解析,供 path 兜底使用) - const childFullPath = child.menu_path || child.path || '' + const childFullPath = String(child.menu_path ?? child.path ?? '').trim() - // 优先使用子菜单自己的 component,否则继承父级的 component;再按路径兜底 + // 已配置 component 的菜单绝不覆盖;仅对许可页做路径/code 兜底,避免 includes 误匹配 let componentPath = child.component || parentComponent - const matchedFallback = MENU_PATH_COMPONENT_FALLBACK.find((fb) => fb.test(childFullPath)) - if (matchedFallback) { - componentPath = matchedFallback.component + if ( + !child.component && + (isLicenseCenterMenuPath(childFullPath) || child.code === 'LicenseCenter') + ) { + componentPath = LICENSE_CENTER_VIEW } const relativePath = extractRelativePath(childFullPath, parentPath || '') diff --git a/src/router/routes/modules/ops.ts b/src/router/routes/modules/ops.ts index 1631cc2..555e435 100644 --- a/src/router/routes/modules/ops.ts +++ b/src/router/routes/modules/ops.ts @@ -34,7 +34,7 @@ const OPS: AppRouteRecordRaw = { }, { path: 'license-center', - name: 'LicenseCenter', + name: 'OpsLicenseCenter', component: () => import('@/views/ops/pages/system-settings/license-center/index.vue'), meta: { locale: 'menu.ops.systemSettings.licenseCenter',