fix(web): update add node

This commit is contained in:
zhaoying
2026-01-14 18:51:33 +08:00
parent 617ff706bc
commit 0d9cdd5039
5 changed files with 111 additions and 28 deletions

View File

@@ -235,7 +235,7 @@ export const useWorkflowGraph = ({
if (parentNode) {
const addedChild = graphRef.current?.addNode(childNode)
if (addedChild) {
parentNode.addChild(addedChild)
parentNode.insertChild(addedChild)
}
}
}
@@ -275,6 +275,11 @@ export const useWorkflowGraph = ({
}, 100)
}
if (edges.length) {
// 计算loop和iteration类型节点的数量
const loopIterationCount = nodes.filter(node =>
node.type === 'loop' || node.type === 'iteration'
).length;
// 去重处理对于if-else和question-classifier节点不同连接桩允许连接到相同节点
const uniqueEdges = edges.filter((edge, index, arr) => {
return arr.findIndex(e => {
@@ -349,7 +354,7 @@ export const useWorkflowGraph = ({
},
},
},
zIndex: targetCell.getData()?.cycle ? 3 : 0
zIndex: loopIterationCount
}
return edgeConfig
@@ -725,7 +730,6 @@ export const useWorkflowGraph = ({
},
},
},
zIndex: 0,
});
},
validateConnection({ sourceCell, targetCell, targetMagnet }) {
@@ -762,9 +766,8 @@ export const useWorkflowGraph = ({
},
embedding: {
enabled: true,
validate (this, { parent }) {
const parentData = parent.getData()
return parentData.type === 'iteration' || parentData.type === 'loop'
validate (this) {
return false
}
},
translating: {