| 123456789101112131415161718192021222324252627282930313233343536373839 |
- import load from "@/utils/loading";
- // isLoading
- // let times = store.getters.loadCount;
- let timer = null;
- export async function showFullScreenLoading(store) {
- if (store.getters.loadCount === 0 && !store.getters.isLoading) {
- await store.dispatch("app/setLoadCount", 1);
- await store.dispatch("app/setLoadStatus", true);
- load.startLoading();
- } else {
- if (store.getters.loadCount < 0) {
- await store.dispatch("app/resetLoadCount");
- await store.dispatch("app/setLoadCount", 1);
- clearTimeout(timer);
- timer = null;
- } else {
- await store.dispatch("app/setLoadCount", 1);
- clearTimeout(timer);
- timer = null;
- }
- }
- }
- export async function tryHideFullScreenLoading(store) {
- // console.log(store.getters.loadCount)
- await store.dispatch("app/setLoadCount", -1);
- if (store.getters.loadCount <= 0 && store.getters.isLoading) {
- if (timer) return;
- timer = setTimeout(async () => {
- await store.dispatch("app/resetLoadCount");
- await store.dispatch("app/setLoadStatus", false);
- load.endLoading();
- clearTimeout(timer);
- timer = null;
- }, 100);
- }
- }
|