feat: expose light ai admin menus
This commit is contained in:
@@ -43,10 +43,12 @@ const LOCAL_ICONS_MAP: Recordable<string[]> = {
|
||||
lucide: [
|
||||
'lucide:bot',
|
||||
'lucide:check-square',
|
||||
'lucide:history',
|
||||
'lucide:layout-grid',
|
||||
'lucide:library-big',
|
||||
'lucide:list',
|
||||
'lucide:megaphone',
|
||||
'lucide:settings',
|
||||
'lucide:square-check-big',
|
||||
'lucide:square-user',
|
||||
'lucide:workflow',
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"aiAgent": "智能体",
|
||||
"workflowOrchestration": "流程编排",
|
||||
"workflowRunHistory": "执行历史",
|
||||
"modelConfig": "模型配置",
|
||||
"knowledgeBase": "知识库",
|
||||
"codex": "Codex",
|
||||
"startChat": "开始聊天",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type {
|
||||
ComponentRecordType,
|
||||
GenerateMenuAndRoutesOptions,
|
||||
RouteRecordStringComponent,
|
||||
} from '@vben/types';
|
||||
|
||||
import { generateAccessible } from '@vben/access';
|
||||
@@ -52,6 +53,61 @@ function isLightMenuRoute(route: { name?: string }) {
|
||||
return isLightMenuName(route.name);
|
||||
}
|
||||
|
||||
function createLightAiMenuRoute(
|
||||
route: Pick<RouteRecordStringComponent, 'component' | 'name' | 'path'> & {
|
||||
meta: RouteRecordStringComponent['meta'];
|
||||
},
|
||||
): RouteRecordStringComponent {
|
||||
return route as RouteRecordStringComponent;
|
||||
}
|
||||
|
||||
const LIGHT_AI_PLATFORM_MENU_ROUTES = [
|
||||
createLightAiMenuRoute({
|
||||
component: '/ai-platform/model/index',
|
||||
meta: {
|
||||
fullPathKey: true,
|
||||
icon: 'lucide:settings',
|
||||
order: 30,
|
||||
title: 'menu-title.modelConfig',
|
||||
},
|
||||
name: 'AIModelConfig',
|
||||
path: '/ai-platform/model',
|
||||
}),
|
||||
createLightAiMenuRoute({
|
||||
component: '/ai-platform/workflow-runs/index',
|
||||
meta: {
|
||||
fullPathKey: true,
|
||||
icon: 'lucide:history',
|
||||
order: 40,
|
||||
title: 'menu-title.workflowRunHistory',
|
||||
},
|
||||
name: 'AIWorkflowRuns',
|
||||
path: '/ai-platform/workflow-runs',
|
||||
}),
|
||||
];
|
||||
|
||||
function appendLightAiPlatformMenus(routes: RouteRecordStringComponent[]) {
|
||||
return routes.map((route) => {
|
||||
const children = route.children
|
||||
? appendLightAiPlatformMenus(route.children)
|
||||
: undefined;
|
||||
|
||||
if (route.name !== 'AIPlatform') {
|
||||
return children ? { ...route, children } : route;
|
||||
}
|
||||
|
||||
const existingNames = new Set(children?.map((item) => item.name));
|
||||
const missingRoutes = LIGHT_AI_PLATFORM_MENU_ROUTES.filter(
|
||||
(item) => !existingNames.has(item.name),
|
||||
);
|
||||
const nextChildren = [...(children || []), ...missingRoutes].sort(
|
||||
(a, b) => Number(a.meta?.order || 0) - Number(b.meta?.order || 0),
|
||||
);
|
||||
|
||||
return { ...route, children: nextChildren };
|
||||
});
|
||||
}
|
||||
|
||||
function filterAvailableRoutes<
|
||||
T extends {
|
||||
children?: T[];
|
||||
@@ -149,7 +205,8 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
||||
? await getAllMenusApi(appContextStore.appCode)
|
||||
: await getAllMenusApi();
|
||||
|
||||
return filterAvailableRoutes(menus, routePageMap, layoutMap);
|
||||
const lightMenus = filterAvailableRoutes(menus, routePageMap, layoutMap);
|
||||
return appendLightAiPlatformMenus(lightMenus);
|
||||
},
|
||||
forbiddenComponent,
|
||||
layoutMap,
|
||||
|
||||
Reference in New Issue
Block a user