Feat:只读模式下节点实例不保存nodeDataSnapshot数据

This commit is contained in:
街角小林
2025-03-26 11:56:57 +08:00
parent a55afdd252
commit 43c41e7ed2

View File

@@ -475,8 +475,12 @@ class MindMapNode {
return
}
this.updateNodeActiveClass()
const { alwaysShowExpandBtn, notShowExpandBtn, isShowCreateChildBtnIcon } =
this.mindMap.opt
const {
alwaysShowExpandBtn,
notShowExpandBtn,
isShowCreateChildBtnIcon,
readonly
} = this.mindMap.opt
const childrenLength = this.getChildrenLength()
// 不显示展开收起按钮则不需要处理
if (!notShowExpandBtn) {
@@ -522,7 +526,7 @@ class MindMapNode {
// 更新节点位置
const t = this.group.transform()
// 保存一份当前节点数据快照
this.nodeDataSnapshot = JSON.stringify(this.getData())
this.nodeDataSnapshot = readonly ? '' : JSON.stringify(this.getData())
// 节点位置变化才更新,因为即使值没有变化属性设置操作也是耗时的
if (this.left !== t.translateX || this.top !== t.translateY) {
this.group.translate(this.left - t.translateX, this.top - t.translateY)