Skip to content

Commit 6975654

Browse files
committed
动作序列函数支持非异步函数
1 parent 7cf9e20 commit 6975654

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

core/Page.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -563,12 +563,19 @@ export default class Page extends EventEmitter {
563563
const matchTimeNodes = Object.keys(this.timeActions)
564564
.map(Number)
565565
.sort()
566-
.filter(time => currentTime >= time)
567-
.shift();
568-
const timeAction = this.timeActions[matchTimeNodes]
569-
timeAction && await timeAction(this)
570-
.catch(err => this.#emitError(err))
571-
.finally(() => delete this.timeActions[matchTimeNodes]);
566+
.find(time => currentTime >= time);
567+
if(!matchTimeNodes)
568+
return;
569+
const timeAction = this.timeActions[matchTimeNodes];
570+
delete this.timeActions[matchTimeNodes]
571+
try {
572+
const result = timeAction(this);
573+
if(result instanceof Promise)
574+
await result.catch(err => this.#emitError(err))
575+
}
576+
catch(err) {
577+
this.#emitError(err)
578+
}
572579
}
573580

574581
/**

0 commit comments

Comments
 (0)