wangzhibo
2026-07-16 b57020623cf0c946706573bf102e548c3a544423
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export const Loading = {
    resolve: null as (() => void) | null,
    next: null as Promise<void> | null,
 
    async set(list: Promise<any>[]) {
        try {
            await Promise.all(list);
        } catch (e) {
            console.error('[Loading] Error: ', e);
        }
 
        if (this.resolve) {
            this.resolve();
        }
    },
 
    async wait() {
        if (this.next) {
            return this.next;
        }
        return Promise.resolve();
    },
 
    close() {
        const el = document.getElementById('Loading');
 
        if (el) {
            setTimeout(() => {
                el.classList.add('is-hide');
            }, 0);
        }
    }
};
 
Loading.next = new Promise<void>(resolve => {
    Loading.resolve = resolve;
});