Use lightweight control center home
This commit is contained in:
@@ -46,30 +46,55 @@ function normalizePageMap(pageMap: ComponentRecordType) {
|
||||
) as ComponentRecordType;
|
||||
}
|
||||
|
||||
function filterAvailableRoutes<T extends { children?: T[]; component?: string }>(
|
||||
function normalizeBackendRoute<T extends { component?: string; name?: string; path?: string; query?: unknown }>(
|
||||
route: T,
|
||||
) {
|
||||
if (route.name !== 'ControlCenter') return route;
|
||||
|
||||
const normalized = { ...route };
|
||||
normalized.path = '/control-center';
|
||||
normalized.component = '_core/control-center/index';
|
||||
normalized.query = undefined;
|
||||
return normalized;
|
||||
}
|
||||
|
||||
function filterAvailableRoutes<
|
||||
T extends {
|
||||
children?: T[];
|
||||
component?: string;
|
||||
name?: string;
|
||||
path?: string;
|
||||
query?: unknown;
|
||||
},
|
||||
>(
|
||||
routes: T[],
|
||||
pageMap: ComponentRecordType,
|
||||
layoutMap: ComponentRecordType,
|
||||
): T[] {
|
||||
return routes
|
||||
.map((route) => {
|
||||
const children = route.children
|
||||
? filterAvailableRoutes(route.children, pageMap, layoutMap)
|
||||
const normalizedRoute = normalizeBackendRoute(route);
|
||||
const children = normalizedRoute.children
|
||||
? filterAvailableRoutes(normalizedRoute.children, pageMap, layoutMap)
|
||||
: undefined;
|
||||
|
||||
if (!route.component && route.children && !children?.length) {
|
||||
if (
|
||||
!normalizedRoute.component &&
|
||||
normalizedRoute.children &&
|
||||
!children?.length
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (!hasPageComponent(route.component, pageMap, layoutMap)) {
|
||||
if (!hasPageComponent(normalizedRoute.component, pageMap, layoutMap)) {
|
||||
if (!children?.length) return undefined;
|
||||
|
||||
const groupRoute = { ...route, children };
|
||||
const groupRoute = { ...normalizedRoute, children };
|
||||
delete groupRoute.component;
|
||||
return groupRoute;
|
||||
}
|
||||
|
||||
return children ? { ...route, children } : route;
|
||||
return children ? { ...normalizedRoute, children } : normalizedRoute;
|
||||
})
|
||||
.filter(Boolean) as T[];
|
||||
}
|
||||
@@ -101,7 +126,6 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
||||
'../views/_core/system-config/index.vue',
|
||||
'../views/_core/ui-config/index.vue',
|
||||
'../views/_core/user/index.vue',
|
||||
'../views/online-dev/page-render/index.vue',
|
||||
'../views/ai-platform/agent/editor/index.vue',
|
||||
'../views/ai-platform/agent/index.vue',
|
||||
'../views/ai-platform/knowledge/detail/index.vue',
|
||||
|
||||
Reference in New Issue
Block a user