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