From 587606e31da2fd5ec7eb2347f9cd092aa149c30d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E6=A2=A6?= Date: Mon, 6 Jan 2025 11:57:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=9D=A1=E4=BB=B6=E8=8A=82=E7=82=B9?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=A0=BC=E5=BC=8F=E6=9B=B4=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/xflow/demo/layout/LR/setting.tsx | 6 +++--- docs/xflow/demo/layout/TB/setting.tsx | 6 +++--- docs/xflow/demo/nodeSetting/data.tsx | 6 +++--- docs/xflow/demo/switchNode/index.tsx | 14 +++++++------- docs/xflow/nodeBuildIn.md | 6 +++--- .../x-flow/src/components/CustomNode/index.tsx | 6 +++--- .../x-flow/src/components/NodeEditor/index.tsx | 8 ++++---- .../x-flow/src/components/NodesPopover/index.tsx | 2 +- .../nodes/node-switch/SwitchBuildInNodeWidget.tsx | 14 +++++++------- 9 files changed, 34 insertions(+), 34 deletions(-) diff --git a/docs/xflow/demo/layout/LR/setting.tsx b/docs/xflow/demo/layout/LR/setting.tsx index 976edd3b9..5de7c4761 100644 --- a/docs/xflow/demo/layout/LR/setting.tsx +++ b/docs/xflow/demo/layout/LR/setting.tsx @@ -212,7 +212,7 @@ export const nodes = [ data: { list: [ { - _conditionId: 'iawoyh5niyi6zjob', + _id: 'iawoyh5niyi6zjob', }, ], }, @@ -259,8 +259,8 @@ export const edges = [ { type: 'buttonedge', source: 'b6zsd6w5ah2b209t', - sourceHandle: 'condition_else', + sourceHandle: 'id_else', target: '4', - id: 'xy-edge__b6zsd6w5ah2b209tcondition_else-4', + id: 'xy-edge__b6zsd6w5ah2b209tid_else-4', }, ]; diff --git a/docs/xflow/demo/layout/TB/setting.tsx b/docs/xflow/demo/layout/TB/setting.tsx index f07b58a57..775af2c55 100644 --- a/docs/xflow/demo/layout/TB/setting.tsx +++ b/docs/xflow/demo/layout/TB/setting.tsx @@ -217,7 +217,7 @@ export const nodes = [ data: { list: [ { - _conditionId: 'iawoyh5niyi6zjob', + _id: 'iawoyh5niyi6zjob', }, ], }, @@ -273,8 +273,8 @@ export const edges = [ { type: 'buttonedge', source: 'b6zsd6w5ah2b209t', - sourceHandle: 'condition_else', + sourceHandle: 'id_else', target: '4', - id: 'xy-edge__b6zsd6w5ah2b209tcondition_else-4', + id: 'xy-edge__b6zsd6w5ah2b209tid_else-4', }, ]; diff --git a/docs/xflow/demo/nodeSetting/data.tsx b/docs/xflow/demo/nodeSetting/data.tsx index 9e321ab09..cb1603af5 100644 --- a/docs/xflow/demo/nodeSetting/data.tsx +++ b/docs/xflow/demo/nodeSetting/data.tsx @@ -177,7 +177,7 @@ export const nodes = [ data: { list: [ { - _conditionId: 'iawoyh5niyi6zjob', + _id: 'iawoyh5niyi6zjob', }, ], }, @@ -224,8 +224,8 @@ export const edges = [ { type: 'buttonedge', source: 'b6zsd6w5ah2b209t', - sourceHandle: 'condition_else', + sourceHandle: 'id_else', target: '4', - id: 'xy-edge__b6zsd6w5ah2b209tcondition_else-4', + id: 'xy-edge__b6zsd6w5ah2b209tid_else-4', }, ]; diff --git a/docs/xflow/demo/switchNode/index.tsx b/docs/xflow/demo/switchNode/index.tsx index c6239afaa..105b1ed66 100644 --- a/docs/xflow/demo/switchNode/index.tsx +++ b/docs/xflow/demo/switchNode/index.tsx @@ -22,16 +22,16 @@ export default () => { data: { list: [ { - _conditionId: 'condition_1nmzbhnbtv1se6sd', // 对应的 sourceHandle: 'condition_1nmzbhnbtv1se6sd'的边 + _id: 'id_1nmzbhnbtv1se6sd', // 对应的 sourceHandle: 'id_1nmzbhnbtv1se6sd'的边 value: '条件1', }, { value: '条件2', - _conditionId: 'condition_enxhwfca1ebn55td', // 对应sourceHandle: 'condition_enxhwfca1ebn55td'的边 + _id: 'id_enxhwfca1ebn55td', // 对应sourceHandle: 'id_enxhwfca1ebn55td'的边 }, { value: '条件3', - _conditionId: 'condition_z1f7b93zwbx1xycu',// 对应sourceHandle: 'condition_z1f7b93zwbx1xycu'的边 + _id: 'id_z1f7b93zwbx1xycu',// 对应sourceHandle: 'id_z1f7b93zwbx1xycu'的边 }, ], desc: '', @@ -97,25 +97,25 @@ export default () => { id: '5s6af77jbcqvzfod', source: 'kshd2hp4vqm8ww19',// switch节点的边 target: 'ql61j2tdli4xage0', - sourceHandle: 'condition_1nmzbhnbtv1se6sd', // 对应 _conditionId为'condition_1nmzbhnbtv1se6sd'的条件 + sourceHandle: 'id_1nmzbhnbtv1se6sd', // 对应 _id为'id_1nmzbhnbtv1se6sd'的条件 }, { id: '6tw709qgc3mtazrv', source: 'kshd2hp4vqm8ww19',// switch节点的边 target: 'fab1j735q8iow6u3', - sourceHandle: 'condition_enxhwfca1ebn55td', // 对应 _conditionId为'condition_enxhwfca1ebn55td'的条件 + sourceHandle: 'id_enxhwfca1ebn55td', // 对应 _id为'id_enxhwfca1ebn55td'的条件 }, { id: 'vzlvdo69ljcqegc8', source: 'kshd2hp4vqm8ww19',// switch节点的边 target: '9mc5i628mfrxdow0', - sourceHandle: 'condition_z1f7b93zwbx1xycu',// 对应 _conditionId为'condition_z1f7b93zwbx1xycu'的条件 + sourceHandle: 'id_z1f7b93zwbx1xycu',// 对应 _id为'id_z1f7b93zwbx1xycu'的条件 }, { id: 'j8p8fnr5au9k25pb', source: 'kshd2hp4vqm8ww19',// switch节点的边 target: 'anmv2kcadqxj4k63', - sourceHandle: 'condition_else',// condition_else 对应默认路径ELSE + sourceHandle: 'id_else',// id_else 对应默认路径ELSE }, { id: '0qfpkc9vcjdb31qp', diff --git a/docs/xflow/nodeBuildIn.md b/docs/xflow/nodeBuildIn.md index 870b6944e..549b46db5 100644 --- a/docs/xflow/nodeBuildIn.md +++ b/docs/xflow/nodeBuildIn.md @@ -11,14 +11,14 @@ group: ## 条件内置节点 内置条件节点,可以直接设置type为`Switch`使用。 -条件节点的数据格式为`data:{list:[{value:"条件1",_conditionId:"condition_${随机数}"}]}`,`_conditionId`为边数据的`sourceHandle`,以便条件和边一一对应。 -有条件参数value(可以通过自定义条件节点配置面板更改配置参数)的放入list数组里面作为`IF或者ELIF`渲染,没有条件参数的,为默认执行路径`ELSE`,`ELSE`路径的固定`_conditionId`为`condition_else`,即边数据的`sourceHandle`必须为`condition_else`才能链接`ELSE`链接头,比如: +条件节点的数据格式为`data:{list:[{value:"条件1",_id:"id_${随机数}"}]}`,`_id`为边数据的`sourceHandle`,以便条件和边一一对应。 +有条件参数value(可以通过自定义条件节点配置面板更改配置参数)的放入list数组里面作为`IF或者ELIF`渲染,没有条件参数的,为默认执行路径`ELSE`,`ELSE`路径的固定`_id`为`id_else`,即边数据的`sourceHandle`必须为`id_else`才能链接`ELSE`链接头,比如: ```js { id: 'j8p8fnr5au9k25pb', source: 'kshd2hp4vqm8ww19', target: 'anmv2kcadqxj4k63', - sourceHandle: 'condition_else', // else路径的边 + sourceHandle: 'id_else', // else路径的边 } ``` diff --git a/packages/x-flow/src/components/CustomNode/index.tsx b/packages/x-flow/src/components/CustomNode/index.tsx index a0b003c08..0ecb3ae5a 100644 --- a/packages/x-flow/src/components/CustomNode/index.tsx +++ b/packages/x-flow/src/components/CustomNode/index.tsx @@ -146,7 +146,7 @@ export default memo((props: any) => { key: 'paste-' + i, index: i, id: id, - sourcehandle: r._conditionId, + sourcehandle: r._id, }; } else { return { @@ -154,7 +154,7 @@ export default memo((props: any) => { key: 'paste-' + i, id: id, index: i, - sourcehandle: r._conditionId, + sourcehandle: r._id, }; } }); @@ -166,7 +166,7 @@ export default memo((props: any) => { key: 'paste-' + (list.length + 1), id: id, index: list.length + 1, - sourcehandle: 'condition_else', + sourcehandle: 'id_else', }, ]; } diff --git a/packages/x-flow/src/components/NodeEditor/index.tsx b/packages/x-flow/src/components/NodeEditor/index.tsx index 361c85ba6..b6c6c5ca8 100644 --- a/packages/x-flow/src/components/NodeEditor/index.tsx +++ b/packages/x-flow/src/components/NodeEditor/index.tsx @@ -71,19 +71,19 @@ const NodeEditor: FC = (props: any) => { // 更新节点的 data if (node?.data?._nodeType === 'Switch' && data?.list?.length) { data['list'] = (data?.list || [])?.map((item, index) => { - if (item?._conditionId) { + if (item?._id) { return item; } else { if ( node?.data?.list?.length && - node?.data?.list[index]?._conditionId + node?.data?.list[index]?._id ) { return { ...item, - _conditionId: node?.data?.list[index]?._conditionId, + _id: node?.data?.list[index]?._id, }; } else { - return { ...item, _conditionId: `condition_${uuid()}` }; + return { ...item, _id: `id_${uuid()}` }; } } }); diff --git a/packages/x-flow/src/components/NodesPopover/index.tsx b/packages/x-flow/src/components/NodesPopover/index.tsx index df3b39843..d6032a392 100644 --- a/packages/x-flow/src/components/NodesPopover/index.tsx +++ b/packages/x-flow/src/components/NodesPopover/index.tsx @@ -42,7 +42,7 @@ export default forwardRef((props: any, popoverRef) => { const handCreateNode = useCallback(({ type }) => { if (type === 'Switch') { - addNode({ _nodeType: type, list: [{ '_conditionId':`${uuid()}`}] }); + addNode({ _nodeType: type, list: [{ '_id':`${uuid()}`}] }); } else if (type === 'Parallel') { addNode({ _nodeType: type, list: [{ _id: `id_${uuid()}` }, { _id: `id_${uuid()}` }] }); } else { diff --git a/packages/x-flow/src/nodes/node-switch/SwitchBuildInNodeWidget.tsx b/packages/x-flow/src/nodes/node-switch/SwitchBuildInNodeWidget.tsx index 5c043742b..900fc9d01 100644 --- a/packages/x-flow/src/nodes/node-switch/SwitchBuildInNodeWidget.tsx +++ b/packages/x-flow/src/nodes/node-switch/SwitchBuildInNodeWidget.tsx @@ -36,15 +36,15 @@ export default memo((props: any) => { position={position} isConnectable={ (edges || [])?.filter( - flow => flow?.sourceHandle === item?._conditionId + flow => flow?.sourceHandle === item?._id )?.length === 0 } selected={selected} isHovered={isHovered} handleAddNode={data => { - handleAddNode(data, item?._conditionId); + handleAddNode(data, item?._id); }} - id={item?._conditionId} + id={item?._id} className="item-handle" /> @@ -89,7 +89,7 @@ export default memo((props: any) => { })} size={5} > - {(data?.list || [{ _conditionId: `condition_${uuid()}` }])?.map( + {(data?.list || [{ _id: `id_${uuid()}` }])?.map( (item, index) => (
{ position={position} isConnectable={ (edges || [])?.filter( - flow => flow?.sourceHandle === 'condition_else' + flow => flow?.sourceHandle === 'id_else' )?.length === 0 } selected={selected} isHovered={isHovered} handleAddNode={data => { - handleAddNode(data, 'condition_else'); + handleAddNode(data, 'id_else'); }} className="item-handle" - id={'condition_else'} + id={'id_else'} />