mirror of
https://github.com/wanglin2/mind-map.git
synced 2026-02-17 22:08:25 +08:00
Fix:修复批量执行类添加同名任务时任务未更新为最小任务的问题
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user