|
@@ -17,11 +17,14 @@ import { lifeHook } from "./request/state";
|
|
|
|
|
|
let loading: ReturnType<typeof ElLoading.service> | null = null;
|
|
let loading: ReturnType<typeof ElLoading.service> | null = null;
|
|
let timeout: ReturnType<typeof setTimeout>;
|
|
let timeout: ReturnType<typeof setTimeout>;
|
|
|
|
+let exixts = false;
|
|
|
|
|
|
lifeHook.push({
|
|
lifeHook.push({
|
|
start: () => {
|
|
start: () => {
|
|
clearTimeout(timeout);
|
|
clearTimeout(timeout);
|
|
- if (!loading) {
|
|
|
|
|
|
+ if (!exixts) {
|
|
|
|
+ // service可能会再次引起life所以需要额外变量提前占位
|
|
|
|
+ exixts = true;
|
|
loading = ElLoading.service({
|
|
loading = ElLoading.service({
|
|
lock: true,
|
|
lock: true,
|
|
fullscreen: true,
|
|
fullscreen: true,
|
|
@@ -31,11 +34,13 @@ lifeHook.push({
|
|
}
|
|
}
|
|
},
|
|
},
|
|
end: () => {
|
|
end: () => {
|
|
- if (loading) {
|
|
|
|
|
|
+ if (exixts) {
|
|
clearTimeout(timeout);
|
|
clearTimeout(timeout);
|
|
timeout = setTimeout(() => {
|
|
timeout = setTimeout(() => {
|
|
|
|
+ console.log("close");
|
|
loading!.close();
|
|
loading!.close();
|
|
loading = null;
|
|
loading = null;
|
|
|
|
+ exixts = false;
|
|
}, 16);
|
|
}, 16);
|
|
}
|
|
}
|
|
},
|
|
},
|