Remove app context from AI admin flows

This commit is contained in:
2026-06-11 08:40:11 +08:00
parent 6867e4f708
commit 86680ad7f8
22 changed files with 55 additions and 221 deletions
@@ -1,26 +1,5 @@
import { requestClient } from '#/api/request'; import { requestClient } from '#/api/request';
import { streamRequestClient } from '#/api/stream-request'; import { streamRequestClient } from '#/api/stream-request';
import { useAppContextStore } from '#/store/app-context';
/**
* Inject current application context into AI requests.
*/
function injectSystemVariables(
inputs: Record<string, any>,
): Record<string, any> {
const appContextStore = useAppContextStore();
const result = { ...inputs };
if (appContextStore.currentApp?.id && !result.application_id) {
result.application_id = appContextStore.currentApp.id;
}
if (appContextStore.currentApp?.code && !result.application_code) {
result.application_code = appContextStore.currentApp.code;
}
return result;
}
/** /**
* AI 平台 API * AI 平台 API
@@ -953,12 +932,9 @@ export function runWorkflowStreamApi(
onComplete?: () => void, onComplete?: () => void,
useDraft: boolean = false, useDraft: boolean = false,
): () => void { ): () => void {
// Inject current application context.
const finalInputs = injectSystemVariables(inputs);
return streamRequestClient<WorkflowStreamEvent>( return streamRequestClient<WorkflowStreamEvent>(
`${BASE_URL}/workflow/${id}/run/stream`, `${BASE_URL}/workflow/${id}/run/stream`,
{ inputs: finalInputs, use_draft: useDraft }, { inputs, use_draft: useDraft },
{ {
onData: onEvent, onData: onEvent,
onError: (error) => { onError: (error) => {
@@ -1482,12 +1458,9 @@ export function sendAgentMessageStream(
onError?: (error: Error) => void, onError?: (error: Error) => void,
onComplete?: () => void, onComplete?: () => void,
) { ) {
// Inject current application context.
const finalData = injectSystemVariables(data);
return streamRequestClient<AgentChatEvent>( return streamRequestClient<AgentChatEvent>(
`${BASE_URL}/agent/${agentId}/chat`, `${BASE_URL}/agent/${agentId}/chat`,
finalData, data,
{ {
onData: onEvent, onData: onEvent,
onError: (error) => { onError: (error) => {
@@ -61,11 +61,11 @@
"namePlaceholder": "请输入智能体名称", "namePlaceholder": "请输入智能体名称",
"code": "编码", "code": "编码",
"codePlaceholder": "请输入唯一编码", "codePlaceholder": "请输入唯一编码",
"appCode": "应用编码", "appCode": "智能体编码",
"mode": "模式", "mode": "模式",
"description": "描述", "description": "描述",
"descriptionPlaceholder": "请输入描述", "descriptionPlaceholder": "请输入描述",
"globalVisible": "子应用可见" "globalVisible": "共享可用"
}, },
"importExport": { "importExport": {
"export": "导出", "export": "导出",
@@ -87,7 +87,7 @@
"agentInfo": "智能体信息", "agentInfo": "智能体信息",
"modelName": "模型", "modelName": "模型",
"workflowCode": "关联工作流", "workflowCode": "关联工作流",
"appTip": "导入的智能体将归属到当前应用,状态为草稿", "appTip": "导入的智能体状态为草稿,可在编辑器中确认模型、工具和知识库配置",
"refTip": "模型、工作流、知识库按编码/名称匹配;目标环境缺失时导入后需在编辑器中重新配置" "refTip": "模型、工作流、知识库按编码/名称匹配;目标环境缺失时导入后需在编辑器中重新配置"
}, },
"basicInfo": "基本信息", "basicInfo": "基本信息",
@@ -356,7 +356,7 @@
"status": "状态", "status": "状态",
"active": "启用", "active": "启用",
"disabled": "停用", "disabled": "停用",
"globalVisible": "子应用可见", "globalVisible": "共享可用",
"documents": "文档", "documents": "文档",
"segments": "分段", "segments": "分段",
"tokens": "Tokens", "tokens": "Tokens",
@@ -606,7 +606,7 @@
"type": "类型", "type": "类型",
"description": "描述", "description": "描述",
"descriptionPlaceholder": "请输入描述", "descriptionPlaceholder": "请输入描述",
"globalVisible": "子应用可见" "globalVisible": "共享可用"
}, },
"status": { "status": {
"draft": "草稿", "draft": "草稿",
@@ -646,7 +646,7 @@
"confirmImport": "确认导入", "confirmImport": "确认导入",
"reselect": "重新选择", "reselect": "重新选择",
"workflowInfo": "工作流信息", "workflowInfo": "工作流信息",
"appTip": "导入的工作流将归属到当前应用,状态为草稿", "appTip": "导入的工作流状态为草稿,可在编辑器中确认节点配置后发布",
"subflowTip": "子流程节点按编码匹配;若目标环境无对应子流程,导入后需在编辑器中重新选择" "subflowTip": "子流程节点按编码匹配;若目标环境无对应子流程,导入后需在编辑器中重新选择"
}, },
"nodeLabel": "节点名称", "nodeLabel": "节点名称",
@@ -1103,9 +1103,8 @@
"rawResponse": "原始响应", "rawResponse": "原始响应",
"cortexLlmResponse": "Cortex LLM 响应", "cortexLlmResponse": "Cortex LLM 响应",
"userInput": "用户输入", "userInput": "用户输入",
"appId": "子应用ID", "sessionId": "会话 ID",
"appCode": "子应用编码", "agentId": "智能体 ID",
"formCode": "表单编码",
"renderResult": "渲染结果", "renderResult": "渲染结果",
"generatedSqlStatement": "生成的 SQL 语句", "generatedSqlStatement": "生成的 SQL 语句",
"sqlThought": "SQL 生成思路", "sqlThought": "SQL 生成思路",
@@ -1309,9 +1308,8 @@
}, },
"start": { "start": {
"userInputDesc": "用户在对话框中输入的内容,自动传入此变量", "userInputDesc": "用户在对话框中输入的内容,自动传入此变量",
"appIdDesc": "子应用下自动注入实际ID,主应用模式下为main", "sessionIdDesc": "当前对话会话 ID,用于多轮记忆和执行追踪",
"appCodeDesc": "子应用下自动注入应用编码,主应用模式下为空", "agentIdDesc": "当前调用智能体 ID,用于智能体协作和审计"
"formCodeDesc": "从表单列表调用时自动注入表单编码,其他情况下为空"
}, },
"choice": { "choice": {
"label": "选项节点", "label": "选项节点",
-4
View File
@@ -27,10 +27,6 @@ const lightMenuNames = new Set([
'KnowledgeBase', 'KnowledgeBase',
'Message', 'Message',
'MessageList', 'MessageList',
'SubAppAIAgentEditor',
'SubAppAIKnowledgeDetail',
'SubAppAIWorkflowEditor',
'SubAppAIWorkflowRuns',
'SystemConfigManager', 'SystemConfigManager',
'SystemManagement', 'SystemManagement',
'SystemMenu', 'SystemMenu',
@@ -7,6 +7,15 @@ const routes: RouteRecordRaw[] = [
path: '/ai-platform/knowledge', path: '/ai-platform/knowledge',
redirect: '/ai-platform/knowledge-base', redirect: '/ai-platform/knowledge-base',
}, },
{
meta: {
hideInMenu: true,
title: '智能体对话',
},
name: 'AgentChat',
path: '/agent-chat/:code',
component: () => import('#/views/_core/agent-chat/index.vue'),
},
{ {
meta: { meta: {
hideInMenu: true, hideInMenu: true,
@@ -22,19 +31,6 @@ const routes: RouteRecordRaw[] = [
path: '/ai-platform/knowledge/detail/:id', path: '/ai-platform/knowledge/detail/:id',
redirect: (to) => `/ai-platform/knowledge-base/detail/${to.params.id}`, redirect: (to) => `/ai-platform/knowledge-base/detail/${to.params.id}`,
}, },
{
meta: { hideInMenu: true },
name: 'SubAppAIKnowledgeLegacyRedirect',
path: '/app/:appCode/ai-platform/knowledge',
redirect: (to) => `/app/${to.params.appCode}/ai-platform/knowledge-base`,
},
{
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: { meta: {
hideInMenu: true, hideInMenu: true,
@@ -44,16 +40,7 @@ const routes: RouteRecordRaw[] = [
path: '/ai-platform/workflow-runs', path: '/ai-platform/workflow-runs',
component: () => import('#/views/ai-platform/workflow-runs/index.vue'), 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: { meta: {
hideInMenu: true, hideInMenu: true,
@@ -64,18 +51,7 @@ const routes: RouteRecordRaw[] = [
path: '/ai-platform/workflow/editor/:id', path: '/ai-platform/workflow/editor/:id',
component: () => import('#/views/ai-platform/workflow/editor/index.vue'), 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: { meta: {
hideInMenu: true, hideInMenu: true,
@@ -86,18 +62,7 @@ const routes: RouteRecordRaw[] = [
path: '/ai-platform/agent/editor/:id', path: '/ai-platform/agent/editor/:id',
component: () => import('#/views/ai-platform/agent/editor/index.vue'), 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: { meta: {
hideInMenu: true, hideInMenu: true,
@@ -107,16 +72,6 @@ const routes: RouteRecordRaw[] = [
path: '/ai-platform/knowledge-base/detail/:id', path: '/ai-platform/knowledge-base/detail/:id',
component: () => import('#/views/ai-platform/knowledge/detail/index.vue'), 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; export default routes;
@@ -248,7 +248,7 @@ async function doSendMessage(message: string, addUserMessage: boolean = true) {
scrollToBottom(); scrollToBottom();
// 发送流式请求 // 发送流式请求
// 系统变量application_id 等)由 API 层自动注入 // 系统变量由 API 层自动注入
cancelStream = sendAgentMessageStream( cancelStream = sendAgentMessageStream(
props.agentId, props.agentId,
{ {
@@ -19,7 +19,6 @@ import {
import { publishAgentToMenuApi } from '#/api/ai-platform/ai-platform'; import { publishAgentToMenuApi } from '#/api/ai-platform/ai-platform';
import { ZqIconPicker } from '#/components/zq-form/zq-icon-picker'; import { ZqIconPicker } from '#/components/zq-form/zq-icon-picker';
import { ZqMenuSelector } from '#/components/zq-form/zq-menu-selector'; import { ZqMenuSelector } from '#/components/zq-form/zq-menu-selector';
import { useAppContextStore } from '#/store/app-context';
interface Props { interface Props {
modelValue: boolean; modelValue: boolean;
@@ -35,8 +34,6 @@ const emit = defineEmits<{
'update:modelValue': [value: boolean]; 'update:modelValue': [value: boolean];
}>(); }>();
const appContextStore = useAppContextStore();
const dialogVisible = computed({ const dialogVisible = computed({
get: () => props.modelValue, get: () => props.modelValue,
set: (val) => emit('update:modelValue', val), set: (val) => emit('update:modelValue', val),
@@ -133,7 +130,6 @@ async function handlePublish() {
:placeholder=" :placeholder="
$t('ai-platform.agent.publishDialog.parentMenuPlaceholder') $t('ai-platform.agent.publishDialog.parentMenuPlaceholder')
" "
:application-id="appContextStore.currentApp?.id"
@change="handleMenuChange" @change="handleMenuChange"
/> />
</ElFormItem> </ElFormItem>
@@ -49,14 +49,11 @@ import {
publishAgentApi, publishAgentApi,
updateAgentApi, updateAgentApi,
} from '#/api/ai-platform/ai-platform'; } from '#/api/ai-platform/ai-platform';
import { useAppContextStore } from '#/store/app-context';
const AiChatPanel = defineAsyncComponent(() => const AiChatPanel = defineAsyncComponent(() =>
import('#/components/ai-chat-panel/AiChatPanel.vue'), import('#/components/ai-chat-panel/AiChatPanel.vue'),
); );
const appContextStore = useAppContextStore();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const agentId = route.params.id as string; const agentId = route.params.id as string;
@@ -220,7 +217,7 @@ async function handlePublish() {
// 返回 // 返回
function handleBack() { function handleBack() {
router.push(appContextStore.getContextPath('/ai-platform/agent')); router.push('/ai-platform/agent');
} }
// 添加性格特点 // 添加性格特点
@@ -52,7 +52,6 @@ import {
publishAgentApi, publishAgentApi,
unpublishAgentMenuApi, unpublishAgentMenuApi,
} from '#/api/ai-platform/ai-platform'; } from '#/api/ai-platform/ai-platform';
import { useAppContextStore } from '#/store/app-context';
import PublishToMenuDialog from './components/PublishToMenuDialog.vue'; import PublishToMenuDialog from './components/PublishToMenuDialog.vue';
import ImportDialog from './modules/import-dialog.vue'; import ImportDialog from './modules/import-dialog.vue';
@@ -60,7 +59,6 @@ import ImportDialog from './modules/import-dialog.vue';
defineOptions({ name: 'AgentList' }); defineOptions({ name: 'AgentList' });
const router = useRouter(); const router = useRouter();
const appContextStore = useAppContextStore();
// 搜索关键词 // 搜索关键词
const searchKeyword = ref(''); const searchKeyword = ref('');
@@ -102,7 +100,6 @@ async function fetchList() {
page: pagination.current, page: pagination.current,
pageSize: pagination.pageSize, pageSize: pagination.pageSize,
name: searchKeyword.value || undefined, name: searchKeyword.value || undefined,
applicationId: appContextStore.currentApp?.id,
}); });
agentList.value = res.items; agentList.value = res.items;
pagination.total = res.total; pagination.total = res.total;
@@ -159,14 +156,10 @@ async function handleCreate() {
try { try {
const agent = await createAgentApi({ const agent = await createAgentApi({
...createForm, ...createForm,
application_id: appContextStore.currentApp?.id,
}); });
ElMessage.success($t('ai-platform.agent.createSuccess')); ElMessage.success($t('ai-platform.agent.createSuccess'));
createDialogVisible.value = false; createDialogVisible.value = false;
// 跳转到编辑页(支持子应用模式) router.push(`/ai-platform/agent/editor/${agent.id}`);
router.push(
appContextStore.getContextPath(`/ai-platform/agent/editor/${agent.id}`),
);
} catch (error: any) { } catch (error: any) {
ElMessage.error(error.message || $t('ai-platform.agent.createFailed')); ElMessage.error(error.message || $t('ai-platform.agent.createFailed'));
} finally { } finally {
@@ -176,16 +169,12 @@ async function handleCreate() {
// 编辑智能体 // 编辑智能体
function handleEdit(agent: AgentListItem) { function handleEdit(agent: AgentListItem) {
router.push( router.push(`/ai-platform/agent/editor/${agent.id}`);
appContextStore.getContextPath(`/ai-platform/agent/editor/${agent.id}`),
);
} }
// 对话 // 对话
function handleChat(agent: AgentListItem) { function handleChat(agent: AgentListItem) {
router.push( router.push(`/agent-chat/${agent.code}`);
appContextStore.getContextPath(`/ai-platform/agent/chat/${agent.id}`),
);
} }
// 发布 // 发布
@@ -24,7 +24,6 @@ import {
importAgentConfigApi, importAgentConfigApi,
} from '#/api/ai-platform/ai-platform'; } from '#/api/ai-platform/ai-platform';
import { ZqDialog } from '#/components/zq-dialog'; import { ZqDialog } from '#/components/zq-dialog';
import { useAppContextStore } from '#/store/app-context';
interface Props { interface Props {
modelValue: boolean; modelValue: boolean;
@@ -37,8 +36,6 @@ const emit = defineEmits<{
'update:modelValue': [value: boolean]; 'update:modelValue': [value: boolean];
}>(); }>();
const appContextStore = useAppContextStore();
const dialogVisible = computed({ const dialogVisible = computed({
get: () => props.modelValue, get: () => props.modelValue,
set: (val) => emit('update:modelValue', val), set: (val) => emit('update:modelValue', val),
@@ -132,7 +129,6 @@ async function handleConfirmImport() {
try { try {
const payload: AgentImportInput = { const payload: AgentImportInput = {
...importData.value, ...importData.value,
application_id: appContextStore.currentApp?.id,
code: checkResult.value?.code_exists code: checkResult.value?.code_exists
? newCode.value.trim() ? newCode.value.trim()
: importData.value.code, : importData.value.code,
@@ -97,11 +97,9 @@ import { ZqDialog } from '#/components/zq-dialog';
import FileSelector from '#/components/zq-form/file-selector/file-selector.vue'; import FileSelector from '#/components/zq-form/file-selector/file-selector.vue';
import { ZqTabs } from '#/components/zq-tabs/index'; import { ZqTabs } from '#/components/zq-tabs/index';
import { getFileUrl } from '#/composables/useFileUrl'; import { getFileUrl } from '#/composables/useFileUrl';
import { useAppContextStore } from '#/store/app-context';
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const appContextStore = useAppContextStore();
const kbId = computed(() => route.params.id as string); const kbId = computed(() => route.params.id as string);
const activeTab = ref('documents'); const activeTab = ref('documents');
@@ -867,7 +865,7 @@ async function handleSaveSettings() {
} }
function handleBack() { function handleBack() {
router.push(appContextStore.getContextPath('/ai-platform/knowledge-base')); router.push('/ai-platform/knowledge-base');
} }
// Tab 切换时加载数据 // Tab 切换时加载数据
@@ -47,12 +47,10 @@ import {
updateKnowledgeBaseApi, updateKnowledgeBaseApi,
} from '#/api/ai-platform/ai-platform'; } from '#/api/ai-platform/ai-platform';
import { ZqDialog } from '#/components/zq-dialog'; import { ZqDialog } from '#/components/zq-dialog';
import { useAppContextStore } from '#/store/app-context';
defineOptions({ name: 'KnowledgeBase' }); defineOptions({ name: 'KnowledgeBase' });
const router = useRouter(); const router = useRouter();
const appContextStore = useAppContextStore();
// 表单 // 表单
const createForm = reactive<KnowledgeBaseCreateInput & { id?: string }>({ const createForm = reactive<KnowledgeBaseCreateInput & { id?: string }>({
@@ -106,7 +104,6 @@ async function fetchList() {
page: pagination.current, page: pagination.current,
pageSize: pagination.pageSize, pageSize: pagination.pageSize,
name: searchKeyword.value || undefined, name: searchKeyword.value || undefined,
applicationId: appContextStore.currentApp?.id,
}); });
kbList.value = res.items; kbList.value = res.items;
pagination.total = res.total; pagination.total = res.total;
@@ -179,7 +176,6 @@ async function handleConfirm() {
ElMessage.success($t('ai-platform.knowledge.saveSuccess')); ElMessage.success($t('ai-platform.knowledge.saveSuccess'));
} else { } else {
const res = await createKnowledgeBaseApi({ const res = await createKnowledgeBaseApi({
application_id: appContextStore.currentApp?.id,
is_global: createForm.is_global, is_global: createForm.is_global,
name: createForm.name, name: createForm.name,
code: createForm.code, code: createForm.code,
@@ -195,12 +191,7 @@ async function handleConfirm() {
indexing_technique: createForm.indexing_technique, indexing_technique: createForm.indexing_technique,
}); });
ElMessage.success($t('ai-platform.knowledge.createSuccess')); 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; dialogVisible.value = false;
fetchList(); fetchList();
@@ -213,11 +204,7 @@ async function handleConfirm() {
} }
function handleDetail(item: KnowledgeBaseListItem) { function handleDetail(item: KnowledgeBaseListItem) {
router.push( router.push(`/ai-platform/knowledge-base/detail/${item.id}`);
appContextStore.getContextPath(
`/ai-platform/knowledge-base/detail/${item.id}`,
),
);
} }
async function handleDelete(item: KnowledgeBaseListItem) { async function handleDelete(item: KnowledgeBaseListItem) {
@@ -5,7 +5,6 @@ import type { VbenFormSchema } from '#/adapter/form';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { getWorkflowListApi } from '#/api/ai-platform/ai-platform'; import { getWorkflowListApi } from '#/api/ai-platform/ai-platform';
import { useAppContextStore } from '#/store/app-context';
type TagType = 'danger' | 'info' | 'primary' | 'success' | 'warning'; type TagType = 'danger' | 'info' | 'primary' | 'success' | 'warning';
@@ -52,8 +51,6 @@ export function formatTime(value?: string) {
} }
export function useSearchFormSchema(): VbenFormSchema[] { export function useSearchFormSchema(): VbenFormSchema[] {
const appContextStore = useAppContextStore();
return [ return [
{ {
component: 'ApiSelect', component: 'ApiSelect',
@@ -64,7 +61,6 @@ export function useSearchFormSchema(): VbenFormSchema[] {
const res = await getWorkflowListApi({ const res = await getWorkflowListApi({
page: 1, page: 1,
pageSize: 200, pageSize: 200,
applicationId: appContextStore.currentApp?.id,
}); });
return (res.items || []).map((item) => ({ return (res.items || []).map((item) => ({
label: item.name, label: item.name,
@@ -11,7 +11,6 @@ import { ElButton, ElTag } from 'element-plus';
import { getAllWorkflowRunsApi } from '#/api/ai-platform/ai-platform'; import { getAllWorkflowRunsApi } from '#/api/ai-platform/ai-platform';
import { useZqTable } from '#/components/zq-table'; import { useZqTable } from '#/components/zq-table';
import { useAppContextStore } from '#/store/app-context';
import RunStatusTag from './components/RunStatusTag.vue'; import RunStatusTag from './components/RunStatusTag.vue';
import { import {
@@ -27,7 +26,6 @@ import DetailDialog from './modules/detail-dialog.vue';
defineOptions({ name: 'WorkflowRunHistory' }); defineOptions({ name: 'WorkflowRunHistory' });
const appContextStore = useAppContextStore();
const detailRef = ref<InstanceType<typeof DetailDialog>>(); const detailRef = ref<InstanceType<typeof DetailDialog>>();
const triggerOptions = getTriggerOptions(); const triggerOptions = getTriggerOptions();
@@ -38,7 +36,6 @@ const fetchRunList = async (params: any) => {
workflowId: params.form?.workflowId || undefined, workflowId: params.form?.workflowId || undefined,
status: params.form?.status || undefined, status: params.form?.status || undefined,
triggerType: params.form?.triggerType || undefined, triggerType: params.form?.triggerType || undefined,
applicationId: appContextStore.currentApp?.id,
}); });
return { return {
items: res.items, items: res.items,
@@ -14,7 +14,6 @@ import { ElAlert, ElButton, ElTag } from 'element-plus';
import { getWorkflowDetailApi, getWorkflowRunDetailApi } from '#/api/ai-platform/ai-platform'; import { getWorkflowDetailApi, getWorkflowRunDetailApi } from '#/api/ai-platform/ai-platform';
import { ZqDesc, ZqDescItem } from '#/components/zq-desc'; import { ZqDesc, ZqDescItem } from '#/components/zq-desc';
import { ZqDialog } from '#/components/zq-dialog'; import { ZqDialog } from '#/components/zq-dialog';
import { useAppContextStore } from '#/store/app-context';
import { definitionToFlowElements } from '../../workflow/shared/loadDefinition'; import { definitionToFlowElements } from '../../workflow/shared/loadDefinition';
import { applyRunReplay } from '../../workflow/shared/useRunReplay'; import { applyRunReplay } from '../../workflow/shared/useRunReplay';
@@ -29,7 +28,6 @@ import {
} from '../data'; } from '../data';
const router = useRouter(); const router = useRouter();
const appContextStore = useAppContextStore();
const triggerOptions = getTriggerOptions(); const triggerOptions = getTriggerOptions();
const visible = ref(false); const visible = ref(false);
@@ -94,11 +92,7 @@ function handleOpen() {
function openEditor() { function openEditor() {
if (!run.value?.workflow_id) return; if (!run.value?.workflow_id) return;
visible.value = false; visible.value = false;
router.push( router.push(`/ai-platform/workflow/editor/${run.value.workflow_id}`);
appContextStore.getContextPath(
`/ai-platform/workflow/editor/${run.value.workflow_id}`,
),
);
} }
function triggerLabel(value?: string) { function triggerLabel(value?: string) {
@@ -213,7 +213,7 @@ const runWorkflow = (userMessage: string, inputs: Record<string, any>) => {
running.value = true; running.value = true;
// 流式运行(编辑器调试模式,使用草稿版本) // 流式运行(编辑器调试模式,使用草稿版本)
// 系统变量application_id 等)由 API 层自动注入 // 系统变量由 API 层自动注入
cancelStream = runWorkflowStreamApi( cancelStream = runWorkflowStreamApi(
props.workflowId, props.workflowId,
inputs, inputs,
@@ -162,7 +162,7 @@ const handleRun = () => {
startTimer(); startTimer();
// 编辑器调试模式,使用草稿版本 // 编辑器调试模式,使用草稿版本
// 系统变量application_id 等)由 API 层自动注入 // 系统变量由 API 层自动注入
cancelStream = runWorkflowStreamApi( cancelStream = runWorkflowStreamApi(
props.workflowId, props.workflowId,
inputs.value, inputs.value,
@@ -382,19 +382,16 @@ const availableNodes = computed(() => {
isSystem: true, isSystem: true,
}, },
{ {
key: 'application_id', key: 'session_id',
label: $t('ai-platform.workflow.editor.variableSelector.appId'),
isSystem: true,
},
{
key: 'application_code',
label: $t('ai-platform.workflow.editor.variableSelector.appCode'),
isSystem: true,
},
{
key: 'form_code',
label: $t( label: $t(
'ai-platform.workflow.editor.variableSelector.formCode', 'ai-platform.workflow.editor.variableSelector.sessionId',
),
isSystem: true,
},
{
key: 'agent_id',
label: $t(
'ai-platform.workflow.editor.variableSelector.agentId',
), ),
isSystem: true, isSystem: true,
}, },
@@ -58,7 +58,6 @@ import {
runWorkflowStreamApi, runWorkflowStreamApi,
updateWorkflowApi, updateWorkflowApi,
} from '#/api/ai-platform/ai-platform'; } from '#/api/ai-platform/ai-platform';
import { useAppContextStore } from '#/store/app-context';
import { useWorkflowEditorStore } from '#/store/workflow-editor'; import { useWorkflowEditorStore } from '#/store/workflow-editor';
import RunDialog from './components/RunDialog.vue'; import RunDialog from './components/RunDialog.vue';
@@ -79,8 +78,6 @@ const AiChatPanel = defineAsyncComponent(
() => import('#/components/ai-chat-panel/AiChatPanel.vue'), () => import('#/components/ai-chat-panel/AiChatPanel.vue'),
); );
const appContextStore = useAppContextStore();
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const workflowId = route.params.id as string; const workflowId = route.params.id as string;
@@ -1834,7 +1831,7 @@ const handleNodeComplete = (event: {
}; };
const handleBack = () => { const handleBack = () => {
router.push(appContextStore.getContextPath('/ai-platform/workflow')); router.push('/ai-platform/workflow');
}; };
// 键盘快捷键 // 键盘快捷键
@@ -50,42 +50,29 @@ const handleDelete = (index: number) => {
</div> </div>
</div> </div>
<!-- 默认的 application_id 变量不可删除 --> <!-- 默认的 session_id 变量不可删除 -->
<div class="border-primary/30 bg-primary/5 rounded border p-3"> <div class="border-primary/30 bg-primary/5 rounded border p-3">
<div class="mb-2 flex items-center justify-between"> <div class="mb-2 flex items-center justify-between">
<span class="text-primary text-sm font-medium">application_id</span> <span class="text-primary text-sm font-medium">session_id</span>
<span class="text-muted-foreground text-xs">{{ <span class="text-muted-foreground text-xs">{{
$t('ai-platform.workflow.panels.common.sysVar') $t('ai-platform.workflow.panels.common.sysVar')
}}</span> }}</span>
</div> </div>
<div class="text-muted-foreground text-xs"> <div class="text-muted-foreground text-xs">
{{ $t('ai-platform.workflow.panels.start.appIdDesc') }} {{ $t('ai-platform.workflow.panels.start.sessionIdDesc') }}
</div> </div>
</div> </div>
<!-- 默认的 application_code 变量不可删除 --> <!-- 默认的 agent_id 变量不可删除 -->
<div class="border-primary/30 bg-primary/5 rounded border p-3"> <div class="border-primary/30 bg-primary/5 rounded border p-3">
<div class="mb-2 flex items-center justify-between"> <div class="mb-2 flex items-center justify-between">
<span class="text-primary text-sm font-medium">application_code</span> <span class="text-primary text-sm font-medium">agent_id</span>
<span class="text-muted-foreground text-xs">{{ <span class="text-muted-foreground text-xs">{{
$t('ai-platform.workflow.panels.common.sysVar') $t('ai-platform.workflow.panels.common.sysVar')
}}</span> }}</span>
</div> </div>
<div class="text-muted-foreground text-xs"> <div class="text-muted-foreground text-xs">
{{ $t('ai-platform.workflow.panels.start.appCodeDesc') }} {{ $t('ai-platform.workflow.panels.start.agentIdDesc') }}
</div>
</div>
<!-- 默认的 form_code 变量不可删除 -->
<div class="border-primary/30 bg-primary/5 rounded border p-3">
<div class="mb-2 flex items-center justify-between">
<span class="text-primary text-sm font-medium">form_code</span>
<span class="text-muted-foreground text-xs">{{
$t('ai-platform.workflow.panels.common.sysVar')
}}</span>
</div>
<div class="text-muted-foreground text-xs">
{{ $t('ai-platform.workflow.panels.start.formCodeDesc') }}
</div> </div>
</div> </div>
@@ -51,13 +51,11 @@ import {
updateWorkflowApi, updateWorkflowApi,
} from '#/api/ai-platform/ai-platform'; } from '#/api/ai-platform/ai-platform';
import { ZqDialog } from '#/components/zq-dialog'; import { ZqDialog } from '#/components/zq-dialog';
import { useAppContextStore } from '#/store/app-context';
import RunDialog from '../workflow/editor/components/RunDialog.vue'; import RunDialog from '../workflow/editor/components/RunDialog.vue';
import ImportDialog from './modules/import-dialog.vue'; import ImportDialog from './modules/import-dialog.vue';
const router = useRouter(); const router = useRouter();
const appContextStore = useAppContextStore();
// //
const workflowTypeOptions = computed(() => [ const workflowTypeOptions = computed(() => [
@@ -85,7 +83,6 @@ const createForm = reactive({
is_global: false, is_global: false,
}); });
//
const formRef = ref(); const formRef = ref();
const isEditMode = ref(false); const isEditMode = ref(false);
const formLoading = ref(false); const formLoading = ref(false);
@@ -117,7 +114,6 @@ async function handleConfirm() {
} else { } else {
// //
const res = await createWorkflowApi({ const res = await createWorkflowApi({
application_id: appContextStore.currentApp?.id,
is_global: createForm.is_global, is_global: createForm.is_global,
name: createForm.name, name: createForm.name,
code: createForm.code, code: createForm.code,
@@ -127,12 +123,7 @@ async function handleConfirm() {
ElMessage.success($t('ai-platform.workflow.createSuccess')); ElMessage.success($t('ai-platform.workflow.createSuccess'));
dialogVisible.value = false; dialogVisible.value = false;
fetchList(); fetchList();
// router.push(`/ai-platform/workflow/editor/${res.id}`);
router.push(
appContextStore.getContextPath(
`/ai-platform/workflow/editor/${res.id}`,
),
);
} }
} catch { } catch {
// error handled by request interceptor // error handled by request interceptor
@@ -165,7 +156,6 @@ async function fetchList() {
page: pagination.current, page: pagination.current,
pageSize: pagination.pageSize, pageSize: pagination.pageSize,
name: searchKeyword.value || undefined, name: searchKeyword.value || undefined,
applicationId: appContextStore.currentApp?.id,
}); });
workflowList.value = res.items; workflowList.value = res.items;
pagination.total = res.total; pagination.total = res.total;
@@ -233,9 +223,7 @@ const handleQuickRun = async (row: WorkflowListItem) => {
}; };
const handleEdit = (row: WorkflowListItem) => { const handleEdit = (row: WorkflowListItem) => {
router.push( router.push(`/ai-platform/workflow/editor/${row.id}`);
appContextStore.getContextPath(`/ai-platform/workflow/editor/${row.id}`),
);
}; };
const handleDelete = async (row: WorkflowListItem) => { const handleDelete = async (row: WorkflowListItem) => {
@@ -308,10 +296,7 @@ const handleCopy = async (row: WorkflowListItem) => {
const res = await copyWorkflowApi(row.id); const res = await copyWorkflowApi(row.id);
ElMessage.success($t('ai-platform.workflow.copySuccess')); ElMessage.success($t('ai-platform.workflow.copySuccess'));
fetchList(); fetchList();
// router.push(`/ai-platform/workflow/editor/${res.id}`);
router.push(
appContextStore.getContextPath(`/ai-platform/workflow/editor/${res.id}`),
);
} catch (error) { } catch (error) {
if (error !== 'cancel') { if (error !== 'cancel') {
console.error(error); console.error(error);
@@ -24,7 +24,6 @@ import {
importWorkflowConfigApi, importWorkflowConfigApi,
} from '#/api/ai-platform/ai-platform'; } from '#/api/ai-platform/ai-platform';
import { ZqDialog } from '#/components/zq-dialog'; import { ZqDialog } from '#/components/zq-dialog';
import { useAppContextStore } from '#/store/app-context';
interface Props { interface Props {
modelValue: boolean; modelValue: boolean;
@@ -37,8 +36,6 @@ const emit = defineEmits<{
'update:modelValue': [value: boolean]; 'update:modelValue': [value: boolean];
}>(); }>();
const appContextStore = useAppContextStore();
const dialogVisible = computed({ const dialogVisible = computed({
get: () => props.modelValue, get: () => props.modelValue,
set: (val) => emit('update:modelValue', val), set: (val) => emit('update:modelValue', val),
@@ -132,7 +129,6 @@ async function handleConfirmImport() {
try { try {
const payload: WorkflowImportInput = { const payload: WorkflowImportInput = {
...importData.value, ...importData.value,
application_id: appContextStore.currentApp?.id,
code: checkResult.value?.code_exists code: checkResult.value?.code_exists
? newCode.value.trim() ? newCode.value.trim()
: importData.value.code, : importData.value.code,
+1 -1
View File
@@ -25,7 +25,7 @@
}, },
"type": "module", "type": "module",
"scripts": { "scripts": {
"build": "cross-env NODE_OPTIONS=--max-old-space-size=4096 pnpm -F @vben/web-ele run build", "build": "pnpm -F @vben/web-ele run build",
"build:all": "cross-env NODE_OPTIONS=--max-old-space-size=8192 turbo build", "build:all": "cross-env NODE_OPTIONS=--max-old-space-size=8192 turbo build",
"build:analyze": "turbo build:analyze", "build:analyze": "turbo build:analyze",
"build:docker": "./scripts/deploy/build-local-docker-image.sh", "build:docker": "./scripts/deploy/build-local-docker-image.sh",