Feature:添加最大历史记录数限制

This commit is contained in:
wanglin2 2023-04-20 16:10:25 +08:00
parent 2be97cc1a0
commit 077478d654
2 changed files with 7 additions and 1 deletions

View File

@ -101,7 +101,9 @@ const defaultOpt = {
// 节点备注浮层的z-index
nodeNoteTooltipZIndex: 3000,
// 是否在点击了画布外的区域时结束节点文本的编辑状态
isEndNodeTextEditOnClickOuter: true
isEndNodeTextEditOnClickOuter: true,
// 最大历史记录数
maxHistoryCount: 1000
}
// 思维导图

View File

@ -84,6 +84,10 @@ class Command {
// 删除当前历史指针后面的数据
this.history = this.history.slice(0, this.activeHistoryIndex + 1)
this.history.push(simpleDeepClone(data))
// 历史记录数超过最大数量
if (this.history.length > this.mindMap.opt.maxHistoryCount) {
this.history.shift()
}
this.activeHistoryIndex = this.history.length - 1
this.mindMap.emit('data_change', this.removeDataUid(data))
this.mindMap.emit(