fix
This commit is contained in:
@@ -181,10 +181,16 @@ function extractRelativePath(childPath: string, parentPath: string): string {
|
|||||||
* @param parentIsFull 父级菜单的 is_full 字段
|
* @param parentIsFull 父级菜单的 is_full 字段
|
||||||
* @returns 子路由配置数组
|
* @returns 子路由配置数组
|
||||||
*/
|
*/
|
||||||
/** 服务端未配置 component 时按 menu_path 绑定视图(避免误用 redirect 导致白屏) */
|
/** 许可授权中心菜单路径(严格匹配末段,避免 menu_path 中含 query 等导致误伤其它菜单如用户管理) */
|
||||||
const MENU_PATH_COMPONENT_FALLBACK: { test: (fullPath: string) => boolean; component: string }[] = [
|
const LICENSE_CENTER_VIEW = 'ops/pages/system-settings/license-center'
|
||||||
{ test: (p) => p.includes('license-center'), component: '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(
|
function transformChildRoutes(
|
||||||
children: ServerMenuItem[],
|
children: ServerMenuItem[],
|
||||||
@@ -193,14 +199,15 @@ function transformChildRoutes(
|
|||||||
parentIsFull?: boolean
|
parentIsFull?: boolean
|
||||||
): AppRouteRecordRaw[] {
|
): AppRouteRecordRaw[] {
|
||||||
return children.map((child) => {
|
return children.map((child) => {
|
||||||
// 计算子路由的相对路径(需先于 component 解析,供 path 兜底使用)
|
const childFullPath = String(child.menu_path ?? child.path ?? '').trim()
|
||||||
const childFullPath = child.menu_path || child.path || ''
|
|
||||||
|
|
||||||
// 优先使用子菜单自己的 component,否则继承父级的 component;再按路径兜底
|
// 已配置 component 的菜单绝不覆盖;仅对许可页做路径/code 兜底,避免 includes 误匹配
|
||||||
let componentPath = child.component || parentComponent
|
let componentPath = child.component || parentComponent
|
||||||
const matchedFallback = MENU_PATH_COMPONENT_FALLBACK.find((fb) => fb.test(childFullPath))
|
if (
|
||||||
if (matchedFallback) {
|
!child.component &&
|
||||||
componentPath = matchedFallback.component
|
(isLicenseCenterMenuPath(childFullPath) || child.code === 'LicenseCenter')
|
||||||
|
) {
|
||||||
|
componentPath = LICENSE_CENTER_VIEW
|
||||||
}
|
}
|
||||||
|
|
||||||
const relativePath = extractRelativePath(childFullPath, parentPath || '')
|
const relativePath = extractRelativePath(childFullPath, parentPath || '')
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const OPS: AppRouteRecordRaw = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'license-center',
|
path: 'license-center',
|
||||||
name: 'LicenseCenter',
|
name: 'OpsLicenseCenter',
|
||||||
component: () => import('@/views/ops/pages/system-settings/license-center/index.vue'),
|
component: () => import('@/views/ops/pages/system-settings/license-center/index.vue'),
|
||||||
meta: {
|
meta: {
|
||||||
locale: 'menu.ops.systemSettings.licenseCenter',
|
locale: 'menu.ops.systemSettings.licenseCenter',
|
||||||
|
|||||||
Reference in New Issue
Block a user