fix
This commit is contained in:
@@ -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 || '')
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user