Feat:指定时间内只允许添加一次历史记录,避免添加没有必要的中间状态

This commit is contained in:
wanglin2 2023-10-18 10:45:25 +08:00
parent baf36acc97
commit b6d91ec07a
2 changed files with 9 additions and 3 deletions

View File

@ -217,5 +217,7 @@ export const defaultOpt = {
defaultGeneralizationText: '概要',
// 粘贴文本的方式创建新节点时,控制是否按换行自动分割节点,即如果存在换行,那么会根据换行创建多个节点,否则只会创建一个节点
// 可以传递一个函数返回promiseresolve代表根据换行分割reject代表忽略换行
handleIsSplitByWrapOnPasteCreateNewNode: null
handleIsSplitByWrapOnPasteCreateNewNode: null,
// 多少时间内只允许添加一次历史记录避免添加没有必要的中间状态单位ms
addHistoryTime: 100
}

View File

@ -1,4 +1,4 @@
import { copyRenderTree, simpleDeepClone, nextTick } from '../../utils'
import { copyRenderTree, simpleDeepClone, throttle } from '../../utils'
// 命令类
class Command {
@ -11,7 +11,11 @@ class Command {
this.activeHistoryIndex = 0
// 注册快捷键
this.registerShortcutKeys()
this.addHistory = nextTick(this.addHistory, this)
this.addHistory = throttle(
this.addHistory,
this.mindMap.opt.addHistoryTime,
this
)
}
// 清空历史数据