feat(convertFlowData): 开始/结束节点增加简单的唯一值

master
钟良源 1 month ago
parent 1560907ce1
commit d3d95b13ba

@ -25,11 +25,12 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
if (!flowData || Object.keys(flowData).length === 0) { if (!flowData || Object.keys(flowData).length === 0) {
// 如果useDefault为true且flowData为空则返回默认的开始和结束节点 // 如果useDefault为true且flowData为空则返回默认的开始和结束节点
const timestamp = Date.now();
if (useDefault) { if (useDefault) {
return { return {
nodes: [ nodes: [
{ {
id: 'start', id: `start-${timestamp}`,
type: 'start', type: 'start',
position: { x: 200, y: 200 }, position: { x: 200, y: 200 },
data: { data: {
@ -44,7 +45,7 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
} }
}, },
{ {
id: 'end', id: `end-${timestamp}`,
type: 'end', type: 'end',
position: { x: 600, y: 200 }, position: { x: 600, y: 200 },
data: { data: {
@ -107,10 +108,10 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
// 确定节点类型 // 确定节点类型
let nodeType = 'BASIC'; let nodeType = 'BASIC';
if (nodeId === 'start') { if (nodeId.includes('start')) {
nodeType = 'start'; nodeType = 'start';
} }
else if (nodeId === 'end') { else if (nodeId.includes('end')) {
nodeType = 'end'; nodeType = 'end';
} }
else if (nodeConfig.component?.type === 'LOOP_START' || nodeConfig.component?.type === 'LOOP_END') { else if (nodeConfig.component?.type === 'LOOP_START' || nodeConfig.component?.type === 'LOOP_END') {
@ -405,10 +406,10 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
// 确定节点类型 // 确定节点类型
let nodeType = node.data.type; let nodeType = node.data.type;
// 特殊处理 start 和 end 节点 // 特殊处理 start 和 end 节点
if (nodeId === 'start') { if (nodeId.includes('start')) {
nodeType = 'start'; nodeType = 'start';
} }
else if (nodeId === 'end') { else if (nodeId.includes('end')) {
nodeType = 'end'; nodeType = 'end';
} }
@ -666,7 +667,7 @@ const getNodeApiIns = (nodeId: string, nodeConfig: any, currentProjectCompData:
else if (nodeConfig.component?.type === 'LOOP_END') { else if (nodeConfig.component?.type === 'LOOP_END') {
return [{ name: 'continue', desc: '', dataType: '', defaultValue: '' }]; return [{ name: 'continue', desc: '', dataType: '', defaultValue: '' }];
} }
else if (nodeId === 'end') { else if (nodeId.includes('end')) {
return [{ name: 'end', desc: '', dataType: '', defaultValue: '' }]; return [{ name: 'end', desc: '', dataType: '', defaultValue: '' }];
} }
else { else {
@ -748,10 +749,10 @@ const getNodeApiOuts = (nodeId: string, nodeConfig: any, currentProjectCompData:
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }]; return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
} }
} }
else if (nodeId === 'start') { else if (nodeId.includes('start')) {
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }]; return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
} }
else if (nodeId === 'end') { else if (nodeId.includes('end')) {
return []; return [];
} }
else { else {
@ -777,10 +778,10 @@ const getNodeApiOutHandle = (nodeId: string, nodeConfig: any) => {
else if (nodeConfig.component?.type === 'LOOP_END') { else if (nodeConfig.component?.type === 'LOOP_END') {
return 'break'; return 'break';
} }
else if (nodeId === 'start') { else if (nodeId.includes('start')) {
return 'start'; return 'start';
} }
else if (nodeId === 'end') { else if (nodeId.includes('end')) {
return 'end'; return 'end';
} }
return 'done'; return 'done';

Loading…
Cancel
Save