From c8f5c9468348af03be1cbfc6cb0c942175256850 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sat, 17 Sep 2022 15:09:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8A=82=E7=82=B9=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E7=BA=BF=E6=9D=A1=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/Node.js | 15 +++++++-------- .../src/layouts/CatalogOrganization.js | 7 ++++++- simple-mind-map/src/layouts/LogicalStructure.js | 3 ++- simple-mind-map/src/layouts/MindMap.js | 3 ++- .../src/layouts/OrganizationStructure.js | 5 ++++- 5 files changed, 21 insertions(+), 12 deletions(-) diff --git a/simple-mind-map/src/Node.js b/simple-mind-map/src/Node.js index ca26e82c..7b1e7aef 100644 --- a/simple-mind-map/src/Node.js +++ b/simple-mind-map/src/Node.js @@ -861,10 +861,9 @@ class Node { this._lines = this._lines.slice(0, childrenLen) } // 画线 - this.renderer.layout.renderLine(this, this._lines) - // 添加样式 - this._lines.forEach((line) => { - this.styleLine(line) + this.renderer.layout.renderLine(this, this._lines, (line, node) => { + // 添加样式 + this.styleLine(line, node) }) } @@ -874,10 +873,10 @@ class Node { * @Date: 2022-09-17 12:41:29 * @Desc: 设置连线样式 */ - styleLine(line) { - let width = this.getSelfInhertStyle('lineWidth') || this.getStyle('lineWidth', true) - let color = this.getSelfInhertStyle('lineColor') || this.getStyle('lineColor', true) - let dasharray = this.getSelfInhertStyle('lineDasharray') || this.getStyle('lineDasharray', true) + styleLine(line, node) { + let width = node.getSelfInhertStyle('lineWidth') || node.getStyle('lineWidth', true) + let color = node.getSelfInhertStyle('lineColor') || node.getStyle('lineColor', true) + let dasharray = node.getSelfInhertStyle('lineDasharray') || node.getStyle('lineDasharray', true) this.style.line(line, { width, color, diff --git a/simple-mind-map/src/layouts/CatalogOrganization.js b/simple-mind-map/src/layouts/CatalogOrganization.js index 38536840..ec1a4fbb 100644 --- a/simple-mind-map/src/layouts/CatalogOrganization.js +++ b/simple-mind-map/src/layouts/CatalogOrganization.js @@ -231,7 +231,7 @@ class CatalogOrganization extends Base { * @Date: 2021-04-11 14:42:48 * @Desc: 绘制连线,连接该节点到其子节点 */ - renderLine(node, lines) { + renderLine(node, lines, style) { if (node.children.length <= 0) { return []; } @@ -263,6 +263,7 @@ class CatalogOrganization extends Base { let path = `M ${x2},${y1 + s1} L ${x2},${y1 + s1 > y2 ? y2 + item.height : y2}` // 竖线 lines[index].plot(path) + style && style(lines[index], item) }) minx = Math.min(minx, x1) maxx = Math.max(maxx, x1) @@ -271,12 +272,14 @@ class CatalogOrganization extends Base { node.style.line(line1) line1.plot(`M ${x1},${y1} L ${x1},${y1 + s1}`) node._lines.push(line1) + style && style(line1, node) // 水平线 if (len > 0) { let lin2 = this.draw.path() node.style.line(lin2) lin2.plot(`M ${minx},${y1 + s1} L ${maxx},${y1 + s1}`) node._lines.push(lin2) + style && style(lin2, node) } } else { // 非根节点 @@ -320,6 +323,7 @@ class CatalogOrganization extends Base { path = `M ${x2},${y2} L ${_left},${y2}` } lines[index].plot(path) + style && style(lines[index], item) }) // 竖线 if (len > 0) { @@ -333,6 +337,7 @@ class CatalogOrganization extends Base { lin2.show() } node._lines.push(lin2) + style && style(lin2, node) } } } diff --git a/simple-mind-map/src/layouts/LogicalStructure.js b/simple-mind-map/src/layouts/LogicalStructure.js index faafbc45..09cca8e3 100644 --- a/simple-mind-map/src/layouts/LogicalStructure.js +++ b/simple-mind-map/src/layouts/LogicalStructure.js @@ -146,7 +146,7 @@ class LogicalStructure extends Base { * @Date: 2021-04-11 14:42:48 * @Desc: 绘制连线,连接该节点到其子节点 */ - renderLine(node, lines) { + renderLine(node, lines, style) { if (node.children.length <= 0) { return []; } @@ -169,6 +169,7 @@ class LogicalStructure extends Base { path = this.cubicBezierPath(x1, y1, x2, y2) } lines[index].plot(path) + style && style(lines[index], item) }) } diff --git a/simple-mind-map/src/layouts/MindMap.js b/simple-mind-map/src/layouts/MindMap.js index faac21e3..1b4c4fb6 100644 --- a/simple-mind-map/src/layouts/MindMap.js +++ b/simple-mind-map/src/layouts/MindMap.js @@ -182,7 +182,7 @@ class MindMap extends Base { * @Date: 2021-04-11 14:42:48 * @Desc: 绘制连线,连接该节点到其子节点 */ - renderLine(node, lines) { + renderLine(node, lines, style) { if (node.children.length <= 0) { return []; } @@ -205,6 +205,7 @@ class MindMap extends Base { path = this.cubicBezierPath(x1, y1, x2, y2) } lines[index].plot(path) + style && style(lines[index], item) }) } diff --git a/simple-mind-map/src/layouts/OrganizationStructure.js b/simple-mind-map/src/layouts/OrganizationStructure.js index cdb6e396..481eac4c 100644 --- a/simple-mind-map/src/layouts/OrganizationStructure.js +++ b/simple-mind-map/src/layouts/OrganizationStructure.js @@ -147,7 +147,7 @@ class OrganizationStructure extends Base { * @Date: 2021-04-11 14:42:48 * @Desc: 绘制连线,连接该节点到其子节点 */ - renderLine(node, lines) { + renderLine(node, lines, style) { if (node.children.length <= 0) { return []; } @@ -177,6 +177,7 @@ class OrganizationStructure extends Base { } let path = `M ${x2},${y1 + s1} L ${x2},${y2}` lines[index].plot(path) + style && style(lines[index], item) }) minx = Math.min(x1, minx) maxx = Math.max(x1, maxx) @@ -186,12 +187,14 @@ class OrganizationStructure extends Base { expandBtnSize = len > 0 && !isRoot ? expandBtnSize : 0 line1.plot(`M ${x1},${y1 + expandBtnSize} L ${x1},${y1 + s1}`) node._lines.push(line1) + style && style(line1, node) // 水平线 if (len > 0) { let lin2 = this.draw.path() node.style.line(lin2) lin2.plot(`M ${minx},${y1 + s1} L ${maxx},${y1 + s1}`) node._lines.push(lin2) + style && style(lin2, node) } }