diff --git a/simple-mind-map/index.js b/simple-mind-map/index.js index fb5f002c..da5beaaa 100644 --- a/simple-mind-map/index.js +++ b/simple-mind-map/index.js @@ -101,7 +101,9 @@ const defaultOpt = { // 节点备注浮层的z-index nodeNoteTooltipZIndex: 3000, // 是否在点击了画布外的区域时结束节点文本的编辑状态 - isEndNodeTextEditOnClickOuter: true + isEndNodeTextEditOnClickOuter: true, + // 最大历史记录数 + maxHistoryCount: 1000 } // 思维导图 diff --git a/simple-mind-map/src/Command.js b/simple-mind-map/src/Command.js index 7b49ef0d..b1c35c57 100644 --- a/simple-mind-map/src/Command.js +++ b/simple-mind-map/src/Command.js @@ -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(