fix
This commit is contained in:
@@ -181,6 +181,11 @@ 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' },
|
||||
]
|
||||
|
||||
function transformChildRoutes(
|
||||
children: ServerMenuItem[],
|
||||
parentComponent?: string,
|
||||
@@ -188,10 +193,16 @@ function transformChildRoutes(
|
||||
parentIsFull?: boolean
|
||||
): AppRouteRecordRaw[] {
|
||||
return children.map((child) => {
|
||||
// 优先使用子菜单自己的 component,否则继承父级的 component
|
||||
const componentPath = child.component || parentComponent
|
||||
// 计算子路由的相对路径
|
||||
// 计算子路由的相对路径(需先于 component 解析,供 path 兜底使用)
|
||||
const childFullPath = child.menu_path || child.path || ''
|
||||
|
||||
// 优先使用子菜单自己的 component,否则继承父级的 component;再按路径兜底
|
||||
let componentPath = child.component || parentComponent
|
||||
const matchedFallback = MENU_PATH_COMPONENT_FALLBACK.find((fb) => fb.test(childFullPath))
|
||||
if (matchedFallback) {
|
||||
componentPath = matchedFallback.component
|
||||
}
|
||||
|
||||
const relativePath = extractRelativePath(childFullPath, parentPath || '')
|
||||
|
||||
const route: AppRouteRecordRaw = {
|
||||
|
||||
@@ -32,6 +32,16 @@ const OPS: AppRouteRecordRaw = {
|
||||
roles: ['*'],
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'license-center',
|
||||
name: 'LicenseCenter',
|
||||
component: () => import('@/views/ops/pages/system-settings/license-center/index.vue'),
|
||||
meta: {
|
||||
locale: 'menu.ops.systemSettings.licenseCenter',
|
||||
requiresAuth: true,
|
||||
roles: ['*'],
|
||||
},
|
||||
},
|
||||
{
|
||||
path: 'web-test',
|
||||
name: 'WebTest',
|
||||
|
||||
Reference in New Issue
Block a user