From c93b4eb5c2269160695bb17ab80fe3f3697156d0 Mon Sep 17 00:00:00 2001 From: panxinying Date: Tue, 1 Sep 2026 14:37:39 +0800 Subject: [PATCH] feat: condition node --- ui/src/workflow-canvas/component/NodeMenu.vue | 120 +++----- .../icons/condition-node-icon.vue | 6 + .../nodes/condition-node/index.ts | 69 +++++ .../nodes/condition-node/index.vue | 280 ++++++++++++++++++ 4 files changed, 391 insertions(+), 84 deletions(-) create mode 100644 ui/src/workflow-canvas/icons/condition-node-icon.vue create mode 100644 ui/src/workflow-canvas/nodes/condition-node/index.ts create mode 100644 ui/src/workflow-canvas/nodes/condition-node/index.vue diff --git a/ui/src/workflow-canvas/component/NodeMenu.vue b/ui/src/workflow-canvas/component/NodeMenu.vue index 4be12bcbb38..3ff818f6a9a 100644 --- a/ui/src/workflow-canvas/component/NodeMenu.vue +++ b/ui/src/workflow-canvas/component/NodeMenu.vue @@ -22,81 +22,37 @@ const workflowComponentTabs: Array<{ label: string; value: WorkflowComponentTab { label: '智能体', value: 'application' }, ] -const workflowComponentOptions = [ +const workflowComponentGroups = [ { - icon: aiChatIcon, - iconClass: 'bg-primary-gradient', - label: 'AI 对话', - value: WorkflowNodeType.AiChat, + label: 'AI 能力', + list: [ + { icon: aiChatIcon, iconClass: 'bg-primary-gradient', label: 'AI 对话', value: WorkflowNodeType.AiChat }, + { icon: aiChatIcon, iconClass: 'bg-primary-gradient', label: '意图识别', value: WorkflowNodeType.IntentNode }, + ], }, { - icon: aiChatIcon, - iconClass: 'bg-primary-gradient', - label: '意图识别', - value: WorkflowNodeType.IntentNode, + label: '业务逻辑', + list: [ + { icon: aiChatIcon, iconClass: 'bg-purple', label: '判断器', value: WorkflowNodeType.Condition }, + { icon: replyIcon, iconClass: 'bg-warning', label: '指定回复', value: WorkflowNodeType.Reply }, + ], }, - // { - // icon: aiChatIcon, - // iconClass: 'bg-primary-gradient', - // label: '文本转语音', - // value: WorkflowNodeType.TextToSpeechNode, - // }, - // { - // icon: aiChatIcon, - // iconClass: 'bg-primary-gradient', - // label: '语音转文本', - // value: WorkflowNodeType.SpeechToTextNode, - // }, - // { - // icon: aiChatIcon, - // iconClass: 'bg-primary-gradient', - // label: '图片生成', - // value: WorkflowNodeType.ImageGenerateNode, - // }, - // { - // icon: aiChatIcon, - // iconClass: 'bg-primary-gradient', - // label: '图片理解', - // value: WorkflowNodeType.ImageUnderstandNode, - // }, - // { - // icon: aiChatIcon, - // iconClass: 'bg-primary-gradient', - // label: '问题优化', - // value: WorkflowNodeType.Question, - // }, - { - icon: replyIcon, - iconClass: 'bg-warning', - label: '指定回复', - value: WorkflowNodeType.Reply, - }, -] satisfies Array<{ - icon: string - iconClass: string - label: string - value: WorkflowNodeType -}> +] -const filteredComponentOptions = computed(() => { +const filteredComponentGroups = computed(() => { if (activeTab.value !== 'basic') return [] const keyword = searchKeyword.value.trim().toLocaleLowerCase() - if (!keyword) return workflowComponentOptions + if (!keyword) return workflowComponentGroups - return workflowComponentOptions.filter((componentOption) => - componentOption.label.toLocaleLowerCase().includes(keyword), - ) + return workflowComponentGroups + .map((group) => ({ ...group, list: group.list.filter((option) => option.label.toLocaleLowerCase().includes(keyword)) })) + .filter((group) => group.list.length > 0) })