fix: restore control center route menu

This commit is contained in:
2026-06-22 08:34:58 +08:00
parent 3e9ed9e132
commit b8a03a19aa
2 changed files with 24 additions and 3 deletions
+21 -3
View File
@@ -15,14 +15,25 @@ import { isLightMenuName } from './light-menu';
const forbiddenComponent = () => import('#/views/_core/fallback/forbidden.vue');
const LEGACY_COMPONENT_MAP: Record<string, string> = {
'/online-dev/page-render/index': '/_core/page-render/index',
'online-dev/page-render/index': '/_core/page-render/index',
};
function normalizeViewPath(path: string) {
const normalizedPath = path.replace(/^(\.\/|\.\.\/)+/, '');
const mappedPath = LEGACY_COMPONENT_MAP[path] || path;
const normalizedPath = mappedPath.replace(/^(\.\/|\.\.\/)+/, '');
const viewPath = normalizedPath.startsWith('/')
? normalizedPath
: `/${normalizedPath}`;
return viewPath.replace(/^\/views/, '');
}
function normalizeRouteComponent(component?: string) {
if (!component) return component;
return LEGACY_COMPONENT_MAP[component] || component;
}
function hasPageComponent(
component: string | undefined,
pageMap: ComponentRecordType,
@@ -156,7 +167,9 @@ function filterAvailableRoutes<
return groupRoute;
}
if (!hasPageComponent(route.component, pageMap, layoutMap)) {
const component = normalizeRouteComponent(route.component);
if (!hasPageComponent(component, pageMap, layoutMap)) {
if (!children?.length) return undefined;
const groupRoute = { ...route, children };
@@ -164,7 +177,12 @@ function filterAvailableRoutes<
return groupRoute;
}
return children ? { ...route, children } : route;
const nextRoute =
component && component !== route.component
? { ...route, component }
: route;
return children ? { ...nextRoute, children } : nextRoute;
})
.filter(Boolean) as T[];
}