From 16490392b2cf28c3eff49c99b1451b9494615181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?cls=5F=E5=AE=81=E6=B3=A2=E6=9C=AC=E6=9C=BA?= <908705107@qq.com> Date: Fri, 12 Jun 2026 10:04:48 +0800 Subject: [PATCH] feat: restore ai app context support --- .../src/router/routes/modules/ai-platform.ts | 69 +++++++++++++++++++ .../agent/components/PublishToMenuDialog.vue | 4 ++ .../views/ai-platform/agent/editor/index.vue | 4 +- .../src/views/ai-platform/agent/index.vue | 30 ++++++-- .../agent/modules/import-dialog.vue | 4 ++ .../ai-platform/knowledge/detail/index.vue | 4 +- .../src/views/ai-platform/knowledge/index.vue | 36 +++++++++- .../views/ai-platform/workflow-runs/data.ts | 4 ++ .../views/ai-platform/workflow-runs/index.vue | 3 + .../workflow-runs/modules/detail-dialog.vue | 8 ++- 10 files changed, 154 insertions(+), 12 deletions(-) diff --git a/web/apps/web-ele/src/router/routes/modules/ai-platform.ts b/web/apps/web-ele/src/router/routes/modules/ai-platform.ts index 9be5185..e2b6250 100644 --- a/web/apps/web-ele/src/router/routes/modules/ai-platform.ts +++ b/web/apps/web-ele/src/router/routes/modules/ai-platform.ts @@ -13,6 +13,12 @@ const routes: RouteRecordRaw[] = [ path: '/ai-platform/knowledge', redirect: '/ai-platform/knowledge-base', }, + { + meta: { hideInMenu: true }, + name: 'SubAppAIKnowledgeLegacyRedirect', + path: '/app/:appCode/ai-platform/knowledge', + redirect: (to) => `/app/${to.params.appCode}/ai-platform/knowledge-base`, + }, { meta: { hideInMenu: true, @@ -22,6 +28,15 @@ const routes: RouteRecordRaw[] = [ path: '/agent-chat/:code', component: () => import('#/views/_core/agent-chat/index.vue'), }, + { + meta: { + hideInMenu: true, + title: '智能体对话', + }, + name: 'SubAppAgentChat', + path: '/app/:appCode/agent-chat/:code', + component: () => import('#/views/_core/agent-chat/index.vue'), + }, { meta: { hideInMenu: true, @@ -31,12 +46,28 @@ const routes: RouteRecordRaw[] = [ path: '/ai-platform/model', component: () => import('#/views/ai-platform/model/index.vue'), }, + { + meta: { + hideInMenu: true, + title: '模型配置', + }, + name: 'SubAppAIModelConfig', + path: '/app/:appCode/ai-platform/model', + component: () => import('#/views/ai-platform/model/index.vue'), + }, { meta: { hideInMenu: true }, name: 'AIKnowledgeLegacyDetailRedirect', path: '/ai-platform/knowledge/detail/:id', redirect: (to) => `/ai-platform/knowledge-base/detail/${to.params.id}`, }, + { + meta: { hideInMenu: true }, + name: 'SubAppAIKnowledgeLegacyDetailRedirect', + path: '/app/:appCode/ai-platform/knowledge/detail/:id', + redirect: (to) => + `/app/${to.params.appCode}/ai-platform/knowledge-base/detail/${to.params.id}`, + }, { meta: { hideInMenu: true, @@ -46,6 +77,15 @@ const routes: RouteRecordRaw[] = [ path: '/ai-platform/workflow-runs', component: () => import('#/views/ai-platform/workflow-runs/index.vue'), }, + { + meta: { + hideInMenu: true, + title: '执行历史', + }, + name: 'SubAppAIWorkflowRuns', + path: '/app/:appCode/ai-platform/workflow-runs', + component: () => import('#/views/ai-platform/workflow-runs/index.vue'), + }, // 工作流编辑器 { meta: { @@ -57,6 +97,16 @@ const routes: RouteRecordRaw[] = [ path: '/ai-platform/workflow/editor/:id', component: () => import('#/views/ai-platform/workflow/editor/index.vue'), }, + { + meta: { + hideInMenu: true, + title: '工作流编辑器', + noBasicLayout: true, + }, + name: 'SubAppAIWorkflowEditor', + path: '/app/:appCode/ai-platform/workflow/editor/:id', + component: () => import('#/views/ai-platform/workflow/editor/index.vue'), + }, // 智能体编辑器 { meta: { @@ -68,6 +118,16 @@ const routes: RouteRecordRaw[] = [ path: '/ai-platform/agent/editor/:id', component: () => import('#/views/ai-platform/agent/editor/index.vue'), }, + { + meta: { + hideInMenu: true, + title: '智能体编辑器', + noBasicLayout: true, + }, + name: 'SubAppAIAgentEditor', + path: '/app/:appCode/ai-platform/agent/editor/:id', + component: () => import('#/views/ai-platform/agent/editor/index.vue'), + }, // 知识库详情 { meta: { @@ -78,6 +138,15 @@ const routes: RouteRecordRaw[] = [ path: '/ai-platform/knowledge-base/detail/:id', component: () => import('#/views/ai-platform/knowledge/detail/index.vue'), }, + { + meta: { + hideInMenu: true, + title: '知识库详情', + }, + name: 'SubAppAIKnowledgeDetail', + path: '/app/:appCode/ai-platform/knowledge-base/detail/:id', + component: () => import('#/views/ai-platform/knowledge/detail/index.vue'), + }, ]; export default routes; diff --git a/web/apps/web-ele/src/views/ai-platform/agent/components/PublishToMenuDialog.vue b/web/apps/web-ele/src/views/ai-platform/agent/components/PublishToMenuDialog.vue index bee5d3a..558d226 100644 --- a/web/apps/web-ele/src/views/ai-platform/agent/components/PublishToMenuDialog.vue +++ b/web/apps/web-ele/src/views/ai-platform/agent/components/PublishToMenuDialog.vue @@ -19,6 +19,7 @@ import { import { publishAgentToMenuApi } from '#/api/ai-platform/ai-platform'; import { ZqIconPicker } from '#/components/zq-form/zq-icon-picker'; import { ZqMenuSelector } from '#/components/zq-form/zq-menu-selector'; +import { useAppContextStore } from '#/store/app-context'; interface Props { modelValue: boolean; @@ -34,6 +35,8 @@ const emit = defineEmits<{ 'update:modelValue': [value: boolean]; }>(); +const appContextStore = useAppContextStore(); + const dialogVisible = computed({ get: () => props.modelValue, set: (val) => emit('update:modelValue', val), @@ -130,6 +133,7 @@ async function handlePublish() { :placeholder=" $t('ai-platform.agent.publishDialog.parentMenuPlaceholder') " + :application-id="appContextStore.currentApp?.id" @change="handleMenuChange" /> diff --git a/web/apps/web-ele/src/views/ai-platform/agent/editor/index.vue b/web/apps/web-ele/src/views/ai-platform/agent/editor/index.vue index ea1edbc..6193309 100644 --- a/web/apps/web-ele/src/views/ai-platform/agent/editor/index.vue +++ b/web/apps/web-ele/src/views/ai-platform/agent/editor/index.vue @@ -49,10 +49,12 @@ import { publishAgentApi, updateAgentApi, } from '#/api/ai-platform/ai-platform'; +import { useAppContextStore } from '#/store/app-context'; const AiChatPanel = defineAsyncComponent(() => import('#/components/ai-chat-panel/AiChatPanel.vue'), ); +const appContextStore = useAppContextStore(); const route = useRoute(); const router = useRouter(); @@ -217,7 +219,7 @@ async function handlePublish() { // 返回 function handleBack() { - router.push('/ai-platform/agent'); + router.push(appContextStore.getContextPath('/ai-platform/agent')); } // 添加性格特点 diff --git a/web/apps/web-ele/src/views/ai-platform/agent/index.vue b/web/apps/web-ele/src/views/ai-platform/agent/index.vue index f1fe8bd..14abfc0 100644 --- a/web/apps/web-ele/src/views/ai-platform/agent/index.vue +++ b/web/apps/web-ele/src/views/ai-platform/agent/index.vue @@ -4,7 +4,7 @@ import type { AgentListItem, } from '#/api/ai-platform/ai-platform'; -import { onMounted, reactive, ref } from 'vue'; +import { computed, onMounted, reactive, ref } from 'vue'; import { useRouter } from 'vue-router'; import { Page } from '@vben/common-ui/es/page'; @@ -39,6 +39,7 @@ import { ElOption, ElPagination, ElSelect, + ElSwitch, ElTag, ElTooltip, } from 'element-plus'; @@ -52,6 +53,7 @@ import { publishAgentApi, unpublishAgentMenuApi, } from '#/api/ai-platform/ai-platform'; +import { useAppContextStore } from '#/store/app-context'; import PublishToMenuDialog from './components/PublishToMenuDialog.vue'; import ImportDialog from './modules/import-dialog.vue'; @@ -59,6 +61,8 @@ import ImportDialog from './modules/import-dialog.vue'; defineOptions({ name: 'AgentList' }); const router = useRouter(); +const appContextStore = useAppContextStore(); +const isMainApp = computed(() => appContextStore.isMainApp); // 搜索关键词 const searchKeyword = ref(''); @@ -100,6 +104,7 @@ async function fetchList() { page: pagination.current, pageSize: pagination.pageSize, name: searchKeyword.value || undefined, + applicationId: appContextStore.currentApp?.id, }); agentList.value = res.items; pagination.total = res.total; @@ -156,10 +161,13 @@ async function handleCreate() { try { const agent = await createAgentApi({ ...createForm, + application_id: appContextStore.currentApp?.id, }); ElMessage.success($t('ai-platform.agent.createSuccess')); createDialogVisible.value = false; - router.push(`/ai-platform/agent/editor/${agent.id}`); + router.push( + appContextStore.getContextPath(`/ai-platform/agent/editor/${agent.id}`), + ); } catch (error: any) { ElMessage.error(error.message || $t('ai-platform.agent.createFailed')); } finally { @@ -169,12 +177,14 @@ async function handleCreate() { // 编辑智能体 function handleEdit(agent: AgentListItem) { - router.push(`/ai-platform/agent/editor/${agent.id}`); + router.push( + appContextStore.getContextPath(`/ai-platform/agent/editor/${agent.id}`), + ); } // 对话 function handleChat(agent: AgentListItem) { - router.push(`/agent-chat/${agent.code}`); + router.push(appContextStore.getContextPath(`/agent-chat/${agent.code}`)); } // 发布 @@ -497,8 +507,10 @@ onMounted(() => {