From e49df169a542211180fe057dddfa2ad7515adf45 Mon Sep 17 00:00:00 2001 From: ZLY Date: Thu, 28 Aug 2025 14:46:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor(flowEditor):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E8=8A=82=E7=82=B9=E6=95=B0=E6=8D=AE=E7=BB=93=E6=9E=84=E5=B9=B6?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=96=87=E6=9C=AC=E6=9B=B4=E6=96=B0=E8=8A=82?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改基本节点、开始节点和结束节点的数据结构,增加 dataIns、dataOuts、apiIns、apiOuts 字段 - 移除文本更新节点组件和相关样式 - 更新节点类型映射和显示名称映射,删除文本更新节点相关项 --- src/pages/flowEditor/index.tsx | 1 + .../flowEditor/node/basicNode/BasicNode.tsx | 6 ++-- src/pages/flowEditor/node/endNode/EndNode.tsx | 6 ++-- src/pages/flowEditor/node/index.tsx | 8 ++--- .../flowEditor/node/startNode/StartNode.tsx | 6 ++-- .../TextUpdaterNode.module.less | 8 ----- .../node/textUpdateNode/TextUpdaterNode.tsx | 30 ------------------- 7 files changed, 15 insertions(+), 50 deletions(-) delete mode 100644 src/pages/flowEditor/node/textUpdateNode/TextUpdaterNode.module.less delete mode 100644 src/pages/flowEditor/node/textUpdateNode/TextUpdaterNode.tsx diff --git a/src/pages/flowEditor/index.tsx b/src/pages/flowEditor/index.tsx index 7a08c13..fe239b2 100644 --- a/src/pages/flowEditor/index.tsx +++ b/src/pages/flowEditor/index.tsx @@ -59,6 +59,7 @@ const FlowEditor: React.FC = () => { event.dataTransfer.dropEffect = 'move'; }, []); + // 侧边栏节点实例 const onDrop = useCallback( (event: React.DragEvent) => { event.preventDefault(); diff --git a/src/pages/flowEditor/node/basicNode/BasicNode.tsx b/src/pages/flowEditor/node/basicNode/BasicNode.tsx index 333fd4d..2029b0d 100644 --- a/src/pages/flowEditor/node/basicNode/BasicNode.tsx +++ b/src/pages/flowEditor/node/basicNode/BasicNode.tsx @@ -6,8 +6,10 @@ import { useStore } from '@xyflow/react'; interface BasicNodeData { title?: string; parameters?: { - inputs?: any[]; - outputs?: any[]; + dataIns?: any[]; + dataOuts?: any[]; + apiIns?: any[]; + apiOuts?: any[]; }; showFooter?: boolean; diff --git a/src/pages/flowEditor/node/endNode/EndNode.tsx b/src/pages/flowEditor/node/endNode/EndNode.tsx index 0c89d43..e5c3728 100644 --- a/src/pages/flowEditor/node/endNode/EndNode.tsx +++ b/src/pages/flowEditor/node/endNode/EndNode.tsx @@ -6,8 +6,10 @@ import { useStore } from '@xyflow/react'; interface EndNodeData { title?: string; parameters?: { - inputs?: any[]; - outputs?: any[]; + dataIns?: any[]; + dataOuts?: any[]; + apiIns?: any[]; + apiOuts?: any[]; }; showFooter?: boolean; diff --git a/src/pages/flowEditor/node/index.tsx b/src/pages/flowEditor/node/index.tsx index 3f7b15f..6cce302 100644 --- a/src/pages/flowEditor/node/index.tsx +++ b/src/pages/flowEditor/node/index.tsx @@ -1,6 +1,5 @@ import React from 'react'; import { NodeTypes } from '@xyflow/react'; -import TextUpdaterNode from './textUpdateNode/TextUpdaterNode'; import StartNode from './startNode/StartNode'; import EndNode from './endNode/EndNode'; import DraggableNode from './draggableNode/DraggableNode'; @@ -8,7 +7,6 @@ import BasicNode from './basicNode/BasicNode'; // 定义所有可用的节点类型 export const nodeTypes: NodeTypes = { - textUpdater: TextUpdaterNode, start: StartNode, end: EndNode, draggable: DraggableNode, @@ -17,7 +15,6 @@ export const nodeTypes: NodeTypes = { // 节点类型映射,用于创建节点时的类型查找 export const nodeTypeMap: Record = { - 'textUpdater': 'textUpdater', 'start': 'start', 'end': 'end', 'draggable': 'draggable', @@ -26,7 +23,6 @@ export const nodeTypeMap: Record = { // 节点显示名称映射 export const nodeTypeNameMap: Record = { - 'textUpdater': '文本更新节点', 'start': '开始节点', 'end': '结束节点', 'draggable': '任务节点', @@ -41,10 +37,10 @@ export const registerNodeType = ( ) => { // 在nodeTypes中注册节点组件 (nodeTypes as any)[type] = component; - + // 在nodeTypeMap中添加类型映射 nodeTypeMap[type] = type; - + // 在nodeTypeNameMap中添加显示名称 nodeTypeNameMap[type] = displayName || type; }; diff --git a/src/pages/flowEditor/node/startNode/StartNode.tsx b/src/pages/flowEditor/node/startNode/StartNode.tsx index e270c51..ccafa6a 100644 --- a/src/pages/flowEditor/node/startNode/StartNode.tsx +++ b/src/pages/flowEditor/node/startNode/StartNode.tsx @@ -6,8 +6,10 @@ import { useStore } from '@xyflow/react'; interface StartNodeData { title?: string; parameters?: { - inputs?: any[]; - outputs?: any[]; + dataIns?: any[]; + dataOuts?: any[]; + apiIns?: any[]; + apiOuts?: any[]; }; showFooter?: boolean; diff --git a/src/pages/flowEditor/node/textUpdateNode/TextUpdaterNode.module.less b/src/pages/flowEditor/node/textUpdateNode/TextUpdaterNode.module.less deleted file mode 100644 index 99e34e4..0000000 --- a/src/pages/flowEditor/node/textUpdateNode/TextUpdaterNode.module.less +++ /dev/null @@ -1,8 +0,0 @@ -.text-updater-node { - //width: 150px; - //height: 80px; - padding: 20px; - border-radius: 15px; - border: 1px solid #cccccc; - background-color: #fff; -} \ No newline at end of file diff --git a/src/pages/flowEditor/node/textUpdateNode/TextUpdaterNode.tsx b/src/pages/flowEditor/node/textUpdateNode/TextUpdaterNode.tsx deleted file mode 100644 index a9f8a49..0000000 --- a/src/pages/flowEditor/node/textUpdateNode/TextUpdaterNode.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import React, { useCallback } from 'react'; -import style from './TextUpdaterNode.module.less'; -import { Handle, NodeProps, Position } from '@xyflow/react'; - -interface TextUpdaterNodeData { - data?: string; - id?: string; -} - const TextUpdaterNode: React.FC = (props) => { - const onChange = useCallback((evt: React.ChangeEvent) => { - console.log(evt.target.value); - }, []); - - return ( -
-
- - -
- - - - - - -
- ); -}; - -export default TextUpdaterNode; \ No newline at end of file