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(() => {
- {{ agent.model_name || '未配置模型' }} ·
- {{ agent.conversation_count || 0 }} 次对话
+
+ {{ agent.application_name }}
+
+ {{ $t('ai-platform.agent.mainApp') }}
{{ agent.sys_create_datetime }}
@@ -599,6 +611,12 @@ onMounted(() => {
type="textarea"
/>
+
+
+
diff --git a/web/apps/web-ele/src/views/ai-platform/agent/modules/import-dialog.vue b/web/apps/web-ele/src/views/ai-platform/agent/modules/import-dialog.vue
index 03e7209..60340f4 100644
--- a/web/apps/web-ele/src/views/ai-platform/agent/modules/import-dialog.vue
+++ b/web/apps/web-ele/src/views/ai-platform/agent/modules/import-dialog.vue
@@ -24,6 +24,7 @@ import {
importAgentConfigApi,
} from '#/api/ai-platform/ai-platform';
import { ZqDialog } from '#/components/zq-dialog';
+import { useAppContextStore } from '#/store/app-context';
interface Props {
modelValue: boolean;
@@ -36,6 +37,8 @@ const emit = defineEmits<{
'update:modelValue': [value: boolean];
}>();
+const appContextStore = useAppContextStore();
+
const dialogVisible = computed({
get: () => props.modelValue,
set: (val) => emit('update:modelValue', val),
@@ -129,6 +132,7 @@ async function handleConfirmImport() {
try {
const payload: AgentImportInput = {
...importData.value,
+ application_id: appContextStore.currentApp?.id,
code: checkResult.value?.code_exists
? newCode.value.trim()
: importData.value.code,
diff --git a/web/apps/web-ele/src/views/ai-platform/knowledge/detail/index.vue b/web/apps/web-ele/src/views/ai-platform/knowledge/detail/index.vue
index 72e6a4f..3e2980c 100644
--- a/web/apps/web-ele/src/views/ai-platform/knowledge/detail/index.vue
+++ b/web/apps/web-ele/src/views/ai-platform/knowledge/detail/index.vue
@@ -97,9 +97,11 @@ import { ZqDialog } from '#/components/zq-dialog';
import FileSelector from '#/components/zq-form/file-selector/file-selector.vue';
import { ZqTabs } from '#/components/zq-tabs/index';
import { getFileUrl } from '#/composables/useFileUrl';
+import { useAppContextStore } from '#/store/app-context';
const route = useRoute();
const router = useRouter();
+const appContextStore = useAppContextStore();
const kbId = computed(() => route.params.id as string);
const activeTab = ref('documents');
@@ -865,7 +867,7 @@ async function handleSaveSettings() {
}
function handleBack() {
- router.push('/ai-platform/knowledge-base');
+ router.push(appContextStore.getContextPath('/ai-platform/knowledge-base'));
}
// Tab 切换时加载数据
diff --git a/web/apps/web-ele/src/views/ai-platform/knowledge/index.vue b/web/apps/web-ele/src/views/ai-platform/knowledge/index.vue
index 389f3c3..7388863 100644
--- a/web/apps/web-ele/src/views/ai-platform/knowledge/index.vue
+++ b/web/apps/web-ele/src/views/ai-platform/knowledge/index.vue
@@ -5,7 +5,7 @@ import type {
ModelListItem,
} 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';
@@ -35,6 +35,7 @@ import {
ElOption,
ElPagination,
ElSelect,
+ ElSwitch,
ElTag,
ElTooltip,
} from 'element-plus';
@@ -47,10 +48,13 @@ import {
updateKnowledgeBaseApi,
} from '#/api/ai-platform/ai-platform';
import { ZqDialog } from '#/components/zq-dialog';
+import { useAppContextStore } from '#/store/app-context';
defineOptions({ name: 'KnowledgeBase' });
const router = useRouter();
+const appContextStore = useAppContextStore();
+const isMainApp = computed(() => appContextStore.isMainApp);
// 表单
const createForm = reactive({
@@ -104,6 +108,7 @@ async function fetchList() {
page: pagination.current,
pageSize: pagination.pageSize,
name: searchKeyword.value || undefined,
+ applicationId: appContextStore.currentApp?.id,
});
kbList.value = res.items;
pagination.total = res.total;
@@ -176,6 +181,7 @@ async function handleConfirm() {
ElMessage.success($t('ai-platform.knowledge.saveSuccess'));
} else {
const res = await createKnowledgeBaseApi({
+ application_id: appContextStore.currentApp?.id,
is_global: createForm.is_global,
name: createForm.name,
code: createForm.code,
@@ -191,7 +197,11 @@ async function handleConfirm() {
indexing_technique: createForm.indexing_technique,
});
ElMessage.success($t('ai-platform.knowledge.createSuccess'));
- router.push(`/ai-platform/knowledge-base/detail/${res.id}`);
+ router.push(
+ appContextStore.getContextPath(
+ `/ai-platform/knowledge-base/detail/${res.id}`,
+ ),
+ );
}
dialogVisible.value = false;
fetchList();
@@ -204,7 +214,11 @@ async function handleConfirm() {
}
function handleDetail(item: KnowledgeBaseListItem) {
- router.push(`/ai-platform/knowledge-base/detail/${item.id}`);
+ router.push(
+ appContextStore.getContextPath(
+ `/ai-platform/knowledge-base/detail/${item.id}`,
+ ),
+ );
}
async function handleDelete(item: KnowledgeBaseListItem) {
@@ -654,6 +668,22 @@ onMounted(() => {
+
+
+
+ {{ $t('ai-platform.knowledge.globalVisible') }}
+
+
+
+
+
+
+
diff --git a/web/apps/web-ele/src/views/ai-platform/workflow-runs/data.ts b/web/apps/web-ele/src/views/ai-platform/workflow-runs/data.ts
index 113a09b..2117547 100644
--- a/web/apps/web-ele/src/views/ai-platform/workflow-runs/data.ts
+++ b/web/apps/web-ele/src/views/ai-platform/workflow-runs/data.ts
@@ -5,6 +5,7 @@ import type { VbenFormSchema } from '#/adapter/form';
import { $t } from '@vben/locales';
import { getWorkflowListApi } from '#/api/ai-platform/ai-platform';
+import { useAppContextStore } from '#/store/app-context';
type TagType = 'danger' | 'info' | 'primary' | 'success' | 'warning';
@@ -51,6 +52,8 @@ export function formatTime(value?: string) {
}
export function useSearchFormSchema(): VbenFormSchema[] {
+ const appContextStore = useAppContextStore();
+
return [
{
component: 'ApiSelect',
@@ -61,6 +64,7 @@ export function useSearchFormSchema(): VbenFormSchema[] {
const res = await getWorkflowListApi({
page: 1,
pageSize: 200,
+ applicationId: appContextStore.currentApp?.id,
});
return (res.items || []).map((item) => ({
label: item.name,
diff --git a/web/apps/web-ele/src/views/ai-platform/workflow-runs/index.vue b/web/apps/web-ele/src/views/ai-platform/workflow-runs/index.vue
index 91bfd64..e5e85e6 100644
--- a/web/apps/web-ele/src/views/ai-platform/workflow-runs/index.vue
+++ b/web/apps/web-ele/src/views/ai-platform/workflow-runs/index.vue
@@ -11,6 +11,7 @@ import { ElButton, ElTag } from 'element-plus';
import { getAllWorkflowRunsApi } from '#/api/ai-platform/ai-platform';
import { useZqTable } from '#/components/zq-table';
+import { useAppContextStore } from '#/store/app-context';
import RunStatusTag from './components/RunStatusTag.vue';
import {
@@ -28,6 +29,7 @@ defineOptions({ name: 'WorkflowRunHistory' });
const detailRef = ref>();
const triggerOptions = getTriggerOptions();
+const appContextStore = useAppContextStore();
const fetchRunList = async (params: any) => {
const res = await getAllWorkflowRunsApi({
@@ -36,6 +38,7 @@ const fetchRunList = async (params: any) => {
workflowId: params.form?.workflowId || undefined,
status: params.form?.status || undefined,
triggerType: params.form?.triggerType || undefined,
+ applicationId: appContextStore.currentApp?.id,
});
return {
items: res.items,
diff --git a/web/apps/web-ele/src/views/ai-platform/workflow-runs/modules/detail-dialog.vue b/web/apps/web-ele/src/views/ai-platform/workflow-runs/modules/detail-dialog.vue
index 1c0964b..641cc9a 100644
--- a/web/apps/web-ele/src/views/ai-platform/workflow-runs/modules/detail-dialog.vue
+++ b/web/apps/web-ele/src/views/ai-platform/workflow-runs/modules/detail-dialog.vue
@@ -14,6 +14,7 @@ import { ElAlert, ElButton, ElTag } from 'element-plus';
import { getWorkflowDetailApi, getWorkflowRunDetailApi } from '#/api/ai-platform/ai-platform';
import { ZqDesc, ZqDescItem } from '#/components/zq-desc';
import { ZqDialog } from '#/components/zq-dialog';
+import { useAppContextStore } from '#/store/app-context';
import { definitionToFlowElements } from '../../workflow/shared/loadDefinition';
import { applyRunReplay } from '../../workflow/shared/useRunReplay';
@@ -28,6 +29,7 @@ import {
} from '../data';
const router = useRouter();
+const appContextStore = useAppContextStore();
const triggerOptions = getTriggerOptions();
const visible = ref(false);
@@ -92,7 +94,11 @@ function handleOpen() {
function openEditor() {
if (!run.value?.workflow_id) return;
visible.value = false;
- router.push(`/ai-platform/workflow/editor/${run.value.workflow_id}`);
+ router.push(
+ appContextStore.getContextPath(
+ `/ai-platform/workflow/editor/${run.value.workflow_id}`,
+ ),
+ );
}
function triggerLabel(value?: string) {