This commit is contained in:
zxr
2026-03-21 17:06:54 +08:00
parent 69e421834b
commit ecf78bc727
7 changed files with 480 additions and 4 deletions

View File

@@ -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 = {

View File

@@ -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',