|
|
|
@ -1,8 +1,14 @@
|
|
|
|
import { nodeTypeMap, registerNodeType } from '@/components/FlowEditor/node';
|
|
|
|
import { nodeTypeMap, registerNodeType } from '@/components/FlowEditor/node';
|
|
|
|
import store from '@/store/index';
|
|
|
|
import store from '@/store/index';
|
|
|
|
|
|
|
|
import LocalNode from '@/components/FlowEditor/node/localNode/LocalNode';
|
|
|
|
import LoopNode from '@/components/FlowEditor/node/loopNode/LoopNode';
|
|
|
|
import LoopNode from '@/components/FlowEditor/node/loopNode/LoopNode';
|
|
|
|
|
|
|
|
import SwitchNode from '@/components/FlowEditor/node/switchNode/SwitchNode';
|
|
|
|
|
|
|
|
import BasicNode from '@/components/FlowEditor/node/basicNode/BasicNode';
|
|
|
|
|
|
|
|
import ImageNode from '@/components/FlowEditor/node/imageNode/ImageNode';
|
|
|
|
|
|
|
|
import CodeNode from '@/components/FlowEditor/node/codeNode/CodeNode';
|
|
|
|
|
|
|
|
import RestNode from '@/components/FlowEditor/node/restNode/RestNode';
|
|
|
|
import { updateEventNodeList } from '@/store/ideContainer';
|
|
|
|
import { updateEventNodeList } from '@/store/ideContainer';
|
|
|
|
import { resolveNodeComponent } from '@/utils/flow/nodeRegistry';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 将提供的数据结构转换为适用于 flow editor 的 nodes 和 edges
|
|
|
|
* 将提供的数据结构转换为适用于 flow editor 的 nodes 和 edges
|
|
|
|
@ -31,14 +37,12 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
title: '开始',
|
|
|
|
title: '开始',
|
|
|
|
parameters: {
|
|
|
|
parameters: {
|
|
|
|
apiIns: [],
|
|
|
|
apiIns: [],
|
|
|
|
apiOuts: [
|
|
|
|
apiOuts: [{ name: 'start', desc: '', dataType: '', defaultValue: '' }],
|
|
|
|
{ name: 'start', desc: '', dataType: '', defaultValue: '' },
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
dataIns: [],
|
|
|
|
dataIns: [],
|
|
|
|
dataOuts: [],
|
|
|
|
dataOuts: []
|
|
|
|
},
|
|
|
|
|
|
|
|
type: 'start',
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
type: 'start'
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
id: `end-${timestamp}`,
|
|
|
|
id: `end-${timestamp}`,
|
|
|
|
@ -47,18 +51,16 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
title: '结束',
|
|
|
|
title: '结束',
|
|
|
|
parameters: {
|
|
|
|
parameters: {
|
|
|
|
apiIns: [
|
|
|
|
apiIns: [{ name: 'end', desc: '', dataType: '', defaultValue: '' }],
|
|
|
|
{ name: 'end', desc: '', dataType: '', defaultValue: '' },
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
apiOuts: [],
|
|
|
|
apiOuts: [],
|
|
|
|
dataIns: [],
|
|
|
|
dataIns: [],
|
|
|
|
dataOuts: [],
|
|
|
|
dataOuts: []
|
|
|
|
},
|
|
|
|
|
|
|
|
type: 'end',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
type: 'end'
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
],
|
|
|
|
],
|
|
|
|
edges: [],
|
|
|
|
edges: []
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 否则返回空数组
|
|
|
|
// 否则返回空数组
|
|
|
|
@ -78,55 +80,44 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const customDef = JSON.parse(nodeConfig.component.customDef);
|
|
|
|
const customDef = JSON.parse(nodeConfig.component.customDef);
|
|
|
|
// 使用展开运算符创建新数组,避免修改冻结对象
|
|
|
|
// 使用展开运算符创建新数组,避免修改冻结对象
|
|
|
|
eventlisteneList.splice(eventlisteneList.length, 0, {
|
|
|
|
eventlisteneList.splice(eventlisteneList.length, 0, { [nodeId]: customDef.topic });
|
|
|
|
[nodeId]: customDef.topic,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (
|
|
|
|
}
|
|
|
|
nodeId.includes('EVENTSEND') &&
|
|
|
|
else if (nodeId.includes('EVENTSEND') && !nodeId.includes('EVENTSEND_SYNC')) {
|
|
|
|
!nodeId.includes('EVENTSEND_SYNC')
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const customDef = JSON.parse(nodeConfig.component.customDef);
|
|
|
|
const customDef = JSON.parse(nodeConfig.component.customDef);
|
|
|
|
// 使用展开运算符创建新数组,避免修改冻结对象
|
|
|
|
// 使用展开运算符创建新数组,避免修改冻结对象
|
|
|
|
eventSendNodeList.splice(eventSendNodeList.length, 0, {
|
|
|
|
eventSendNodeList.splice(eventSendNodeList.length, 0, { [nodeId]: customDef.topic });
|
|
|
|
[nodeId]: customDef.topic,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.log(error);
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (eventlisteneList.length > 0 || eventSendNodeList.length > 0)
|
|
|
|
if (eventlisteneList.length > 0 || eventSendNodeList.length > 0) store.dispatch(updateEventNodeList({
|
|
|
|
store.dispatch(
|
|
|
|
|
|
|
|
updateEventNodeList({
|
|
|
|
|
|
|
|
eventSendNodeList: [...eventSendNodeList],
|
|
|
|
eventSendNodeList: [...eventSendNodeList],
|
|
|
|
eventlisteneList: [...eventlisteneList],
|
|
|
|
eventlisteneList: [...eventlisteneList]
|
|
|
|
})
|
|
|
|
}));
|
|
|
|
);
|
|
|
|
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
store.dispatch(
|
|
|
|
store.dispatch(updateEventNodeList({
|
|
|
|
updateEventNodeList({
|
|
|
|
|
|
|
|
eventSendNodeList: [],
|
|
|
|
eventSendNodeList: [],
|
|
|
|
eventlisteneList: [],
|
|
|
|
eventlisteneList: []
|
|
|
|
})
|
|
|
|
}));
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 确定节点类型
|
|
|
|
// 确定节点类型
|
|
|
|
let nodeType = 'BASIC';
|
|
|
|
let nodeType = 'BASIC';
|
|
|
|
if (nodeId.includes('start')) {
|
|
|
|
if (nodeId.includes('start')) {
|
|
|
|
nodeType = 'start';
|
|
|
|
nodeType = 'start';
|
|
|
|
} else if (nodeId.includes('end')) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeId.includes('end')) {
|
|
|
|
nodeType = 'end';
|
|
|
|
nodeType = 'end';
|
|
|
|
} else if (
|
|
|
|
}
|
|
|
|
nodeConfig.component?.type === 'LOOP_START' ||
|
|
|
|
else if (nodeConfig.component?.type === 'LOOP_START' || nodeConfig.component?.type === 'LOOP_END') {
|
|
|
|
nodeConfig.component?.type === 'LOOP_END'
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
nodeType = 'LOOP';
|
|
|
|
nodeType = 'LOOP';
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
nodeType = nodeConfig.component?.type || 'BASIC';
|
|
|
|
nodeType = nodeConfig.component?.type || 'BASIC';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -144,10 +135,10 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
apiIns: getNodeApiIns(nodeId, nodeConfig, currentProjectCompData),
|
|
|
|
apiIns: getNodeApiIns(nodeId, nodeConfig, currentProjectCompData),
|
|
|
|
apiOuts: getNodeApiOuts(nodeId, nodeConfig, currentProjectCompData),
|
|
|
|
apiOuts: getNodeApiOuts(nodeId, nodeConfig, currentProjectCompData),
|
|
|
|
dataIns: nodeConfig.dataIns || [],
|
|
|
|
dataIns: nodeConfig.dataIns || [],
|
|
|
|
dataOuts: nodeConfig.dataOuts || [],
|
|
|
|
dataOuts: nodeConfig.dataOuts || []
|
|
|
|
},
|
|
|
|
|
|
|
|
type: nodeConfig.component?.type || nodeType,
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
type: nodeConfig.component?.type || nodeType
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 添加组件标识信息
|
|
|
|
// 添加组件标识信息
|
|
|
|
@ -166,25 +157,16 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
|
|
|
|
|
|
|
|
// 注册循环节点类型
|
|
|
|
// 注册循环节点类型
|
|
|
|
if (nodeType === 'LOOP') {
|
|
|
|
if (nodeType === 'LOOP') {
|
|
|
|
const nodeMap = Array.from(Object.values(nodeTypeMap).map((key) => key));
|
|
|
|
const nodeMap = Array.from(Object.values(nodeTypeMap).map(key => key));
|
|
|
|
if (!nodeMap.includes('LOOP')) {
|
|
|
|
if (!nodeMap.includes('LOOP')) {
|
|
|
|
registerNodeType('LOOP', LoopNode, '循环');
|
|
|
|
registerNodeType('LOOP', LoopNode, '循环');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 注册其他节点类型
|
|
|
|
// 注册其他节点类型
|
|
|
|
const nodeMap = Array.from(Object.values(nodeTypeMap).map((key) => key));
|
|
|
|
const nodeMap = Array.from(Object.values(nodeTypeMap).map(key => key));
|
|
|
|
if (
|
|
|
|
if (!nodeMap.includes(nodeType) && nodeType !== 'start' && nodeType !== 'end' && nodeType !== 'LOOP') {
|
|
|
|
!nodeMap.includes(nodeType) &&
|
|
|
|
registerNodeType(nodeType, getNodeComponent(nodeType), nodeConfig.componentName);
|
|
|
|
nodeType !== 'start' &&
|
|
|
|
|
|
|
|
nodeType !== 'end' &&
|
|
|
|
|
|
|
|
nodeType !== 'LOOP'
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
registerNodeType(
|
|
|
|
|
|
|
|
nodeType,
|
|
|
|
|
|
|
|
resolveNodeComponent(nodeType),
|
|
|
|
|
|
|
|
nodeConfig.componentName
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nodes.push(node);
|
|
|
|
nodes.push(node);
|
|
|
|
@ -194,15 +176,7 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
const addedEdges = new Set<string>();
|
|
|
|
const addedEdges = new Set<string>();
|
|
|
|
|
|
|
|
|
|
|
|
// 创建一个映射来存储所有连接信息
|
|
|
|
// 创建一个映射来存储所有连接信息
|
|
|
|
const connections = new Map<
|
|
|
|
const connections = new Map<string, { source: string; target: string; sourceHandle: string; targetHandle: string }>();
|
|
|
|
string,
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
source: string;
|
|
|
|
|
|
|
|
target: string;
|
|
|
|
|
|
|
|
sourceHandle: string;
|
|
|
|
|
|
|
|
targetHandle: string;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 遍历所有节点,收集连接信息
|
|
|
|
// 遍历所有节点,收集连接信息
|
|
|
|
for (const entry of nodeEntries) {
|
|
|
|
for (const entry of nodeEntries) {
|
|
|
|
@ -213,7 +187,7 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
if (nodeConfig.apiDownstream && Array.isArray(nodeConfig.apiDownstream)) {
|
|
|
|
if (nodeConfig.apiDownstream && Array.isArray(nodeConfig.apiDownstream)) {
|
|
|
|
nodeConfig.apiDownstream.forEach((targetArray: string[]) => {
|
|
|
|
nodeConfig.apiDownstream.forEach((targetArray: string[]) => {
|
|
|
|
if (Array.isArray(targetArray)) {
|
|
|
|
if (Array.isArray(targetArray)) {
|
|
|
|
targetArray.forEach((target) => {
|
|
|
|
targetArray.forEach(target => {
|
|
|
|
if (typeof target === 'string' && target.includes('$$')) {
|
|
|
|
if (typeof target === 'string' && target.includes('$$')) {
|
|
|
|
const [targetNodeId, targetHandle] = target.split('$$');
|
|
|
|
const [targetNodeId, targetHandle] = target.split('$$');
|
|
|
|
const connectionKey = `${nodeId}-${targetNodeId}`;
|
|
|
|
const connectionKey = `${nodeId}-${targetNodeId}`;
|
|
|
|
@ -225,16 +199,17 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
if (existing) {
|
|
|
|
if (existing) {
|
|
|
|
connections.set(connectionKey, {
|
|
|
|
connections.set(connectionKey, {
|
|
|
|
...existing,
|
|
|
|
...existing,
|
|
|
|
targetHandle: targetHandle,
|
|
|
|
targetHandle: targetHandle
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 创建新的连接信息
|
|
|
|
// 创建新的连接信息
|
|
|
|
connections.set(connectionKey, {
|
|
|
|
connections.set(connectionKey, {
|
|
|
|
source: nodeId,
|
|
|
|
source: nodeId,
|
|
|
|
target: targetNodeId,
|
|
|
|
target: targetNodeId,
|
|
|
|
sourceHandle: '', // 将根据节点信息填充
|
|
|
|
sourceHandle: '', // 将根据节点信息填充
|
|
|
|
targetHandle: targetHandle,
|
|
|
|
targetHandle: targetHandle
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -247,7 +222,7 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
if (nodeConfig.apiUpstream && Array.isArray(nodeConfig.apiUpstream)) {
|
|
|
|
if (nodeConfig.apiUpstream && Array.isArray(nodeConfig.apiUpstream)) {
|
|
|
|
nodeConfig.apiUpstream.forEach((sourceArray: string[]) => {
|
|
|
|
nodeConfig.apiUpstream.forEach((sourceArray: string[]) => {
|
|
|
|
if (Array.isArray(sourceArray)) {
|
|
|
|
if (Array.isArray(sourceArray)) {
|
|
|
|
sourceArray.forEach((source) => {
|
|
|
|
sourceArray.forEach(source => {
|
|
|
|
if (typeof source === 'string' && source.includes('$$')) {
|
|
|
|
if (typeof source === 'string' && source.includes('$$')) {
|
|
|
|
const [sourceNodeId, sourceHandle] = source.split('$$');
|
|
|
|
const [sourceNodeId, sourceHandle] = source.split('$$');
|
|
|
|
const connectionKey = `${sourceNodeId}-${nodeId}`;
|
|
|
|
const connectionKey = `${sourceNodeId}-${nodeId}`;
|
|
|
|
@ -259,16 +234,17 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
if (existing) {
|
|
|
|
if (existing) {
|
|
|
|
connections.set(connectionKey, {
|
|
|
|
connections.set(connectionKey, {
|
|
|
|
...existing,
|
|
|
|
...existing,
|
|
|
|
sourceHandle: sourceHandle,
|
|
|
|
sourceHandle: sourceHandle
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 创建新的连接信息
|
|
|
|
// 创建新的连接信息
|
|
|
|
connections.set(connectionKey, {
|
|
|
|
connections.set(connectionKey, {
|
|
|
|
source: sourceNodeId,
|
|
|
|
source: sourceNodeId,
|
|
|
|
target: nodeId,
|
|
|
|
target: nodeId,
|
|
|
|
sourceHandle: sourceHandle,
|
|
|
|
sourceHandle: sourceHandle,
|
|
|
|
targetHandle: '', // 将根据节点信息填充
|
|
|
|
targetHandle: '' // 将根据节点信息填充
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -293,13 +269,9 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
if (!finalSourceHandle) {
|
|
|
|
if (!finalSourceHandle) {
|
|
|
|
if (source === 'start') {
|
|
|
|
if (source === 'start') {
|
|
|
|
finalSourceHandle = 'start';
|
|
|
|
finalSourceHandle = 'start';
|
|
|
|
} else if (
|
|
|
|
}
|
|
|
|
sourceNode &&
|
|
|
|
else if (sourceNode && sourceNode.data && sourceNode.data.parameters &&
|
|
|
|
sourceNode.data &&
|
|
|
|
sourceNode.data.parameters.apiOuts && sourceNode.data.parameters.apiOuts.length > 0) {
|
|
|
|
sourceNode.data.parameters &&
|
|
|
|
|
|
|
|
sourceNode.data.parameters.apiOuts &&
|
|
|
|
|
|
|
|
sourceNode.data.parameters.apiOuts.length > 0
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
// 查找匹配的目标句柄
|
|
|
|
// 查找匹配的目标句柄
|
|
|
|
const matchingApiOut = sourceNode.data.parameters.apiOuts.find(
|
|
|
|
const matchingApiOut = sourceNode.data.parameters.apiOuts.find(
|
|
|
|
(apiOut: any) => apiOut.name === targetHandle
|
|
|
|
(apiOut: any) => apiOut.name === targetHandle
|
|
|
|
@ -307,18 +279,17 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingApiOut) {
|
|
|
|
if (matchingApiOut) {
|
|
|
|
finalSourceHandle = matchingApiOut.name;
|
|
|
|
finalSourceHandle = matchingApiOut.name;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 如果没有精确匹配,使用第一个apiOut
|
|
|
|
// 如果没有精确匹配,使用第一个apiOut
|
|
|
|
finalSourceHandle = sourceNode.data.parameters.apiOuts[0].name;
|
|
|
|
finalSourceHandle = sourceNode.data.parameters.apiOuts[0].name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (
|
|
|
|
}
|
|
|
|
sourceNode &&
|
|
|
|
else if (sourceNode && sourceNode.component && sourceNode.component.type) {
|
|
|
|
sourceNode.component &&
|
|
|
|
|
|
|
|
sourceNode.component.type
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
// 根据节点类型获取正确的源句柄
|
|
|
|
// 根据节点类型获取正确的源句柄
|
|
|
|
finalSourceHandle = getNodeApiOutHandle(source, sourceNode);
|
|
|
|
finalSourceHandle = getNodeApiOutHandle(source, sourceNode);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 默认句柄
|
|
|
|
// 默认句柄
|
|
|
|
finalSourceHandle = 'done';
|
|
|
|
finalSourceHandle = 'done';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -330,13 +301,9 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
if (!finalTargetHandle) {
|
|
|
|
if (!finalTargetHandle) {
|
|
|
|
if (target === 'end') {
|
|
|
|
if (target === 'end') {
|
|
|
|
finalTargetHandle = 'end';
|
|
|
|
finalTargetHandle = 'end';
|
|
|
|
} else if (
|
|
|
|
}
|
|
|
|
targetNode &&
|
|
|
|
else if (targetNode && targetNode.data && targetNode.data.parameters &&
|
|
|
|
targetNode.data &&
|
|
|
|
targetNode.data.parameters.apiIns && targetNode.data.parameters.apiIns.length > 0) {
|
|
|
|
targetNode.data.parameters &&
|
|
|
|
|
|
|
|
targetNode.data.parameters.apiIns &&
|
|
|
|
|
|
|
|
targetNode.data.parameters.apiIns.length > 0
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
// 查找匹配的源句柄
|
|
|
|
// 查找匹配的源句柄
|
|
|
|
const matchingApiIn = targetNode.data.parameters.apiIns.find(
|
|
|
|
const matchingApiIn = targetNode.data.parameters.apiIns.find(
|
|
|
|
(apiIn: any) => apiIn.name === sourceHandle
|
|
|
|
(apiIn: any) => apiIn.name === sourceHandle
|
|
|
|
@ -344,11 +311,13 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
|
|
|
|
|
|
|
|
if (matchingApiIn) {
|
|
|
|
if (matchingApiIn) {
|
|
|
|
finalTargetHandle = matchingApiIn.name;
|
|
|
|
finalTargetHandle = matchingApiIn.name;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 如果没有精确匹配,使用第一个apiIn
|
|
|
|
// 如果没有精确匹配,使用第一个apiIn
|
|
|
|
finalTargetHandle = targetNode.data.parameters.apiIns[0].name;
|
|
|
|
finalTargetHandle = targetNode.data.parameters.apiIns[0].name;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 默认句柄
|
|
|
|
// 默认句柄
|
|
|
|
finalTargetHandle = 'start';
|
|
|
|
finalTargetHandle = 'start';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -369,8 +338,8 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
type: 'custom',
|
|
|
|
type: 'custom',
|
|
|
|
lineType: 'api',
|
|
|
|
lineType: 'api',
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
lineType: 'api',
|
|
|
|
lineType: 'api'
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -387,12 +356,9 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
// 第一个元素是源节点和句柄信息
|
|
|
|
// 第一个元素是源节点和句柄信息
|
|
|
|
const [sourceInfo, targetInfo] = connectionGroup;
|
|
|
|
const [sourceInfo, targetInfo] = connectionGroup;
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (typeof sourceInfo === 'string' && sourceInfo.includes('@@') &&
|
|
|
|
typeof sourceInfo === 'string' &&
|
|
|
|
typeof targetInfo === 'string' && targetInfo.includes('@@')) {
|
|
|
|
sourceInfo.includes('@@') &&
|
|
|
|
|
|
|
|
typeof targetInfo === 'string' &&
|
|
|
|
|
|
|
|
targetInfo.includes('@@')
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
const [sourceNodeId, sourceHandle] = sourceInfo.split('@@');
|
|
|
|
const [sourceNodeId, sourceHandle] = sourceInfo.split('@@');
|
|
|
|
const [targetNodeId, targetHandle] = targetInfo.split('@@');
|
|
|
|
const [targetNodeId, targetHandle] = targetInfo.split('@@');
|
|
|
|
|
|
|
|
|
|
|
|
@ -412,8 +378,8 @@ export const convertFlowData = (flowData: any, useDefault = true) => {
|
|
|
|
type: 'custom',
|
|
|
|
type: 'custom',
|
|
|
|
lineType: 'data',
|
|
|
|
lineType: 'data',
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
lineType: 'data',
|
|
|
|
lineType: 'data'
|
|
|
|
},
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -437,12 +403,12 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
|
|
|
|
const flowData: any = {
|
|
|
|
const flowData: any = {
|
|
|
|
id: 'main',
|
|
|
|
id: 'main',
|
|
|
|
nodeConfigs: [],
|
|
|
|
nodeConfigs: [],
|
|
|
|
lineConfigs: [],
|
|
|
|
lineConfigs: []
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 转换节点数据
|
|
|
|
// 转换节点数据
|
|
|
|
if (nodes && nodes.length > 0) {
|
|
|
|
if (nodes && nodes.length > 0) {
|
|
|
|
flowData.nodeConfigs = nodes.map((node) => {
|
|
|
|
flowData.nodeConfigs = nodes.map(node => {
|
|
|
|
// 确定 nodeId 和 nodeName
|
|
|
|
// 确定 nodeId 和 nodeName
|
|
|
|
const nodeId = node.id || node.name;
|
|
|
|
const nodeId = node.id || node.name;
|
|
|
|
const nodeName = node.data?.title || nodeId;
|
|
|
|
const nodeName = node.data?.title || nodeId;
|
|
|
|
@ -452,20 +418,21 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
|
|
|
|
// 特殊处理 start 和 end 节点
|
|
|
|
// 特殊处理 start 和 end 节点
|
|
|
|
if (nodeId.includes('start')) {
|
|
|
|
if (nodeId.includes('start')) {
|
|
|
|
nodeType = 'start';
|
|
|
|
nodeType = 'start';
|
|
|
|
} else if (nodeId.includes('end')) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeId.includes('end')) {
|
|
|
|
nodeType = 'end';
|
|
|
|
nodeType = 'end';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 构造 x6 数据(位置信息)
|
|
|
|
// 构造 x6 数据(位置信息)
|
|
|
|
const x6 = JSON.stringify({
|
|
|
|
const x6 = JSON.stringify({
|
|
|
|
position: node.position,
|
|
|
|
position: node.position
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 构造 nodeConfig 对象
|
|
|
|
// 构造 nodeConfig 对象
|
|
|
|
const nodeConfig: any = {
|
|
|
|
const nodeConfig: any = {
|
|
|
|
nodeId,
|
|
|
|
nodeId,
|
|
|
|
nodeName,
|
|
|
|
nodeName,
|
|
|
|
x6,
|
|
|
|
x6
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 处理 component 信息
|
|
|
|
// 处理 component 信息
|
|
|
|
@ -473,20 +440,18 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
|
|
|
|
nodeConfig.component = {
|
|
|
|
nodeConfig.component = {
|
|
|
|
type: nodeType,
|
|
|
|
type: nodeType,
|
|
|
|
compIdentifier: node.data.component.compIdentifier || '',
|
|
|
|
compIdentifier: node.data.component.compIdentifier || '',
|
|
|
|
compInstanceIdentifier:
|
|
|
|
compInstanceIdentifier: node.data.component.compInstanceIdentifier || '',
|
|
|
|
node.data.component.compInstanceIdentifier || '',
|
|
|
|
compId: node.data.compId || ''
|
|
|
|
compId: node.data.compId || '',
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
if (node.data.component?.customDef)
|
|
|
|
if (node.data.component?.customDef) nodeConfig.component.customDef = node.data.component.customDef;
|
|
|
|
nodeConfig.component.customDef = node.data.component.customDef;
|
|
|
|
}
|
|
|
|
} else if (nodeType !== 'start' && nodeType !== 'end') {
|
|
|
|
else if (nodeType !== 'start' && nodeType !== 'end') {
|
|
|
|
// 对于非 start/end 节点,添加基本的 component 信息
|
|
|
|
// 对于非 start/end 节点,添加基本的 component 信息
|
|
|
|
nodeConfig.component = {
|
|
|
|
nodeConfig.component = {
|
|
|
|
type: nodeType,
|
|
|
|
type: nodeType
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (['BASIC', 'SUB'].includes(nodeType))
|
|
|
|
if (['BASIC', 'SUB'].includes(nodeType)) nodeConfig.component.compId = node.data.compId || '';
|
|
|
|
nodeConfig.component.compId = node.data.compId || '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理参数信息
|
|
|
|
// 处理参数信息
|
|
|
|
const parameters = node.data?.parameters || {};
|
|
|
|
const parameters = node.data?.parameters || {};
|
|
|
|
@ -498,7 +463,7 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
|
|
|
|
desc: input.desc,
|
|
|
|
desc: input.desc,
|
|
|
|
dataType: input.dataType,
|
|
|
|
dataType: input.dataType,
|
|
|
|
defaultValue: input.defaultValue,
|
|
|
|
defaultValue: input.defaultValue,
|
|
|
|
arrayType: input.arrayType || null,
|
|
|
|
arrayType: input.arrayType || null
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -509,7 +474,7 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
|
|
|
|
desc: output.desc,
|
|
|
|
desc: output.desc,
|
|
|
|
dataType: output.dataType,
|
|
|
|
dataType: output.dataType,
|
|
|
|
defaultValue: output.defaultValue,
|
|
|
|
defaultValue: output.defaultValue,
|
|
|
|
arrayType: output.arrayType || null,
|
|
|
|
arrayType: output.arrayType || null
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -521,34 +486,22 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
|
|
|
|
if (edges && edges.length > 0) {
|
|
|
|
if (edges && edges.length > 0) {
|
|
|
|
flowData.lineConfigs = edges.map((edge, index) => {
|
|
|
|
flowData.lineConfigs = edges.map((edge, index) => {
|
|
|
|
// 查找源节点和目标节点以确定连线类型
|
|
|
|
// 查找源节点和目标节点以确定连线类型
|
|
|
|
const sourceNode = nodes.find((node) => node.id === edge.source);
|
|
|
|
const sourceNode = nodes.find(node => node.id === edge.source);
|
|
|
|
const targetNode = nodes.find((node) => node.id === edge.target);
|
|
|
|
const targetNode = nodes.find(node => node.id === edge.target);
|
|
|
|
|
|
|
|
|
|
|
|
let lineType = 'DATA'; // 默认为DATA类型
|
|
|
|
let lineType = 'DATA'; // 默认为DATA类型
|
|
|
|
|
|
|
|
|
|
|
|
// 判断是否为CONVERT类型的连线
|
|
|
|
// 判断是否为CONVERT类型的连线
|
|
|
|
if (
|
|
|
|
if (targetNode && ['JSONCONVERT', 'JSON2STR', 'STR2JSON'].includes(targetNode.type)) {
|
|
|
|
targetNode &&
|
|
|
|
|
|
|
|
['JSONCONVERT', 'JSON2STR', 'STR2JSON'].includes(targetNode.type)
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
lineType = 'CONVERT';
|
|
|
|
lineType = 'CONVERT';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 判断是否为API类型的连线
|
|
|
|
// 判断是否为API类型的连线
|
|
|
|
else if (
|
|
|
|
else if (edge.sourceHandle && (edge.sourceHandle === 'apiOuts' ||
|
|
|
|
edge.sourceHandle &&
|
|
|
|
sourceNode?.data?.parameters?.apiOuts?.some((out: any) => (out.name || out.id) === edge.sourceHandle))) {
|
|
|
|
(edge.sourceHandle === 'apiOuts' ||
|
|
|
|
|
|
|
|
sourceNode?.data?.parameters?.apiOuts?.some(
|
|
|
|
|
|
|
|
(out: any) => (out.name || out.id) === edge.sourceHandle
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
lineType = 'API';
|
|
|
|
lineType = 'API';
|
|
|
|
} else if (
|
|
|
|
}
|
|
|
|
edge.targetHandle &&
|
|
|
|
else if (edge.targetHandle && (edge.targetHandle === 'apiIns' ||
|
|
|
|
(edge.targetHandle === 'apiIns' ||
|
|
|
|
targetNode?.data?.parameters?.apiIns?.some((inp: any) => (inp.name || inp.id) === edge.targetHandle))) {
|
|
|
|
targetNode?.data?.parameters?.apiIns?.some(
|
|
|
|
|
|
|
|
(inp: any) => (inp.name || inp.id) === edge.targetHandle
|
|
|
|
|
|
|
|
))
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
lineType = 'API';
|
|
|
|
lineType = 'API';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -557,12 +510,12 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
|
|
|
|
lineType, // 添加lineType属性
|
|
|
|
lineType, // 添加lineType属性
|
|
|
|
prev: {
|
|
|
|
prev: {
|
|
|
|
nodeId: edge.source,
|
|
|
|
nodeId: edge.source,
|
|
|
|
endpointId: edge.sourceHandle || 'done', // 默认使用 'done'
|
|
|
|
endpointId: edge.sourceHandle || 'done' // 默认使用 'done'
|
|
|
|
},
|
|
|
|
},
|
|
|
|
next: {
|
|
|
|
next: {
|
|
|
|
nodeId: edge.target,
|
|
|
|
nodeId: edge.target,
|
|
|
|
endpointId: edge.targetHandle || 'start', // 默认使用 'start'
|
|
|
|
endpointId: edge.targetHandle || 'start' // 默认使用 'start'
|
|
|
|
},
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -577,24 +530,20 @@ export const revertFlowData = (nodes: any[], edges: any[]) => {
|
|
|
|
* @param complexKV - 复合组件使用的组件id对照表 {数字ID/nodeId:sub_ID}
|
|
|
|
* @param complexKV - 复合组件使用的组件id对照表 {数字ID/nodeId:sub_ID}
|
|
|
|
* @returns 可用于 convertFlowData 的数据结构
|
|
|
|
* @returns 可用于 convertFlowData 的数据结构
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
export const reverseConvertFlowData = (
|
|
|
|
export const reverseConvertFlowData = (nodes: any[], edges: any[], complexKV: any) => {
|
|
|
|
nodes: any[],
|
|
|
|
|
|
|
|
edges: any[],
|
|
|
|
|
|
|
|
complexKV: any
|
|
|
|
|
|
|
|
) => {
|
|
|
|
|
|
|
|
// 初始化返回的数据结构
|
|
|
|
// 初始化返回的数据结构
|
|
|
|
const flowData: any = {};
|
|
|
|
const flowData: any = {};
|
|
|
|
|
|
|
|
|
|
|
|
// 转换节点数据
|
|
|
|
// 转换节点数据
|
|
|
|
if (nodes && nodes.length > 0) {
|
|
|
|
if (nodes && nodes.length > 0) {
|
|
|
|
nodes.forEach((node) => {
|
|
|
|
nodes.forEach(node => {
|
|
|
|
const nodeId = node.id;
|
|
|
|
const nodeId = node.id;
|
|
|
|
|
|
|
|
|
|
|
|
// 构造节点配置对象
|
|
|
|
// 构造节点配置对象
|
|
|
|
const nodeConfig: any = {
|
|
|
|
const nodeConfig: any = {
|
|
|
|
id: nodeId,
|
|
|
|
id: nodeId,
|
|
|
|
componentName: node.data?.title || nodeId,
|
|
|
|
componentName: node.data?.title || nodeId,
|
|
|
|
position: node.position || { x: 0, y: 0 },
|
|
|
|
position: node.position || { x: 0, y: 0 }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 处理 component 信息
|
|
|
|
// 处理 component 信息
|
|
|
|
@ -621,14 +570,16 @@ export const reverseConvertFlowData = (
|
|
|
|
dataIns: node.data.parameters.dataIns,
|
|
|
|
dataIns: node.data.parameters.dataIns,
|
|
|
|
dataOuts: node.data.parameters.dataOuts,
|
|
|
|
dataOuts: node.data.parameters.dataOuts,
|
|
|
|
subflowId: subflowId,
|
|
|
|
subflowId: subflowId,
|
|
|
|
name: node.data.title,
|
|
|
|
name: node.data.title
|
|
|
|
}),
|
|
|
|
})
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else if (node.data?.component) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (node.data?.component) {
|
|
|
|
nodeConfig.component = { ...node.data.component };
|
|
|
|
nodeConfig.component = { ...node.data.component };
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
nodeConfig.component = {
|
|
|
|
nodeConfig.component = {
|
|
|
|
type: node.type,
|
|
|
|
type: node.type
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -638,28 +589,32 @@ export const reverseConvertFlowData = (
|
|
|
|
// 处理 apiIns(输入API)
|
|
|
|
// 处理 apiIns(输入API)
|
|
|
|
if (parameters.apiIns && parameters.apiIns.length > 0) {
|
|
|
|
if (parameters.apiIns && parameters.apiIns.length > 0) {
|
|
|
|
nodeConfig.apiIns = parameters.apiIns;
|
|
|
|
nodeConfig.apiIns = parameters.apiIns;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
nodeConfig.apiIns = [];
|
|
|
|
nodeConfig.apiIns = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理 apiOuts(输出API)
|
|
|
|
// 处理 apiOuts(输出API)
|
|
|
|
if (parameters.apiOuts && parameters.apiOuts.length > 0) {
|
|
|
|
if (parameters.apiOuts && parameters.apiOuts.length > 0) {
|
|
|
|
nodeConfig.apiOuts = parameters.apiOuts;
|
|
|
|
nodeConfig.apiOuts = parameters.apiOuts;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
nodeConfig.apiOuts = [];
|
|
|
|
nodeConfig.apiOuts = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理 dataIns(输入数据)
|
|
|
|
// 处理 dataIns(输入数据)
|
|
|
|
if (parameters.dataIns && parameters.dataIns.length > 0) {
|
|
|
|
if (parameters.dataIns && parameters.dataIns.length > 0) {
|
|
|
|
nodeConfig.dataIns = parameters.dataIns;
|
|
|
|
nodeConfig.dataIns = parameters.dataIns;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
nodeConfig.dataIns = [];
|
|
|
|
nodeConfig.dataIns = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 处理 dataOuts(输出数据)
|
|
|
|
// 处理 dataOuts(输出数据)
|
|
|
|
if (parameters.dataOuts && parameters.dataOuts.length > 0) {
|
|
|
|
if (parameters.dataOuts && parameters.dataOuts.length > 0) {
|
|
|
|
nodeConfig.dataOuts = parameters.dataOuts;
|
|
|
|
nodeConfig.dataOuts = parameters.dataOuts;
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
nodeConfig.dataOuts = [];
|
|
|
|
nodeConfig.dataOuts = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -677,45 +632,33 @@ export const reverseConvertFlowData = (
|
|
|
|
// 处理连接关系
|
|
|
|
// 处理连接关系
|
|
|
|
if (edges && edges.length > 0) {
|
|
|
|
if (edges && edges.length > 0) {
|
|
|
|
// 分析边的连接关系
|
|
|
|
// 分析边的连接关系
|
|
|
|
edges.forEach((edge) => {
|
|
|
|
edges.forEach(edge => {
|
|
|
|
const sourceNode = edge.source;
|
|
|
|
const sourceNode = edge.source;
|
|
|
|
const targetNode = edge.target;
|
|
|
|
const targetNode = edge.target;
|
|
|
|
const sourceHandle = edge.sourceHandle || 'done';
|
|
|
|
const sourceHandle = edge.sourceHandle || 'done';
|
|
|
|
const targetHandle = edge.targetHandle || 'start';
|
|
|
|
const targetHandle = edge.targetHandle || 'start';
|
|
|
|
|
|
|
|
|
|
|
|
// 确定连接类型(API 还是 DATA)
|
|
|
|
// 确定连接类型(API 还是 DATA)
|
|
|
|
const sourceNodeData = nodes.find((n) => n.id === sourceNode);
|
|
|
|
const sourceNodeData = nodes.find(n => n.id === sourceNode);
|
|
|
|
const targetNodeData = nodes.find((n) => n.id === targetNode);
|
|
|
|
const targetNodeData = nodes.find(n => n.id === targetNode);
|
|
|
|
|
|
|
|
|
|
|
|
const isApiConnection =
|
|
|
|
const isApiConnection =
|
|
|
|
sourceNodeData?.data?.parameters?.apiOuts?.some(
|
|
|
|
(sourceNodeData?.data?.parameters?.apiOuts?.some((out: any) => (out.name || out.id) === sourceHandle)) ||
|
|
|
|
(out: any) => (out.name || out.id) === sourceHandle
|
|
|
|
(targetNodeData?.data?.parameters?.apiIns?.some((inp: any) => (inp.name || inp.id) === targetHandle)) ||
|
|
|
|
) ||
|
|
|
|
sourceHandle === 'start' || targetHandle === 'end' ||
|
|
|
|
targetNodeData?.data?.parameters?.apiIns?.some(
|
|
|
|
sourceHandle === 'end' || targetHandle === 'start';
|
|
|
|
(inp: any) => (inp.name || inp.id) === targetHandle
|
|
|
|
|
|
|
|
) ||
|
|
|
|
|
|
|
|
sourceHandle === 'start' ||
|
|
|
|
|
|
|
|
targetHandle === 'end' ||
|
|
|
|
|
|
|
|
sourceHandle === 'end' ||
|
|
|
|
|
|
|
|
targetHandle === 'start';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isApiConnection) {
|
|
|
|
if (isApiConnection) {
|
|
|
|
// API 连接
|
|
|
|
// API 连接
|
|
|
|
// 添加下游连接
|
|
|
|
// 添加下游连接
|
|
|
|
flowData[sourceNode].apiDownstream.push([
|
|
|
|
flowData[sourceNode].apiDownstream.push([`${targetNode}$$${targetHandle}`]);
|
|
|
|
`${targetNode}$$${targetHandle}`,
|
|
|
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加上游连接
|
|
|
|
// 添加上游连接
|
|
|
|
flowData[targetNode].apiUpstream.push([
|
|
|
|
flowData[targetNode].apiUpstream.push([`${sourceNode}$$${sourceHandle}`]);
|
|
|
|
`${sourceNode}$$${sourceHandle}`,
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
else {
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 数据连接
|
|
|
|
// 数据连接
|
|
|
|
const dataConnection = [
|
|
|
|
const dataConnection = [`${sourceNode}@@${sourceHandle}`, `${targetNode}@@${targetHandle}`];
|
|
|
|
`${sourceNode}@@${sourceHandle}`,
|
|
|
|
|
|
|
|
`${targetNode}@@${targetHandle}`,
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
flowData[sourceNode].dataDownstream.push(dataConnection);
|
|
|
|
flowData[sourceNode].dataDownstream.push(dataConnection);
|
|
|
|
flowData[targetNode].dataUpstream.push(dataConnection);
|
|
|
|
flowData[targetNode].dataUpstream.push(dataConnection);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -726,67 +669,59 @@ export const reverseConvertFlowData = (
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 获取节点的API输入参数
|
|
|
|
// 获取节点的API输入参数
|
|
|
|
const getNodeApiIns = (
|
|
|
|
const getNodeApiIns = (nodeId: string, nodeConfig: any, currentProjectCompData: any[]) => {
|
|
|
|
nodeId: string,
|
|
|
|
|
|
|
|
nodeConfig: any,
|
|
|
|
|
|
|
|
currentProjectCompData: any[]
|
|
|
|
|
|
|
|
) => {
|
|
|
|
|
|
|
|
// JSON2STR 和 STR2JSON 不需要 API 输入
|
|
|
|
// JSON2STR 和 STR2JSON 不需要 API 输入
|
|
|
|
if (
|
|
|
|
if (nodeConfig.component?.type === 'JSON2STR' || nodeConfig.component?.type === 'STR2JSON') {
|
|
|
|
nodeConfig.component?.type === 'JSON2STR' ||
|
|
|
|
|
|
|
|
nodeConfig.component?.type === 'STR2JSON'
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return [];
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 对于特定类型的节点使用预定义值
|
|
|
|
// 对于特定类型的节点使用预定义值
|
|
|
|
if (nodeConfig.component?.type === 'LOOP_START') {
|
|
|
|
if (nodeConfig.component?.type === 'LOOP_START') {
|
|
|
|
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
} 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.includes('end')) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeId.includes('end')) {
|
|
|
|
return [{ name: 'end', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'end', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
} else if (nodeConfig.component?.type === 'SUB') {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeConfig.component?.type === 'SUB') {
|
|
|
|
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
const comp = currentProjectCompData.filter((item) => {
|
|
|
|
else {
|
|
|
|
|
|
|
|
const comp = currentProjectCompData.filter(item => {
|
|
|
|
return (item.id || item?.comp?.id) === nodeConfig?.component?.compId;
|
|
|
|
return (item.id || item?.comp?.id) === nodeConfig?.component?.compId;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
if (comp && comp.length > 0) {
|
|
|
|
if (comp && comp.length > 0) {
|
|
|
|
const apiIns = comp[0]?.def?.apis || comp[0]?.comp?.def?.apis || [];
|
|
|
|
const apiIns = comp[0]?.def?.apis || comp[0]?.comp?.def?.apis || [];
|
|
|
|
return apiIns.map((v) => {
|
|
|
|
return apiIns.map(v => {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
...v,
|
|
|
|
...v,
|
|
|
|
name: v.id,
|
|
|
|
name: v.id,
|
|
|
|
desc: v.desc,
|
|
|
|
desc: v.desc,
|
|
|
|
dataType: v?.dataType || '',
|
|
|
|
dataType: v?.dataType || '',
|
|
|
|
defaultValue: v?.defaultValue || '',
|
|
|
|
defaultValue: v?.defaultValue || ''
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 获取节点的API输出参数
|
|
|
|
// 获取节点的API输出参数
|
|
|
|
const getNodeApiOuts = (
|
|
|
|
const getNodeApiOuts = (nodeId: string, nodeConfig: any, currentProjectCompData: any[]) => {
|
|
|
|
nodeId: string,
|
|
|
|
|
|
|
|
nodeConfig: any,
|
|
|
|
|
|
|
|
currentProjectCompData: any[]
|
|
|
|
|
|
|
|
) => {
|
|
|
|
|
|
|
|
// JSON2STR 和 STR2JSON 不需要 API 输出
|
|
|
|
// JSON2STR 和 STR2JSON 不需要 API 输出
|
|
|
|
if (
|
|
|
|
if (nodeConfig.component?.type === 'JSON2STR' || nodeConfig.component?.type === 'STR2JSON') {
|
|
|
|
nodeConfig.component?.type === 'JSON2STR' ||
|
|
|
|
|
|
|
|
nodeConfig.component?.type === 'STR2JSON'
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
return [];
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 对于特定类型的节点使用预定义值
|
|
|
|
// 对于特定类型的节点使用预定义值
|
|
|
|
if (nodeConfig.component?.type === 'LOOP_START') {
|
|
|
|
if (nodeConfig.component?.type === 'LOOP_START') {
|
|
|
|
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
} else if (nodeConfig.component?.type === 'LOOP_END') {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeConfig.component?.type === 'LOOP_END') {
|
|
|
|
// 从customDef中获取apiOutIds数组
|
|
|
|
// 从customDef中获取apiOutIds数组
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const customDef = JSON.parse(nodeConfig.component?.customDef || '{}');
|
|
|
|
const customDef = JSON.parse(nodeConfig.component?.customDef || '{}');
|
|
|
|
@ -796,14 +731,15 @@ const getNodeApiOuts = (
|
|
|
|
const breakIndex = apiOutIds.indexOf('break');
|
|
|
|
const breakIndex = apiOutIds.indexOf('break');
|
|
|
|
if (breakIndex !== -1) {
|
|
|
|
if (breakIndex !== -1) {
|
|
|
|
// 返回从"break"开始的所有项
|
|
|
|
// 返回从"break"开始的所有项
|
|
|
|
return apiOutIds.slice(breakIndex).map((id) => ({
|
|
|
|
return apiOutIds.slice(breakIndex).map(id => ({
|
|
|
|
name: id,
|
|
|
|
name: id,
|
|
|
|
id: id,
|
|
|
|
id: id,
|
|
|
|
desc: id,
|
|
|
|
desc: id,
|
|
|
|
dataType: '',
|
|
|
|
dataType: '',
|
|
|
|
defaultValue: '',
|
|
|
|
defaultValue: ''
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 如果没有找到"break",则返回默认值
|
|
|
|
// 如果没有找到"break",则返回默认值
|
|
|
|
return [{ name: 'break', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'break', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -811,7 +747,8 @@ const getNodeApiOuts = (
|
|
|
|
// 解析失败时返回默认值
|
|
|
|
// 解析失败时返回默认值
|
|
|
|
return [{ name: 'break', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'break', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (nodeConfig.component?.type === 'SWITCH') {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeConfig.component?.type === 'SWITCH') {
|
|
|
|
// 从customDef中获取apiOutIds数组
|
|
|
|
// 从customDef中获取apiOutIds数组
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const customDef = JSON.parse(nodeConfig.component?.customDef || '{}');
|
|
|
|
const customDef = JSON.parse(nodeConfig.component?.customDef || '{}');
|
|
|
|
@ -821,14 +758,15 @@ const getNodeApiOuts = (
|
|
|
|
const breakIndex = apiOutIds.indexOf('default');
|
|
|
|
const breakIndex = apiOutIds.indexOf('default');
|
|
|
|
if (breakIndex !== -1) {
|
|
|
|
if (breakIndex !== -1) {
|
|
|
|
// 返回从"break"开始的所有项
|
|
|
|
// 返回从"break"开始的所有项
|
|
|
|
return apiOutIds.slice(breakIndex).map((id) => ({
|
|
|
|
return apiOutIds.slice(breakIndex).map(id => ({
|
|
|
|
name: id,
|
|
|
|
name: id,
|
|
|
|
id: id,
|
|
|
|
id: id,
|
|
|
|
desc: id,
|
|
|
|
desc: id,
|
|
|
|
dataType: '',
|
|
|
|
dataType: '',
|
|
|
|
defaultValue: '',
|
|
|
|
defaultValue: ''
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
// 如果没有找到"break",则返回默认值
|
|
|
|
// 如果没有找到"break",则返回默认值
|
|
|
|
return [{ name: 'default', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'default', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -836,25 +774,26 @@ const getNodeApiOuts = (
|
|
|
|
// 解析失败时返回默认值
|
|
|
|
// 解析失败时返回默认值
|
|
|
|
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (nodeId.includes('start')) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeId.includes('start')) {
|
|
|
|
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'start', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
} else if (nodeId.includes('end')) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeId.includes('end')) {
|
|
|
|
return [];
|
|
|
|
return [];
|
|
|
|
} else if (nodeConfig.component?.type === 'SUB') {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeConfig.component?.type === 'SUB') {
|
|
|
|
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
const comp = currentProjectCompData.filter(
|
|
|
|
else {
|
|
|
|
(item) => item.id === nodeConfig?.component?.compId
|
|
|
|
const comp = currentProjectCompData.filter(item => item.id === nodeConfig?.component?.compId);
|
|
|
|
);
|
|
|
|
|
|
|
|
if (comp && comp.length > 0) {
|
|
|
|
if (comp && comp.length > 0) {
|
|
|
|
return [
|
|
|
|
return [{
|
|
|
|
{
|
|
|
|
|
|
|
|
...comp[0].def?.apiOut,
|
|
|
|
...comp[0].def?.apiOut,
|
|
|
|
dataType: '',
|
|
|
|
dataType: '',
|
|
|
|
defaultValue: '',
|
|
|
|
defaultValue: ''
|
|
|
|
},
|
|
|
|
}];
|
|
|
|
];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else {
|
|
|
|
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
return [{ name: 'done', desc: '', dataType: '', defaultValue: '' }];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -864,11 +803,14 @@ const getNodeApiOuts = (
|
|
|
|
const getNodeApiOutHandle = (nodeId: string, nodeConfig: any) => {
|
|
|
|
const getNodeApiOutHandle = (nodeId: string, nodeConfig: any) => {
|
|
|
|
if (nodeConfig.component?.type === 'LOOP_START') {
|
|
|
|
if (nodeConfig.component?.type === 'LOOP_START') {
|
|
|
|
return 'done';
|
|
|
|
return 'done';
|
|
|
|
} else if (nodeConfig.component?.type === 'LOOP_END') {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeConfig.component?.type === 'LOOP_END') {
|
|
|
|
return 'break';
|
|
|
|
return 'break';
|
|
|
|
} else if (nodeId.includes('start')) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeId.includes('start')) {
|
|
|
|
return 'start';
|
|
|
|
return 'start';
|
|
|
|
} else if (nodeId.includes('end')) {
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (nodeId.includes('end')) {
|
|
|
|
return 'end';
|
|
|
|
return 'end';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 'done';
|
|
|
|
return 'done';
|
|
|
|
@ -883,17 +825,13 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
|
|
|
|
|
|
|
|
// 处理projectCompDto中的数据
|
|
|
|
// 处理projectCompDto中的数据
|
|
|
|
if (compData.projectCompDto) {
|
|
|
|
if (compData.projectCompDto) {
|
|
|
|
const {
|
|
|
|
const { mineComp = [], pubComp = [], teamWorkComp = [] } = compData.projectCompDto;
|
|
|
|
mineComp = [],
|
|
|
|
|
|
|
|
pubComp = [],
|
|
|
|
|
|
|
|
teamWorkComp = [],
|
|
|
|
|
|
|
|
} = compData.projectCompDto;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 添加mineComp数据
|
|
|
|
// 添加mineComp数据
|
|
|
|
mineComp.forEach((item: any) => {
|
|
|
|
mineComp.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'mineComp',
|
|
|
|
type: 'mineComp'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -901,7 +839,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
pubComp.forEach((item: any) => {
|
|
|
|
pubComp.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'pubComp',
|
|
|
|
type: 'pubComp'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -909,7 +847,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
teamWorkComp.forEach((item: any) => {
|
|
|
|
teamWorkComp.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'teamWorkComp',
|
|
|
|
type: 'teamWorkComp'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -922,7 +860,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
mineFlow.forEach((item: any) => {
|
|
|
|
mineFlow.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'mineFlow',
|
|
|
|
type: 'mineFlow'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
@ -930,7 +868,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
pubFlow.forEach((item: any) => {
|
|
|
|
pubFlow.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'pubFlow',
|
|
|
|
type: 'pubFlow'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -943,13 +881,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
const compLibsData = sessionStorage.getItem(compLibsKey);
|
|
|
|
const compLibsData = sessionStorage.getItem(compLibsKey);
|
|
|
|
|
|
|
|
|
|
|
|
if (compLibsData) {
|
|
|
|
if (compLibsData) {
|
|
|
|
const {
|
|
|
|
const { myLibs = [], pubLibs = [], teamLibs = [], myFlow = [], pubFlow = [] } = JSON.parse(compLibsData);
|
|
|
|
myLibs = [],
|
|
|
|
|
|
|
|
pubLibs = [],
|
|
|
|
|
|
|
|
teamLibs = [],
|
|
|
|
|
|
|
|
myFlow = [],
|
|
|
|
|
|
|
|
pubFlow = [],
|
|
|
|
|
|
|
|
} = JSON.parse(compLibsData);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 处理 myLibs(我的组件库)
|
|
|
|
// 处理 myLibs(我的组件库)
|
|
|
|
if (Array.isArray(myLibs)) {
|
|
|
|
if (Array.isArray(myLibs)) {
|
|
|
|
@ -958,7 +890,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
lib.children.forEach((item: any) => {
|
|
|
|
lib.children.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'mineComp',
|
|
|
|
type: 'mineComp'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -972,7 +904,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
lib.children.forEach((item: any) => {
|
|
|
|
lib.children.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'pubComp',
|
|
|
|
type: 'pubComp'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -986,7 +918,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
lib.children.forEach((item: any) => {
|
|
|
|
lib.children.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'teamWorkComp',
|
|
|
|
type: 'teamWorkComp'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -998,7 +930,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
myFlow.forEach((item: any) => {
|
|
|
|
myFlow.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'mineFlow',
|
|
|
|
type: 'mineFlow'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1008,7 +940,7 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
pubFlow.forEach((item: any) => {
|
|
|
|
pubFlow.forEach((item: any) => {
|
|
|
|
result.push({
|
|
|
|
result.push({
|
|
|
|
...item,
|
|
|
|
...item,
|
|
|
|
type: 'pubFlow',
|
|
|
|
type: 'pubFlow'
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1019,3 +951,22 @@ const getCurrentProjectStoreData = () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据节点类型获取对应的节点组件
|
|
|
|
|
|
|
|
const getNodeComponent = (nodeType: string) => {
|
|
|
|
|
|
|
|
switch (nodeType) {
|
|
|
|
|
|
|
|
case 'BASIC':
|
|
|
|
|
|
|
|
case 'SUB':
|
|
|
|
|
|
|
|
return BasicNode;
|
|
|
|
|
|
|
|
case 'SWITCH':
|
|
|
|
|
|
|
|
return SwitchNode;
|
|
|
|
|
|
|
|
case 'IMAGE':
|
|
|
|
|
|
|
|
return ImageNode;
|
|
|
|
|
|
|
|
case 'CODE':
|
|
|
|
|
|
|
|
return CodeNode;
|
|
|
|
|
|
|
|
case 'REST':
|
|
|
|
|
|
|
|
return RestNode;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return LocalNode;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|