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
| // 加载状态的逻辑管理
|
| import { defineStore } from 'pinia';
|
| export const useLoadingStore = defineStore('loading', {
| state: () => {
| return {
| loadingStatus: []
| };
| },
| actions: {
| pushLoading(func) {
| const timeout = setTimeout(func, 3000);
| this.loadingStatus.push({ t: timeout, f: func });
| },
| clearLoading() {
| if (this.loadingStatus.length > 0) {
| this.loadingStatus.forEach((obj) => {
| clearTimeout(obj.t)
| obj.f()
| });
| this.loadingStatus = [];
| }
| }
| }
| });
|
|