qin
2025-03-31 8371d124f9ea5c5e898818784a2fd5e669fa7d83
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
38
39
import { nextTick } from 'vue';
import '@/styles/loading.scss';
 
/**
 * 页面全局 Loading
 * @method start 创建 loading
 * @method done 移除 loading
 */
export const NextLoading = {
    // 创建 loading
    start: () => {
        const bodys: Element = document.body;
        const div = <HTMLElement>document.createElement('div');
        div.setAttribute('class', 'loader-div');
        const htmls = `
            <div class='loader-next'>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
            </div>
        `;
        div.innerHTML = htmls;
        bodys.insertBefore(div, bodys.childNodes[0]);
        window.nextLoading = true;
    },
    // 移除 loading
    done: (time = 0) => {
        nextTick(() => {
            setTimeout(() => {
                window.nextLoading = false;
                const el = <HTMLElement>document.querySelector('.loader-div');
                el?.parentNode?.removeChild(el);
            }, time);
        });
    },
};