代码优化:将调用render类的setNodeData方法的地方改为调用SET_NODE_DATA命令

This commit is contained in:
wanglin2 2023-10-13 15:26:00 +08:00
parent 21053c43c9
commit 5079ad2190
2 changed files with 22 additions and 14 deletions

View File

@ -994,9 +994,13 @@ class Render {
if (isAppointNodes) list.splice(i, 1) if (isAppointNodes) list.splice(i, 1)
if (node.isGeneralization) { if (node.isGeneralization) {
// 删除概要节点 // 删除概要节点
this.setNodeData(node.generalizationBelongNode, { this.mindMap.execCommand(
generalization: null 'SET_NODE_DATA',
}) node.generalizationBelongNode,
{
generalization: null
}
)
node.generalizationBelongNode.update() node.generalizationBelongNode.update()
this.removeNodeFromActiveList(node) this.removeNodeFromActiveList(node)
i-- i--
@ -1035,9 +1039,13 @@ class Render {
let node = list[i] let node = list[i]
if (node.isGeneralization) { if (node.isGeneralization) {
// 删除概要节点 // 删除概要节点
this.setNodeData(node.generalizationBelongNode, { this.mindMap.execCommand(
generalization: null 'SET_NODE_DATA',
}) node.generalizationBelongNode,
{
generalization: null
}
)
node.generalizationBelongNode.update() node.generalizationBelongNode.update()
} else { } else {
const parent = node.parent const parent = node.parent
@ -1215,7 +1223,7 @@ class Render {
// 设置节点是否激活 // 设置节点是否激活
setNodeActive(node, active) { setNodeActive(node, active) {
this.setNodeData(node, { this.mindMap.execCommand('SET_NODE_DATA', node, {
isActive: active isActive: active
}) })
if (node.group) { if (node.group) {
@ -1231,7 +1239,7 @@ class Render {
// 设置节点是否展开 // 设置节点是否展开
setNodeExpand(node, expand) { setNodeExpand(node, expand) {
this.setNodeData(node, { this.mindMap.execCommand('SET_NODE_DATA', node, {
expand expand
}) })
if (expand) { if (expand) {
@ -1405,7 +1413,7 @@ class Render {
if (node.nodeData.data.generalization || node.isRoot) { if (node.nodeData.data.generalization || node.isRoot) {
return return
} }
this.setNodeData(node, { this.mindMap.execCommand('SET_NODE_DATA', node, {
generalization: data || { generalization: data || {
text: '概要' text: '概要'
} }
@ -1424,7 +1432,7 @@ class Render {
if (!node.nodeData.data.generalization) { if (!node.nodeData.data.generalization) {
return return
} }
this.setNodeData(node, { this.mindMap.execCommand('SET_NODE_DATA', node, {
generalization: null generalization: null
}) })
node.update() node.update()
@ -1436,7 +1444,7 @@ class Render {
setNodeCustomPosition(node, left = undefined, top = undefined) { setNodeCustomPosition(node, left = undefined, top = undefined) {
let nodeList = [node] || this.activeNodeList let nodeList = [node] || this.activeNodeList
nodeList.forEach(item => { nodeList.forEach(item => {
this.setNodeData(item, { this.mindMap.execCommand('SET_NODE_DATA', item, {
customLeft: left, customLeft: left,
customTop: top customTop: top
}) })
@ -1451,7 +1459,7 @@ class Render {
node => { node => {
node.customLeft = undefined node.customLeft = undefined
node.customTop = undefined node.customTop = undefined
this.setNodeData(node, { this.mindMap.execCommand('SET_NODE_DATA', node, {
customLeft: undefined, customLeft: undefined,
customTop: undefined customTop: undefined
}) })
@ -1498,7 +1506,7 @@ class Render {
// 设置节点数据,并判断是否渲染 // 设置节点数据,并判断是否渲染
setNodeDataRender(node, data, notRender = false) { setNodeDataRender(node, data, notRender = false) {
this.setNodeData(node, data) this.mindMap.execCommand('SET_NODE_DATA', node, data)
let changed = node.reRender() let changed = node.reRender()
if (changed) { if (changed) {
if (node.isGeneralization) { if (node.isGeneralization) {

View File

@ -494,7 +494,7 @@ class RichText {
}) })
} else { } else {
let data = this.richTextStyleToNormalStyle(config) let data = this.richTextStyleToNormalStyle(config)
this.mindMap.renderer.setNodeData(this.node, data) this.mindMap.execCommand('SET_NODE_DATA', this.node, data)
} }
} }