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 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) { function normalizeViewPath(path: string) {
const normalizedPath = path.replace(/^(\.\/|\.\.\/)+/, ''); const mappedPath = LEGACY_COMPONENT_MAP[path] || path;
const normalizedPath = mappedPath.replace(/^(\.\/|\.\.\/)+/, '');
const viewPath = normalizedPath.startsWith('/') const viewPath = normalizedPath.startsWith('/')
? normalizedPath ? normalizedPath
: `/${normalizedPath}`; : `/${normalizedPath}`;
return viewPath.replace(/^\/views/, ''); return viewPath.replace(/^\/views/, '');
} }
function normalizeRouteComponent(component?: string) {
if (!component) return component;
return LEGACY_COMPONENT_MAP[component] || component;
}
function hasPageComponent( function hasPageComponent(
component: string | undefined, component: string | undefined,
pageMap: ComponentRecordType, pageMap: ComponentRecordType,
@@ -156,7 +167,9 @@ function filterAvailableRoutes<
return groupRoute; return groupRoute;
} }
if (!hasPageComponent(route.component, pageMap, layoutMap)) { const component = normalizeRouteComponent(route.component);
if (!hasPageComponent(component, pageMap, layoutMap)) {
if (!children?.length) return undefined; if (!children?.length) return undefined;
const groupRoute = { ...route, children }; const groupRoute = { ...route, children };
@@ -164,7 +177,12 @@ function filterAvailableRoutes<
return groupRoute; 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[]; .filter(Boolean) as T[];
} }
@@ -14,6 +14,8 @@ export const LIGHT_MENU_NAMES = new Set([
'AnnouncementList', 'AnnouncementList',
'AnnouncementManage', 'AnnouncementManage',
'CodexAgentChat', 'CodexAgentChat',
'ControlCenter',
'ControlCenterLegacyRedirect',
'Message', 'Message',
'MessageCenter', 'MessageCenter',
'MessageList', 'MessageList',
@@ -44,6 +46,7 @@ const LIGHT_ROUTE_PATH_PREFIXES = [
'/ai-platform/workflow', '/ai-platform/workflow',
'/ai-platform/workflow-runs', '/ai-platform/workflow-runs',
'/agent-chat', '/agent-chat',
'/control-center',
'/message/list', '/message/list',
'/message/announcement', '/message/announcement',
'/message/announcement-list', '/message/announcement-list',