fix: pin edge endpoints to node edge midpoints for clean orthogonal routing

This commit is contained in:
2026-06-12 13:28:44 +08:00
parent 5e81c42c40
commit 04285162c9

View File

@@ -155,13 +155,26 @@ function buildFlow(root: PlayerTreeNode) {
}
})
const nodeMap = new Map(resultNodes.map((n) => [n.id, n]))
const resultEdges: FlowEdge[] = dagreEdges.map((e) => {
const edge = g.edge(e.from, e.to)
const pts = edge.points || []
if (pts.length >= 2) {
const src = nodeMap.get(e.from)
const dst = nodeMap.get(e.to)
if (src) {
pts[0] = { x: src.x + src.w, y: src.y + src.h / 2 }
}
if (dst) {
pts[pts.length - 1] = { x: dst.x, y: dst.y + dst.h / 2 }
}
}
return {
from: e.from,
to: e.to,
visited: e.visited,
points: edge.points || [],
points: pts,
}
})