Trim online variables from workflow selector

This commit is contained in:
2026-06-08 23:50:30 +08:00
parent 5d4525b898
commit cd355180f6
@@ -2,28 +2,26 @@
import { computed, ref } from 'vue'; import { computed, ref } from 'vue';
import { import {
AppWindow, ArrowDown,
BookOpen, ArrowRight,
Bot, ChatLineRound,
ChevronDown, Check,
ChevronRight, Coin,
CircleHelp, Collection,
ClipboardCheck, Connection,
Code, Cpu,
Combine, DataAnalysis,
Database, Document,
FileText, Finished,
Globe, Guide,
HelpCircle, Help,
LayoutDashboard, Link,
LayoutTemplate, MagicStick,
ListChecks, Operation,
MessageSquareText,
Play,
Search, Search,
Snowflake, Switch,
Square, VideoPlay,
} from '@vben/icons'; } from '@element-plus/icons-vue';
import { $t } from '@vben/locales'; import { $t } from '@vben/locales';
import { useVueFlow } from '@vue-flow/core'; import { useVueFlow } from '@vue-flow/core';
@@ -41,52 +39,29 @@ const collapsedNodes = ref<Set<string>>(new Set());
// 定义不同节点的图标 // 定义不同节点的图标
const icons: any = { const icons: any = {
start: Play, start: VideoPlay,
llm: Bot, llm: MagicStick,
http: Globe, http: Link,
code: Code, code: Cpu,
template: LayoutTemplate, template: Document,
end: Square, end: Finished,
db_query: Database, db_query: Coin,
db_insert: Database, db_insert: Coin,
db_update: Database, db_update: Coin,
db_delete: Database, db_delete: Coin,
db_sql: Database, db_sql: Coin,
// 对话流节点 question: Help,
question: HelpCircle, choice: Operation,
choice: ListChecks, message: ChatLineRound,
message: MessageSquareText, confirm: Check,
confirm: CircleHelp, snowflake_cortex_llm: DataAnalysis,
// Snowflake Cortex 节点 snowflake_cortex_analyst: DataAnalysis,
snowflake_cortex_llm: Snowflake, loop: Switch,
snowflake_cortex_analyst: Snowflake, merge: Connection,
// 循环节点 subflow: Guide,
loop: Play, knowledge_retrieval: Collection,
// 合并节点
merge: Combine,
// 表单节点
form_basic_info: FileText,
form_database_design: Database,
form_database_create: Database,
// 应用节点
app_create: AppWindow,
app_design: LayoutDashboard,
app_settings: LayoutDashboard,
app_update: LayoutDashboard,
// 仪表盘节点
dashboard_basic_info: LayoutDashboard,
dashboard_design: LayoutDashboard,
dashboard_create: LayoutDashboard,
dashboard_publish: LayoutDashboard,
// 系统总结节点
system_summary: ClipboardCheck,
// 子流程节点
subflow: Play,
// 知识库检索节点
knowledge_retrieval: BookOpen,
}; };
// 获取当前节点的父循环节点(如果存在)
const getParentLoopNode = (nodeId: string) => { const getParentLoopNode = (nodeId: string) => {
const currentNode = nodes.value.find((n) => n.id === nodeId); const currentNode = nodes.value.find((n) => n.id === nodeId);
if (currentNode?.parentNode) { if (currentNode?.parentNode) {
@@ -139,92 +114,6 @@ const availableNodes = computed(() => {
// 根据节点类型获取输出变量 schema // 根据节点类型获取输出变量 schema
switch (node.type) { switch (node.type) {
case 'app_create': {
variables = [
{
key: 'app_id',
label: $t('ai-platform.workflow.editor.variableSelector.appId'),
},
{
key: 'app_code',
label: $t('ai-platform.workflow.editor.variableSelector.appCode'),
},
{
key: 'app_name',
label: $t('ai-platform.workflow.editor.variableSelector.appName'),
},
{
key: 'success',
label: $t(
'ai-platform.workflow.editor.variableSelector.createSuccess',
),
},
];
break;
}
case 'app_design': {
variables = [
{
key: 'design_content',
label: $t(
'ai-platform.workflow.editor.variableSelector.designContent',
),
},
{
key: 'design_title',
label: $t(
'ai-platform.workflow.editor.variableSelector.designTitle',
),
},
{
key: 'confirmed',
label: $t(
'ai-platform.workflow.editor.variableSelector.isConfirmed',
),
},
];
break;
}
case 'app_settings': {
variables = [
{
key: 'settings',
label: $t(
'ai-platform.workflow.editor.variableSelector.appSettings',
),
},
{
key: 'confirmed',
label: $t(
'ai-platform.workflow.editor.variableSelector.isConfirmed',
),
},
];
break;
}
case 'app_update': {
variables = [
{
key: 'update_success',
label: $t(
'ai-platform.workflow.editor.variableSelector.updateSuccess',
),
},
{
key: 'config_id',
label: $t(
'ai-platform.workflow.editor.variableSelector.configId',
),
},
{
key: 'update_message',
label: $t(
'ai-platform.workflow.editor.variableSelector.updateMessage',
),
},
];
break;
}
case 'choice': { case 'choice': {
const choiceVar = node.data.variable_name || 'user_choice'; const choiceVar = node.data.variable_name || 'user_choice';
variables = [ variables = [
@@ -280,96 +169,6 @@ const availableNodes = computed(() => {
]; ];
break; break;
} }
case 'dashboard_basic_info': {
variables = [
{
key: 'dashboard_basic_info',
label: $t(
'ai-platform.workflow.editor.variableSelector.dashboardBasicInfo',
),
},
{
key: 'dashboard_name',
label: $t(
'ai-platform.workflow.editor.variableSelector.dashboardName',
),
},
{
key: 'dashboard_code',
label: $t(
'ai-platform.workflow.editor.variableSelector.dashboardCode',
),
},
];
break;
}
case 'dashboard_create': {
variables = [
{
key: 'dashboard_id',
label: $t(
'ai-platform.workflow.editor.variableSelector.dashboardId',
),
},
{
key: 'dashboard_code',
label: $t(
'ai-platform.workflow.editor.variableSelector.dashboardCode',
),
},
{
key: 'page_meta',
label: $t(
'ai-platform.workflow.editor.variableSelector.pageMeta',
),
},
];
break;
}
case 'dashboard_design': {
variables = [
{
key: 'page_config',
label: $t(
'ai-platform.workflow.editor.variableSelector.pageConfig',
),
},
{
key: 'design_title',
label: $t(
'ai-platform.workflow.editor.variableSelector.designTitle',
),
},
{
key: 'confirmed',
label: $t(
'ai-platform.workflow.editor.variableSelector.isConfirmed',
),
},
];
break;
}
case 'dashboard_publish': {
variables = [
{
key: 'menu_id',
label: $t('ai-platform.workflow.editor.variableSelector.menuId'),
},
{
key: 'route_path',
label: $t(
'ai-platform.workflow.editor.variableSelector.routePath',
),
},
{
key: 'publish_result',
label: $t(
'ai-platform.workflow.editor.variableSelector.publishResult',
),
},
];
break;
}
case 'db_delete': { case 'db_delete': {
const deleteOutputVar = node.data.output_variable || 'delete_result'; const deleteOutputVar = node.data.output_variable || 'delete_result';
variables = [ variables = [
@@ -460,205 +259,6 @@ const availableNodes = computed(() => {
]; ];
break; break;
} }
case 'form_basic_info': {
variables = [
{
key: 'form_basic_info',
label: $t(
'ai-platform.workflow.editor.variableSelector.formBasicInfoObj',
),
},
{
key: 'form_name',
label: $t(
'ai-platform.workflow.editor.variableSelector.formName',
),
},
{
key: 'form_code',
label: $t(
'ai-platform.workflow.editor.variableSelector.formCode',
),
},
{
key: 'form_type',
label: $t(
'ai-platform.workflow.editor.variableSelector.formType',
),
},
{
key: 'form_description',
label: $t(
'ai-platform.workflow.editor.variableSelector.formDescription',
),
},
{
key: 'form_sort',
label: $t(
'ai-platform.workflow.editor.variableSelector.formSort',
),
},
];
break;
}
case 'form_create': {
variables = [
{
key: 'form_id',
label: $t('ai-platform.workflow.editor.variableSelector.formId'),
},
{
key: 'form_code',
label: $t(
'ai-platform.workflow.editor.variableSelector.formCode',
),
},
{
key: 'form_meta',
label: $t(
'ai-platform.workflow.editor.variableSelector.formMeta',
),
},
];
break;
}
case 'form_database_create': {
variables = [
{
key: 'creation_result',
label: $t(
'ai-platform.workflow.editor.variableSelector.creationResult',
),
},
{
key: 'all_tables_ready',
label: $t(
'ai-platform.workflow.editor.variableSelector.allTablesReady',
),
},
{
key: 'created_count',
label: $t(
'ai-platform.workflow.editor.variableSelector.createdCount',
),
},
{
key: 'error_count',
label: $t(
'ai-platform.workflow.editor.variableSelector.errorCount',
),
},
{
key: 'schema_name',
label: $t(
'ai-platform.workflow.editor.variableSelector.schemaName',
),
},
{
key: 'table_name',
label: $t(
'ai-platform.workflow.editor.variableSelector.tableName',
),
},
];
break;
}
case 'form_database_design': {
variables = [
{
key: 'database_design',
label: $t(
'ai-platform.workflow.editor.variableSelector.dbDesignObj',
),
},
{
key: 'table_name',
label: $t(
'ai-platform.workflow.editor.variableSelector.tableName',
),
},
{
key: 'field_count',
label: $t(
'ai-platform.workflow.editor.variableSelector.fieldCount',
),
},
];
break;
}
case 'form_list_design': {
variables = [
{
key: 'list_config',
label: $t(
'ai-platform.workflow.editor.variableSelector.listConfig',
),
},
{
key: 'query_field_count',
label: $t(
'ai-platform.workflow.editor.variableSelector.queryFieldCount',
),
},
{
key: 'column_count',
label: $t(
'ai-platform.workflow.editor.variableSelector.columnCount',
),
},
];
break;
}
case 'form_publish': {
variables = [
{
key: 'menu_id',
label: $t('ai-platform.workflow.editor.variableSelector.menuId'),
},
{
key: 'route_path',
label: $t(
'ai-platform.workflow.editor.variableSelector.routePath',
),
},
{
key: 'publish_result',
label: $t(
'ai-platform.workflow.editor.variableSelector.publishResult',
),
},
];
break;
}
case 'form_ui_design': {
variables = [
{
key: 'form_ui_design',
label: $t(
'ai-platform.workflow.editor.variableSelector.formUiDesign',
),
},
{
key: 'form_code',
label: $t(
'ai-platform.workflow.editor.variableSelector.formCode',
),
},
{
key: 'field_count',
label: $t(
'ai-platform.workflow.editor.variableSelector.fieldCount',
),
},
{
key: 'group_count',
label: $t(
'ai-platform.workflow.editor.variableSelector.groupCount',
),
},
];
break;
}
case 'http': { case 'http': {
variables = [ variables = [
{ {
@@ -885,23 +485,6 @@ const availableNodes = computed(() => {
), ),
isSystem: true, 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',
label: $t(
'ai-platform.workflow.editor.variableSelector.formCode',
),
isSystem: true,
},
]; ];
// 加上自定义变量 // 加上自定义变量
variables.push( variables.push(
@@ -965,33 +548,6 @@ const availableNodes = computed(() => {
} }
break; break;
} }
case 'system_summary': {
variables = [
{
key: 'summary',
label: $t(
'ai-platform.workflow.editor.variableSelector.summaryData',
),
},
{
key: 'total_forms',
label: $t(
'ai-platform.workflow.editor.variableSelector.totalForms',
),
},
{
key: 'has_app',
label: $t('ai-platform.workflow.editor.variableSelector.hasApp'),
},
{
key: 'has_dashboard',
label: $t(
'ai-platform.workflow.editor.variableSelector.hasDashboard',
),
},
];
break;
}
case 'template': { case 'template': {
const templateOutputVar = const templateOutputVar =
node.data.output_variable || 'template_result'; node.data.output_variable || 'template_result';
@@ -1107,7 +663,7 @@ const handleSelect = (nodeId: string, variable: string) => {
@click="toggleNodeCollapse(node.id)" @click="toggleNodeCollapse(node.id)"
> >
<component <component
:is="isNodeCollapsed(node.id) ? ChevronRight : ChevronDown" :is="isNodeCollapsed(node.id) ? ArrowRight : ArrowDown"
class="text-muted-foreground size-3 shrink-0" class="text-muted-foreground size-3 shrink-0"
/> />
<component <component