From 2ad7536eb7dafb4a0cc2dce491a5262fd55c55c5 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sat, 18 Mar 2023 21:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=85=B3=E8=81=94=E7=BA=BF?= =?UTF-8?q?=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/AssociativeLine.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/simple-mind-map/src/AssociativeLine.js b/simple-mind-map/src/AssociativeLine.js index 81e63efa..153feb68 100644 --- a/simple-mind-map/src/AssociativeLine.js +++ b/simple-mind-map/src/AssociativeLine.js @@ -79,14 +79,15 @@ class AssociativeLine { null, cur => { if (!cur) return + let data = cur.nodeData.data if ( - cur.nodeData.data.associativeLineTargets && - cur.nodeData.data.associativeLineTargets.length > 0 + data.associativeLineTargets && + data.associativeLineTargets.length > 0 ) { - nodeToIds.set(cur, cur.nodeData.data.associativeLineTargets) + nodeToIds.set(cur, data.associativeLineTargets) } - if (cur.nodeData.data.id) { - idToNode.set(cur.nodeData.data.id, cur) + if (data.id) { + idToNode.set(data.id, cur) } }, () => {}, @@ -106,7 +107,9 @@ class AssociativeLine { // 绘制连接线 drawLine(startPoint, endPoint, node, toNode) { let { associativeLineWidth, associativeLineColor, associativeLineActiveWidth, associativeLineActiveColor } = this.mindMap.themeConfig + // 箭头 this.markerPath.stroke({ color: associativeLineColor }).fill({ color: associativeLineColor }) + // 路径 let pathStr = this.cubicBezierPath( startPoint.x, startPoint.y, @@ -153,12 +156,13 @@ class AssociativeLine { // 创建连接线 createLine(fromNode) { + let { associativeLineWidth, associativeLineColor } = this.mindMap.themeConfig if (this.isCreatingLine || !fromNode) return this.isCreatingLine = true this.creatingStartNode = fromNode this.creatingLine = this.draw.path() this.creatingLine - .stroke({ width: 2, color: 'rgb(51, 51, 51)', dasharray: [6, 4] }) + .stroke({ width: associativeLineWidth, color: associativeLineColor, dasharray: [6, 4] }) .fill({ color: 'none' }) this.creatingLine.marker('end', this.marker) } @@ -233,16 +237,12 @@ class AssociativeLine { this.mindMap.execCommand('SET_NODE_DATA', fromNode, { associativeLineTargets: list }) - let [startPoint, endPoint] = this.computeNodePoints(fromNode, toNode) - this.drawLine(startPoint, endPoint, fromNode, toNode) } // 删除连接线 removeLine() { if (!this.activeLine) return - let [path, clickPath, node, toNode] = this.activeLine - path.remove() - clickPath.remove() + let [, , node, toNode] = this.activeLine let id = toNode.nodeData.data.id this.mindMap.execCommand('SET_NODE_DATA', node, { associativeLineTargets: node.nodeData.data.associativeLineTargets.filter(