// 加载状态的逻辑管理 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 = []; } } } });