1
This commit is contained in:
parent
3038debaef
commit
b98c801b9f
@ -953,14 +953,32 @@ const WorkflowDesign: React.FC = () => {
|
||||
const sourceNode = nodeMap.get(edge.from);
|
||||
const targetNode = nodeMap.get(edge.to);
|
||||
if (sourceNode && targetNode) {
|
||||
// 根据节点类型获取正确的端口组
|
||||
const getPortByGroup = (node: any, group: string) => {
|
||||
const ports = node.getPorts();
|
||||
const port = ports.find((p: any) => p.group === group);
|
||||
return port?.id;
|
||||
};
|
||||
|
||||
// 获取源节点的输出端口(一定是out组)
|
||||
const sourcePort = getPortByGroup(sourceNode, 'out');
|
||||
|
||||
// 获取目标节点的输入端口(一定是in组)
|
||||
const targetPort = getPortByGroup(targetNode, 'in');
|
||||
|
||||
if (!sourcePort || !targetPort) {
|
||||
console.error('无法找到正确的端口:', edge);
|
||||
return;
|
||||
}
|
||||
|
||||
graphInstance.addEdge({
|
||||
source: {
|
||||
cell: sourceNode.id,
|
||||
port: edge.fromPort || sourceNode.getPorts()[0].id, // 使用指定的端口或默认第一个端口
|
||||
port: sourcePort,
|
||||
},
|
||||
target: {
|
||||
cell: targetNode.id,
|
||||
port: edge.toPort || targetNode.getPorts()[0].id, // 使用指定的端口或默认第一个端口
|
||||
port: targetPort,
|
||||
},
|
||||
attrs: {
|
||||
line: {
|
||||
@ -972,42 +990,6 @@ const WorkflowDesign: React.FC = () => {
|
||||
},
|
||||
},
|
||||
},
|
||||
tools: [
|
||||
{
|
||||
name: 'source-arrowhead',
|
||||
args: {
|
||||
attrs: {
|
||||
fill: '#fff',
|
||||
stroke: '#5F95FF',
|
||||
strokeWidth: 1,
|
||||
d: 'M 0 -6 L -8 0 L 0 6 Z',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'target-arrowhead',
|
||||
args: {
|
||||
attrs: {
|
||||
fill: '#fff',
|
||||
stroke: '#5F95FF',
|
||||
strokeWidth: 1,
|
||||
d: 'M 0 -6 L 8 0 L 0 6 Z',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
connector: {
|
||||
name: 'rounded',
|
||||
args: {
|
||||
radius: 8
|
||||
}
|
||||
},
|
||||
router: {
|
||||
name: 'manhattan',
|
||||
args: {
|
||||
padding: 1
|
||||
}
|
||||
},
|
||||
labels: [{
|
||||
attrs: {label: {text: edge.name || ''}}
|
||||
}]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user