feat: expose light ai admin menus
This commit is contained in:
@@ -43,10 +43,12 @@ const LOCAL_ICONS_MAP: Recordable<string[]> = {
|
|||||||
lucide: [
|
lucide: [
|
||||||
'lucide:bot',
|
'lucide:bot',
|
||||||
'lucide:check-square',
|
'lucide:check-square',
|
||||||
|
'lucide:history',
|
||||||
'lucide:layout-grid',
|
'lucide:layout-grid',
|
||||||
'lucide:library-big',
|
'lucide:library-big',
|
||||||
'lucide:list',
|
'lucide:list',
|
||||||
'lucide:megaphone',
|
'lucide:megaphone',
|
||||||
|
'lucide:settings',
|
||||||
'lucide:square-check-big',
|
'lucide:square-check-big',
|
||||||
'lucide:square-user',
|
'lucide:square-user',
|
||||||
'lucide:workflow',
|
'lucide:workflow',
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
"aiAgent": "智能体",
|
"aiAgent": "智能体",
|
||||||
"workflowOrchestration": "流程编排",
|
"workflowOrchestration": "流程编排",
|
||||||
"workflowRunHistory": "执行历史",
|
"workflowRunHistory": "执行历史",
|
||||||
|
"modelConfig": "模型配置",
|
||||||
"knowledgeBase": "知识库",
|
"knowledgeBase": "知识库",
|
||||||
"codex": "Codex",
|
"codex": "Codex",
|
||||||
"startChat": "开始聊天",
|
"startChat": "开始聊天",
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type {
|
import type {
|
||||||
ComponentRecordType,
|
ComponentRecordType,
|
||||||
GenerateMenuAndRoutesOptions,
|
GenerateMenuAndRoutesOptions,
|
||||||
|
RouteRecordStringComponent,
|
||||||
} from '@vben/types';
|
} from '@vben/types';
|
||||||
|
|
||||||
import { generateAccessible } from '@vben/access';
|
import { generateAccessible } from '@vben/access';
|
||||||
@@ -52,6 +53,61 @@ function isLightMenuRoute(route: { name?: string }) {
|
|||||||
return isLightMenuName(route.name);
|
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<
|
function filterAvailableRoutes<
|
||||||
T extends {
|
T extends {
|
||||||
children?: T[];
|
children?: T[];
|
||||||
@@ -149,7 +205,8 @@ async function generateAccess(options: GenerateMenuAndRoutesOptions) {
|
|||||||
? await getAllMenusApi(appContextStore.appCode)
|
? await getAllMenusApi(appContextStore.appCode)
|
||||||
: await getAllMenusApi();
|
: await getAllMenusApi();
|
||||||
|
|
||||||
return filterAvailableRoutes(menus, routePageMap, layoutMap);
|
const lightMenus = filterAvailableRoutes(menus, routePageMap, layoutMap);
|
||||||
|
return appendLightAiPlatformMenus(lightMenus);
|
||||||
},
|
},
|
||||||
forbiddenComponent,
|
forbiddenComponent,
|
||||||
layoutMap,
|
layoutMap,
|
||||||
|
|||||||
@@ -17,12 +17,14 @@ import {
|
|||||||
ChevronRight,
|
ChevronRight,
|
||||||
Circle,
|
Circle,
|
||||||
Edit,
|
Edit,
|
||||||
|
History,
|
||||||
LayoutGrid,
|
LayoutGrid,
|
||||||
List,
|
List,
|
||||||
Mail,
|
Mail,
|
||||||
Megaphone,
|
Megaphone,
|
||||||
Plus,
|
Plus,
|
||||||
RefreshCw,
|
RefreshCw,
|
||||||
|
Settings,
|
||||||
SquareCheckBig,
|
SquareCheckBig,
|
||||||
Trash2,
|
Trash2,
|
||||||
TriangleAlert,
|
TriangleAlert,
|
||||||
@@ -58,10 +60,12 @@ const localIconMap: Record<string, Component> = {
|
|||||||
'ep:refresh-right': RefreshCw,
|
'ep:refresh-right': RefreshCw,
|
||||||
'lucide:bot': Bot,
|
'lucide:bot': Bot,
|
||||||
'lucide:check-square': CheckSquare,
|
'lucide:check-square': CheckSquare,
|
||||||
|
'lucide:history': History,
|
||||||
'lucide:layout-grid': LayoutGrid,
|
'lucide:layout-grid': LayoutGrid,
|
||||||
'lucide:library-big': BookOpen,
|
'lucide:library-big': BookOpen,
|
||||||
'lucide:list': List,
|
'lucide:list': List,
|
||||||
'lucide:megaphone': Megaphone,
|
'lucide:megaphone': Megaphone,
|
||||||
|
'lucide:settings': Settings,
|
||||||
'lucide:square-check-big': SquareCheckBig,
|
'lucide:square-check-big': SquareCheckBig,
|
||||||
'lucide:square-user': UserRound,
|
'lucide:square-user': UserRound,
|
||||||
'lucide:workflow': Workflow,
|
'lucide:workflow': Workflow,
|
||||||
|
|||||||
@@ -43,10 +43,12 @@ const LOCAL_ICONS_MAP: Recordable<string[]> = {
|
|||||||
lucide: [
|
lucide: [
|
||||||
'lucide:bot',
|
'lucide:bot',
|
||||||
'lucide:check-square',
|
'lucide:check-square',
|
||||||
|
'lucide:history',
|
||||||
'lucide:layout-grid',
|
'lucide:layout-grid',
|
||||||
'lucide:library-big',
|
'lucide:library-big',
|
||||||
'lucide:list',
|
'lucide:list',
|
||||||
'lucide:megaphone',
|
'lucide:megaphone',
|
||||||
|
'lucide:settings',
|
||||||
'lucide:square-check-big',
|
'lucide:square-check-big',
|
||||||
'lucide:square-user',
|
'lucide:square-user',
|
||||||
'lucide:workflow',
|
'lucide:workflow',
|
||||||
|
|||||||
Reference in New Issue
Block a user