From 6a3f016920e441e78fddf88088772baa4aab1062 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Sat, 24 Sep 2022 20:13:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=9E=E7=BA=BF=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E6=B7=B1=E5=BA=A6=E6=9B=B4=E6=96=B0=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/Node.js | 10 ++++++---- simple-mind-map/src/Render.js | 7 ++++++- simple-mind-map/src/themes/default.js | 4 +++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/simple-mind-map/src/Node.js b/simple-mind-map/src/Node.js index 9db807db..2f5b615b 100644 --- a/simple-mind-map/src/Node.js +++ b/simple-mind-map/src/Node.js @@ -845,7 +845,7 @@ class Node { * @Date: 2021-04-10 22:01:53 * @Desc: 连线 */ - renderLine() { + renderLine(deep = false) { if (this.nodeData.data.expand === false) { return } @@ -867,9 +867,11 @@ class Node { // 添加样式 this.styleLine(line, node) }) - // 和父级的连线也需要更新 - if (this.parent) { - this.parent.renderLine() + // 子级的连线也需要更新 + if (deep && this.children && this.children.length > 0) { + this.children.forEach((item) => { + item.renderLine(deep) + }) } } diff --git a/simple-mind-map/src/Render.js b/simple-mind-map/src/Render.js index a6eb7c22..14f710eb 100644 --- a/simple-mind-map/src/Render.js +++ b/simple-mind-map/src/Render.js @@ -5,7 +5,8 @@ import CatalogOrganization from './layouts/CatalogOrganization' import OrganizationStructure from './layouts/OrganizationStructure' import TextEdit from './TextEdit' import { copyNodeTree, simpleDeepClone, walk } from './utils' -import { shapeList } from './Shape'; +import { shapeList } from './Shape' +import { lineStyleProps } from './themes/default' // 布局列表 const layouts = { @@ -734,6 +735,10 @@ class Render { } } this.setNodeDataRender(node, data) + // 更新了连线的样式 + if (lineStyleProps.includes(prop)) { + (node.parent || node).renderLine(true) + } } /** diff --git a/simple-mind-map/src/themes/default.js b/simple-mind-map/src/themes/default.js index d901f784..78354999 100644 --- a/simple-mind-map/src/themes/default.js +++ b/simple-mind-map/src/themes/default.js @@ -127,4 +127,6 @@ export default { // 支持激活样式的属性 // 简单来说,会改变节点大小的都不支持在激活时设置,为了性能考虑,节点切换激活态时不会重新计算节点大小 -export const supportActiveStyle = ['fillColor', 'color', 'fontWeight', 'fontStyle', 'borderColor', 'borderWidth', 'borderDasharray', 'borderRadius', 'textDecoration'] \ No newline at end of file +export const supportActiveStyle = ['fillColor', 'color', 'fontWeight', 'fontStyle', 'borderColor', 'borderWidth', 'borderDasharray', 'borderRadius', 'textDecoration'] + +export const lineStyleProps = ['lineColor', 'lineDasharray', 'lineWidth'] \ No newline at end of file