x-essential-lib 0.10.34 → 0.10.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +48 -48
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36,6 +36,53 @@ function useColor() {
|
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/utils/misc.ts
|
|
41
|
+
const globalObjects = (function() {
|
|
42
|
+
if (!window.globalObjects) {
|
|
43
|
+
window.globalObjects = {
|
|
44
|
+
router: null,
|
|
45
|
+
i18n: null
|
|
46
|
+
};
|
|
47
|
+
console.log("globalObjects created");
|
|
48
|
+
}
|
|
49
|
+
return window.globalObjects;
|
|
50
|
+
})();
|
|
51
|
+
const eventBus = (function() {
|
|
52
|
+
if (!window.eventBus) {
|
|
53
|
+
window.eventBus = mitt_default();
|
|
54
|
+
console.log("eventBus created");
|
|
55
|
+
}
|
|
56
|
+
return window.eventBus;
|
|
57
|
+
})();
|
|
58
|
+
async function waitMs(ms) {
|
|
59
|
+
return new Promise((resolve) => {
|
|
60
|
+
setTimeout(resolve, ms);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
async function waitUtil(conditionFunc, timeout, interval) {
|
|
64
|
+
const timestamp = Date.now();
|
|
65
|
+
return new Promise((resolve) => {
|
|
66
|
+
const check = () => {
|
|
67
|
+
if (conditionFunc()) resolve(true);
|
|
68
|
+
else if (timeout && Date.now() - timestamp > timeout) resolve(false);
|
|
69
|
+
else setTimeout(check, interval ?? 30);
|
|
70
|
+
};
|
|
71
|
+
check();
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
function appAppear(name, diff) {
|
|
75
|
+
const appElement = document.getElementById("single-spa-application:" + name);
|
|
76
|
+
if (!appElement) return;
|
|
77
|
+
appElement.classList.remove("app-fade", "app-left", "app-right", "app-reset");
|
|
78
|
+
if (diff === 0) return;
|
|
79
|
+
if (diff > 0) appElement.classList.add("app-left");
|
|
80
|
+
else appElement.classList.add("app-right");
|
|
81
|
+
setTimeout(() => {
|
|
82
|
+
appElement.classList.add("app-reset");
|
|
83
|
+
}, 50);
|
|
84
|
+
}
|
|
85
|
+
|
|
39
86
|
//#endregion
|
|
40
87
|
//#region src/utils/axios.ts
|
|
41
88
|
function createAxios(options) {
|
|
@@ -85,59 +132,12 @@ function onRespRejected(error, onError) {
|
|
|
85
132
|
}
|
|
86
133
|
}
|
|
87
134
|
function onUnauthorized() {
|
|
88
|
-
const router =
|
|
135
|
+
const { router } = globalObjects;
|
|
89
136
|
api.remove("accessToken");
|
|
90
137
|
api.remove("refreshToken");
|
|
91
138
|
router.replace({ path: `/passport/login` });
|
|
92
139
|
}
|
|
93
140
|
|
|
94
|
-
//#endregion
|
|
95
|
-
//#region src/utils/misc.ts
|
|
96
|
-
const globalObjects = (function() {
|
|
97
|
-
if (!window.globalObjects) {
|
|
98
|
-
window.globalObjects = {
|
|
99
|
-
router: null,
|
|
100
|
-
i18n: null
|
|
101
|
-
};
|
|
102
|
-
console.log("globalObjects created");
|
|
103
|
-
}
|
|
104
|
-
return window.globalObjects;
|
|
105
|
-
})();
|
|
106
|
-
const eventBus = (function() {
|
|
107
|
-
if (!window.eventBus) {
|
|
108
|
-
window.eventBus = mitt_default();
|
|
109
|
-
console.log("eventBus created");
|
|
110
|
-
}
|
|
111
|
-
return window.eventBus;
|
|
112
|
-
})();
|
|
113
|
-
async function waitMs(ms) {
|
|
114
|
-
return new Promise((resolve) => {
|
|
115
|
-
setTimeout(resolve, ms);
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
async function waitUtil(conditionFunc, timeout, interval) {
|
|
119
|
-
const timestamp = Date.now();
|
|
120
|
-
return new Promise((resolve) => {
|
|
121
|
-
const check = () => {
|
|
122
|
-
if (conditionFunc()) resolve(true);
|
|
123
|
-
else if (timeout && Date.now() - timestamp > timeout) resolve(false);
|
|
124
|
-
else setTimeout(check, interval ?? 30);
|
|
125
|
-
};
|
|
126
|
-
check();
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
function appAppear(name, diff) {
|
|
130
|
-
const appElement = document.getElementById("single-spa-application:" + name);
|
|
131
|
-
if (!appElement) return;
|
|
132
|
-
appElement.classList.remove("app-fade", "app-left", "app-right", "app-reset");
|
|
133
|
-
if (diff === 0) return;
|
|
134
|
-
if (diff > 0) appElement.classList.add("app-left");
|
|
135
|
-
else appElement.classList.add("app-right");
|
|
136
|
-
setTimeout(() => {
|
|
137
|
-
appElement.classList.add("app-reset");
|
|
138
|
-
}, 50);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
141
|
//#endregion
|
|
142
142
|
//#region src/utils/dialog.ts
|
|
143
143
|
let lastTime = Date.now();
|