From 33a1c178ff0225af2050999a9a7b09f0c7286b37 Mon Sep 17 00:00:00 2001 From: zhaoying Date: Thu, 9 Apr 2026 17:45:42 +0800 Subject: [PATCH] fix(web): if-else node case show --- .../Workflow/components/Nodes/ConditionNode.tsx | 4 ++-- web/src/views/Workflow/hooks/useWorkflowGraph.ts | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/web/src/views/Workflow/components/Nodes/ConditionNode.tsx b/web/src/views/Workflow/components/Nodes/ConditionNode.tsx index 79e8352c..996ae5dd 100644 --- a/web/src/views/Workflow/components/Nodes/ConditionNode.tsx +++ b/web/src/views/Workflow/components/Nodes/ConditionNode.tsx @@ -14,7 +14,7 @@ const caculateIsSet = (item: any, type: string) => { case 'cases': { if (!item.left) return false if (['not_empty', 'empty'].includes(item.operator)) return true - return !!item.left && (!!item.right || typeof item.right === 'boolean') + return !!item.left && (!!item.right || typeof item.right === 'boolean' || typeof item.right === 'number') } } } @@ -22,7 +22,7 @@ const ConditionNode: ReactShapeConfig['component'] = ({ node }) => { const data = node?.getData() || {}; const { t } = useTranslation() const graphRef = useRef(node?.model?.graph) - const variableList = useVariableList(node ?? null, graphRef, []) + const variableList = useVariableList(node ?? null, graphRef, data.chatVariables ?? []) const getLocaleField = (field: string, filedType: string) => { const key = filedType === 'boolean' ? `workflow.config.if-else..boolean.${field}` : filedType === 'number' ? `workflow.config.if-else.num.${field}` : `workflow.config.if-else.${field}` diff --git a/web/src/views/Workflow/hooks/useWorkflowGraph.ts b/web/src/views/Workflow/hooks/useWorkflowGraph.ts index 45400362..19e8662b 100644 --- a/web/src/views/Workflow/hooks/useWorkflowGraph.ts +++ b/web/src/views/Workflow/hooks/useWorkflowGraph.ts @@ -106,6 +106,16 @@ export const useWorkflowGraph = ({ const [chatVariables, setChatVariables] = useState([]) const featuresRef = useRef(undefined) + useEffect(() => { + if (!graphRef.current) return + graphRef.current.getNodes().forEach(node => { + const data = node.getData() + if (data?.type === 'if-else' || data?.type === 'question-classifier') { + node.setData({ ...data, chatVariables }, { silent: true }) + } + }) + }, [chatVariables]) + useEffect(() => { getConfig() }, [id]) @@ -211,7 +221,7 @@ export const useWorkflowGraph = ({ id, type, name, - data: { ...node, ...nodeLibraryConfig}, + data: { ...node, ...nodeLibraryConfig, ...((type === 'if-else' || type === 'question-classifier') ? { chatVariables } : {}) }, ...position, }