From a0f56473eec10f83082dc3d451bb664e7c3ce46d Mon Sep 17 00:00:00 2001 From: wanglin2 <1013335014@qq.com> Date: Tue, 28 Nov 2023 17:36:13 +0800 Subject: [PATCH] =?UTF-8?q?Fix=EF=BC=9A=E4=BF=AE=E5=A4=8D=E6=89=B9?= =?UTF-8?q?=E9=87=8F=E6=89=A7=E8=A1=8C=E7=B1=BB=E6=B7=BB=E5=8A=A0=E5=90=8C?= =?UTF-8?q?=E5=90=8D=E4=BB=BB=E5=8A=A1=E6=97=B6=E4=BB=BB=E5=8A=A1=E6=9C=AA?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=BA=E6=9C=80=E5=B0=8F=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- simple-mind-map/src/utils/BatchExecution.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/simple-mind-map/src/utils/BatchExecution.js b/simple-mind-map/src/utils/BatchExecution.js index fcdfb735..f30c3740 100644 --- a/simple-mind-map/src/utils/BatchExecution.js +++ b/simple-mind-map/src/utils/BatchExecution.js @@ -12,6 +12,7 @@ class BatchExecution { // 添加任务 push(name, fn) { if (this.has[name]) { + this.replaceTask(name, fn) return } this.has[name] = true @@ -22,6 +23,19 @@ class BatchExecution { this.nextTick() } + // 替换任务 + replaceTask(name, fn) { + const index = this.queue.findIndex(item => { + return item.name === name + }) + if (index !== -1) { + this.queue[index] = { + name, + fn + } + } + } + // 执行队列 flush() { let fns = this.queue.slice(0)