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