From b6d91ec07a3b3bc1aefd9c814290046c612e0193 Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Wed, 18 Oct 2023 10:45:25 +0800 Subject: [PATCH] =?UTF-8?q?Feat=EF=BC=9A=E6=8C=87=E5=AE=9A=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=86=85=E5=8F=AA=E5=85=81=E8=AE=B8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E4=B8=80=E6=AC=A1=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95=EF=BC=8C?= =?UTF-8?q?=E9=81=BF=E5=85=8D=E6=B7=BB=E5=8A=A0=E6=B2=A1=E6=9C=89=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E4=B8=AD=E9=97=B4=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/constants/defaultOptions.js | 4 +++- simple-mind-map/src/core/command/Command.js | 8 ++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/simple-mind-map/src/constants/defaultOptions.js b/simple-mind-map/src/constants/defaultOptions.js index 0050ff1c..d658fc83 100644 --- a/simple-mind-map/src/constants/defaultOptions.js +++ b/simple-mind-map/src/constants/defaultOptions.js @@ -217,5 +217,7 @@ export const defaultOpt = { defaultGeneralizationText: '概要', // 粘贴文本的方式创建新节点时,控制是否按换行自动分割节点,即如果存在换行,那么会根据换行创建多个节点,否则只会创建一个节点 // 可以传递一个函数,返回promise,resolve代表根据换行分割,reject代表忽略换行 - handleIsSplitByWrapOnPasteCreateNewNode: null + handleIsSplitByWrapOnPasteCreateNewNode: null, + // 多少时间内只允许添加一次历史记录,避免添加没有必要的中间状态,单位:ms + addHistoryTime: 100 } diff --git a/simple-mind-map/src/core/command/Command.js b/simple-mind-map/src/core/command/Command.js index 8b59b98d..d1638dee 100644 --- a/simple-mind-map/src/core/command/Command.js +++ b/simple-mind-map/src/core/command/Command.js @@ -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 + ) } // 清空历史数据