mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: rkey cached
This commit is contained in:
parent
ad251a7682
commit
a566dd390b
@ -1,6 +1,6 @@
|
|||||||
import { sleep } from '@/common/utils/helper';
|
import { sleep } from '@/common/utils/helper';
|
||||||
|
|
||||||
type AsyncQueueTask = (() => void) | Promise<void> ;
|
type AsyncQueueTask = (() => void) | (()=>Promise<void>);
|
||||||
|
|
||||||
|
|
||||||
export class AsyncQueue {
|
export class AsyncQueue {
|
||||||
@ -8,20 +8,22 @@ export class AsyncQueue {
|
|||||||
|
|
||||||
public addTask(task: AsyncQueueTask) {
|
public addTask(task: AsyncQueueTask) {
|
||||||
this.tasks.push(task);
|
this.tasks.push(task);
|
||||||
|
// console.log('addTask', this.tasks.length);
|
||||||
if (this.tasks.length === 1) {
|
if (this.tasks.length === 1) {
|
||||||
this.runQueue().then().catch(()=>{});
|
this.runQueue().then().catch(()=>{});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async runQueue() {
|
private async runQueue() {
|
||||||
|
// console.log('runQueue', this.tasks.length);
|
||||||
while (this.tasks.length > 0) {
|
while (this.tasks.length > 0) {
|
||||||
const task = this.tasks[0];
|
const task = this.tasks[0];
|
||||||
|
// console.log('typeof task', typeof task);
|
||||||
try {
|
try {
|
||||||
if (task instanceof Promise) {
|
const taskRet = task();
|
||||||
await task;
|
// console.log('type of taskRet', typeof taskRet, taskRet);
|
||||||
}
|
if (taskRet instanceof Promise) {
|
||||||
else{
|
await taskRet;
|
||||||
task();
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user