Fix:修复批量执行类添加同名任务时任务未更新为最小任务的问题
This commit is contained in:
parent
51dcb1f54f
commit
a0f56473ee
@ -12,6 +12,7 @@ class BatchExecution {
|
|||||||
// 添加任务
|
// 添加任务
|
||||||
push(name, fn) {
|
push(name, fn) {
|
||||||
if (this.has[name]) {
|
if (this.has[name]) {
|
||||||
|
this.replaceTask(name, fn)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.has[name] = true
|
this.has[name] = true
|
||||||
@ -22,6 +23,19 @@ class BatchExecution {
|
|||||||
this.nextTick()
|
this.nextTick()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 替换任务
|
||||||
|
replaceTask(name, fn) {
|
||||||
|
const index = this.queue.findIndex(item => {
|
||||||
|
return item.name === name
|
||||||
|
})
|
||||||
|
if (index !== -1) {
|
||||||
|
this.queue[index] = {
|
||||||
|
name,
|
||||||
|
fn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 执行队列
|
// 执行队列
|
||||||
flush() {
|
flush() {
|
||||||
let fns = this.queue.slice(0)
|
let fns = this.queue.slice(0)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user