@morningfast/platform 1.0.4 → 1.0.6
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/assets/main/style.css +3 -3
- package/dist/chunks/{Login-8fZ-l3ST.js → Login-7n7MU-kG.js} +1 -1
- package/dist/chunks/{SystemConfig-Xa8FuNBK.js → SystemConfig-DGZUwXWB.js} +1 -1
- package/dist/chunks/application-config-DePctoXE.js +426 -0
- package/dist/chunks/main-8Nctu65O.js +2441 -0
- package/dist/chunks/register-dGBgzdRh.js +575 -0
- package/dist/chunks/{route-items-DXwaEe0Y.js → route-items-CYTYHd0U.js} +2 -1
- package/dist/index.js +6 -6
- package/dist/main/micro-apps/config.d.ts +15 -0
- package/dist/main/micro-apps/register.d.ts +2 -0
- package/dist/main.js +5 -5
- package/dist/sub.js +1 -1
- package/package.json +2 -1
- package/dist/chunks/application-config-DpfzdbAa.js +0 -287
- package/dist/chunks/config-CJOAan9n.js +0 -40
- package/dist/chunks/main-CmsQvBLj.js +0 -2836
- /package/dist/chunks/{_plugin-vue_export-helper-CZc-Y3Wh.js → _plugin-vue_export-helper-DvRHjpsZ.js} +0 -0
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
import { n as e, r as t, t as n } from "./storage-DNllLr_D.js";
|
|
2
|
+
import { computed as r, reactive as i, ref as a, watch as o } from "vue";
|
|
3
|
+
import { defineStore as s } from "pinia";
|
|
4
|
+
import { addErrorHandler as c, registerMicroApps as l, start as u } from "qiankun";
|
|
5
|
+
import { getAppNames as d, triggerAppChange as f, unloadApplication as ee, unregisterApplication as p } from "single-spa";
|
|
6
|
+
//#region src/main/utils/theme.ts
|
|
7
|
+
var m = "theme-color", h = "theme-mode", g = "theme-position", _ = [
|
|
8
|
+
{
|
|
9
|
+
label: "默认蓝",
|
|
10
|
+
value: "#409EFF"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
label: "深蓝色",
|
|
14
|
+
value: "#0960BE"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
label: "靛蓝色",
|
|
18
|
+
value: "#045277"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
label: "天空蓝",
|
|
22
|
+
value: "#78B5FE"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: "深绿色",
|
|
26
|
+
value: "#0C522B"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: "翡翠绿",
|
|
30
|
+
value: "#009773"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: "浅绿色",
|
|
34
|
+
value: "#0BD092"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
label: "紫罗兰",
|
|
38
|
+
value: "#7166F0"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
label: "樱花粉",
|
|
42
|
+
value: "#FFB7C5"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
label: "柠檬黄",
|
|
46
|
+
value: "#EFBD48"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
label: "橙黄色",
|
|
50
|
+
value: "#C1420B"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: "玫瑰红",
|
|
54
|
+
value: "#BB1B1B"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: "锌色灰",
|
|
58
|
+
value: "#3F3F46"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: "中性灰",
|
|
62
|
+
value: "#404040"
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: "石板灰",
|
|
66
|
+
value: "#344256"
|
|
67
|
+
}
|
|
68
|
+
];
|
|
69
|
+
function v() {
|
|
70
|
+
return localStorage.getItem(m) || "#409EFF";
|
|
71
|
+
}
|
|
72
|
+
function y() {
|
|
73
|
+
let e = localStorage.getItem(h);
|
|
74
|
+
return e === "light" || e === "dark" || e === "system" ? e : "light";
|
|
75
|
+
}
|
|
76
|
+
function te(e) {
|
|
77
|
+
localStorage.setItem(m, e);
|
|
78
|
+
}
|
|
79
|
+
function ne(e) {
|
|
80
|
+
localStorage.setItem(h, e);
|
|
81
|
+
}
|
|
82
|
+
function b() {
|
|
83
|
+
let e = localStorage.getItem(g);
|
|
84
|
+
return e === "none" || e === "header" || e === "sidebar" ? e : "none";
|
|
85
|
+
}
|
|
86
|
+
function re(e) {
|
|
87
|
+
localStorage.setItem(g, e);
|
|
88
|
+
}
|
|
89
|
+
function x() {
|
|
90
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
91
|
+
}
|
|
92
|
+
function ie(e) {
|
|
93
|
+
return e === "dark" || e === "system" && x();
|
|
94
|
+
}
|
|
95
|
+
function ae(e) {
|
|
96
|
+
let t = ie(e);
|
|
97
|
+
document.documentElement.classList.toggle("dark", t), document.documentElement.style.colorScheme = t ? "dark" : "light";
|
|
98
|
+
}
|
|
99
|
+
function S(e) {
|
|
100
|
+
let t = document.documentElement, n = t.classList.contains("dark");
|
|
101
|
+
t.style.setProperty("--el-color-primary", e), t.style.setProperty("--el-color-primary-light-3", w(e, n ? "#000000" : "#ffffff", .3)), t.style.setProperty("--el-color-primary-light-5", w(e, n ? "#000000" : "#ffffff", .5)), t.style.setProperty("--el-color-primary-light-7", w(e, n ? "#000000" : "#ffffff", .7)), t.style.setProperty("--el-color-primary-light-8", w(e, n ? "#000000" : "#ffffff", .8)), t.style.setProperty("--el-color-primary-light-9", w(e, n ? "#000000" : "#ffffff", .9)), t.style.setProperty("--el-color-primary-dark-2", w(e, n ? "#ffffff" : "#000000", .2));
|
|
102
|
+
}
|
|
103
|
+
function oe() {
|
|
104
|
+
ae(y()), S(v()), se(b());
|
|
105
|
+
}
|
|
106
|
+
function se(e) {
|
|
107
|
+
document.documentElement.setAttribute("data-theme-position", e);
|
|
108
|
+
}
|
|
109
|
+
function C(e = 50) {
|
|
110
|
+
return new Promise((t) => {
|
|
111
|
+
setTimeout(() => {
|
|
112
|
+
S(v()), t();
|
|
113
|
+
}, e);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
async function ce(e, t) {
|
|
117
|
+
if (!document.startViewTransition) {
|
|
118
|
+
t(), await C();
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
let n = e.clientX, r = e.clientY, i = Math.hypot(Math.max(n, innerWidth - n), Math.max(r, innerHeight - r));
|
|
122
|
+
try {
|
|
123
|
+
document.startViewTransition(() => {
|
|
124
|
+
t();
|
|
125
|
+
}).ready.then(() => {
|
|
126
|
+
let e = 100 * n / innerWidth, t = 100 * r / innerHeight, a = Math.hypot(innerWidth, innerHeight) / Math.SQRT2, o = 100 * i / a, s = [`circle(0% at ${e}% ${t}%)`, `circle(${o}% at ${e}% ${t}%)`], c = document.documentElement.classList.contains("dark");
|
|
127
|
+
document.documentElement.animate({ clipPath: c ? s.reverse() : s }, {
|
|
128
|
+
duration: 400,
|
|
129
|
+
easing: "ease-in",
|
|
130
|
+
fill: "both",
|
|
131
|
+
pseudoElement: c ? "::view-transition-old(root)" : "::view-transition-new(root)"
|
|
132
|
+
});
|
|
133
|
+
}), await C();
|
|
134
|
+
} catch {
|
|
135
|
+
t(), await C();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function w(e, t, n) {
|
|
139
|
+
let [r, i, a] = T(e), [o, s, c] = T(t), l = (e, t) => Math.round(e * (1 - n) + t * n);
|
|
140
|
+
return `rgb(${l(r, o)}, ${l(i, s)}, ${l(a, c)})`;
|
|
141
|
+
}
|
|
142
|
+
function T(e) {
|
|
143
|
+
let t = e.replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t, r = Number.parseInt(n, 16);
|
|
144
|
+
return [
|
|
145
|
+
r >> 16 & 255,
|
|
146
|
+
r >> 8 & 255,
|
|
147
|
+
r & 255
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/main/stores/app.ts
|
|
152
|
+
var le = "sidebar-collapsed", E = "menu-search-placement", D = "layout-mode", O = "top-menu-path", k = "(max-width: 768px)", A = null, j = s("app", () => {
|
|
153
|
+
let e = a(localStorage.getItem(le) === "true"), t = a(!1), n = a(ue()), i = a(!1), o = a("theme"), s = a(y()), c = a(v()), l = a(b()), u = a(fe(localStorage.getItem(D))), d = a(localStorage.getItem(E) || "header"), f = a(localStorage.getItem(O) || ""), ee = a(!0), p = r(() => ie(s.value)), m = r(() => u.value === "top" ? ["header"] : ["header", "sidebar"]), h = r(() => u.value !== "top" && d.value === "sidebar");
|
|
154
|
+
function g() {
|
|
155
|
+
if (n.value) {
|
|
156
|
+
t.value = !t.value;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
e.value = !e.value;
|
|
160
|
+
}
|
|
161
|
+
function _(t) {
|
|
162
|
+
e.value = t, localStorage.setItem(le, String(e.value));
|
|
163
|
+
}
|
|
164
|
+
function C() {
|
|
165
|
+
t.value = !1;
|
|
166
|
+
}
|
|
167
|
+
function ce(e = "theme") {
|
|
168
|
+
o.value = e, i.value = !0;
|
|
169
|
+
}
|
|
170
|
+
function w() {
|
|
171
|
+
i.value = !1;
|
|
172
|
+
}
|
|
173
|
+
function T(e) {
|
|
174
|
+
i.value = e;
|
|
175
|
+
}
|
|
176
|
+
function k(e) {
|
|
177
|
+
s.value = e, ne(e), ae(e), S(c.value);
|
|
178
|
+
}
|
|
179
|
+
function A() {
|
|
180
|
+
k(x() && s.value === "system" || p.value ? "light" : "dark");
|
|
181
|
+
}
|
|
182
|
+
function j(e) {
|
|
183
|
+
c.value = e, te(e), S(e);
|
|
184
|
+
}
|
|
185
|
+
function M(e) {
|
|
186
|
+
l.value = e, re(e), se(e);
|
|
187
|
+
}
|
|
188
|
+
function N(e) {
|
|
189
|
+
u.value = e, localStorage.setItem(D, e), e === "top" && d.value === "sidebar" && P("header");
|
|
190
|
+
}
|
|
191
|
+
function P(e) {
|
|
192
|
+
let t = u.value === "top" ? "header" : e;
|
|
193
|
+
d.value = t, localStorage.setItem(E, t);
|
|
194
|
+
}
|
|
195
|
+
function F(e) {
|
|
196
|
+
f.value = e, localStorage.setItem(O, e);
|
|
197
|
+
}
|
|
198
|
+
function I() {
|
|
199
|
+
oe(), de();
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
closeMobileSidebar: C,
|
|
203
|
+
closeSettings: w,
|
|
204
|
+
initializePreferences: I,
|
|
205
|
+
isDark: p,
|
|
206
|
+
isMobileViewport: n,
|
|
207
|
+
layoutMode: u,
|
|
208
|
+
menuSearchPlacement: d,
|
|
209
|
+
menuSearchPlacementOptions: m,
|
|
210
|
+
mobileSidebarVisible: t,
|
|
211
|
+
openSettings: ce,
|
|
212
|
+
isSidebarMenuSearch: h,
|
|
213
|
+
settingsActiveTab: o,
|
|
214
|
+
selectedTopMenuPath: f,
|
|
215
|
+
setLayoutMode: N,
|
|
216
|
+
setMenuSearchPlacement: P,
|
|
217
|
+
setSelectedTopMenuPath: F,
|
|
218
|
+
setSettingsVisible: T,
|
|
219
|
+
setSidebarCollapsed: _,
|
|
220
|
+
setThemeColor: j,
|
|
221
|
+
setThemeColorPosition: M,
|
|
222
|
+
setThemeMode: k,
|
|
223
|
+
settingsVisible: i,
|
|
224
|
+
sidebarCollapsed: e,
|
|
225
|
+
shortcutTipVisible: ee,
|
|
226
|
+
themeColor: c,
|
|
227
|
+
themeColorPosition: l,
|
|
228
|
+
themeMode: s,
|
|
229
|
+
toggleDarkMode: A,
|
|
230
|
+
toggleSidebar: g
|
|
231
|
+
};
|
|
232
|
+
});
|
|
233
|
+
function ue() {
|
|
234
|
+
return typeof window > "u" ? !1 : window.matchMedia(k).matches;
|
|
235
|
+
}
|
|
236
|
+
function de() {
|
|
237
|
+
if (typeof window > "u" || A) return;
|
|
238
|
+
let e = window.matchMedia(k), t = j(), n = () => {
|
|
239
|
+
t.isMobileViewport = e.matches, e.matches || t.closeMobileSidebar();
|
|
240
|
+
};
|
|
241
|
+
n(), e.addEventListener("change", n), A = () => {
|
|
242
|
+
e.removeEventListener("change", n), A = null;
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function fe(e) {
|
|
246
|
+
return e === "side" || e === "top" || e === "mix" ? e : "default";
|
|
247
|
+
}
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/main/micro-apps/config.ts
|
|
250
|
+
var M = "system:apps", N = "system:micro-app-entry-overrides", P = [], F = "micro-app-container";
|
|
251
|
+
function I() {
|
|
252
|
+
return ye(n(M, P).filter((e) => e.type === "sub").map(H));
|
|
253
|
+
}
|
|
254
|
+
function pe(e) {
|
|
255
|
+
P = e.map(H);
|
|
256
|
+
}
|
|
257
|
+
async function me(e) {
|
|
258
|
+
let n = e.map(H), r = n.find((e) => B(e.entry));
|
|
259
|
+
if (r) throw Error(`公共应用配置不能保存本地或内网入口:${r.name} ${r.entry}`);
|
|
260
|
+
await t(M, n);
|
|
261
|
+
}
|
|
262
|
+
function L(e) {
|
|
263
|
+
return e.map((e) => ({
|
|
264
|
+
id: e.id,
|
|
265
|
+
name: ge(e),
|
|
266
|
+
title: e.name,
|
|
267
|
+
entry: R(e).entry,
|
|
268
|
+
activeRule: V(e.basePath),
|
|
269
|
+
container: "#micro-app-container"
|
|
270
|
+
}));
|
|
271
|
+
}
|
|
272
|
+
function he(e) {
|
|
273
|
+
return {
|
|
274
|
+
id: "id" in e ? String(e.id) : e.name,
|
|
275
|
+
name: e.name,
|
|
276
|
+
title: e.title,
|
|
277
|
+
entry: e.entry,
|
|
278
|
+
activeRule: e.activeRule
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function ge(e) {
|
|
282
|
+
return `morningfast-${e.id}`;
|
|
283
|
+
}
|
|
284
|
+
function R(e) {
|
|
285
|
+
let t = z()[e.id]?.trim() || "", n = e.entry.trim(), r = be(e);
|
|
286
|
+
return t ? {
|
|
287
|
+
entry: t,
|
|
288
|
+
source: "local",
|
|
289
|
+
localEntry: t,
|
|
290
|
+
configEntry: n,
|
|
291
|
+
envEntry: r
|
|
292
|
+
} : n && !B(n) ? {
|
|
293
|
+
entry: n,
|
|
294
|
+
source: "config",
|
|
295
|
+
localEntry: t,
|
|
296
|
+
configEntry: n,
|
|
297
|
+
envEntry: r
|
|
298
|
+
} : {
|
|
299
|
+
entry: r,
|
|
300
|
+
source: "env",
|
|
301
|
+
localEntry: t,
|
|
302
|
+
configEntry: n,
|
|
303
|
+
envEntry: r
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
function z() {
|
|
307
|
+
let e = n(N, {});
|
|
308
|
+
return Object.fromEntries(Object.entries(e).map(([e, t]) => [e, t.trim()]).filter(([, e]) => !!e));
|
|
309
|
+
}
|
|
310
|
+
async function _e(e, t) {
|
|
311
|
+
let n = e.trim(), r = t.trim();
|
|
312
|
+
if (!n) return;
|
|
313
|
+
let i = z();
|
|
314
|
+
r ? i[n] = r : delete i[n], U(i);
|
|
315
|
+
}
|
|
316
|
+
async function ve(e) {
|
|
317
|
+
let t = z();
|
|
318
|
+
delete t[e], U(t);
|
|
319
|
+
}
|
|
320
|
+
function B(e) {
|
|
321
|
+
let t = Se(e);
|
|
322
|
+
if (!t) return !1;
|
|
323
|
+
let n = t.toLowerCase();
|
|
324
|
+
if (n === "localhost" || n.endsWith(".localhost") || n === "0.0.0.0" || n === "::1") return !0;
|
|
325
|
+
let r = n.match(/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/);
|
|
326
|
+
if (!r) return !1;
|
|
327
|
+
let i = Number(r[1]), a = Number(r[2] ?? 0);
|
|
328
|
+
return i === 10 || i === 127 || i === 172 && a >= 16 && a <= 31 || i === 192 && a === 168;
|
|
329
|
+
}
|
|
330
|
+
function V(e) {
|
|
331
|
+
let t = e.trim() || "/micro";
|
|
332
|
+
return t.startsWith("/") ? t : `/${t}`;
|
|
333
|
+
}
|
|
334
|
+
function H(e) {
|
|
335
|
+
return {
|
|
336
|
+
id: e.id?.trim() || `app-${Date.now()}`,
|
|
337
|
+
name: e.name?.trim() || "未命名子应用",
|
|
338
|
+
type: "sub",
|
|
339
|
+
description: e.description?.trim() || "",
|
|
340
|
+
basePath: V(e.basePath),
|
|
341
|
+
entry: e.entry?.trim() || ""
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
function ye(e) {
|
|
345
|
+
let n = !1, r = !1, i = z(), a = e.map((e) => B(e.entry) ? (i[e.id] || (i[e.id] = e.entry, r = !0), n = !0, {
|
|
346
|
+
...e,
|
|
347
|
+
entry: ""
|
|
348
|
+
}) : e);
|
|
349
|
+
return r && U(i), n && t(M, a), a;
|
|
350
|
+
}
|
|
351
|
+
function U(n) {
|
|
352
|
+
let r = Object.fromEntries(Object.entries(n).map(([e, t]) => [e, t.trim()]).filter(([e, t]) => !!e.trim() && !!t));
|
|
353
|
+
Object.keys(r).length ? t(N, r) : e(N);
|
|
354
|
+
}
|
|
355
|
+
function be(e) {
|
|
356
|
+
let t = {
|
|
357
|
+
BASE_URL: "/",
|
|
358
|
+
DEV: !1,
|
|
359
|
+
MODE: "production",
|
|
360
|
+
PROD: !0,
|
|
361
|
+
SSR: !1
|
|
362
|
+
}, n = [
|
|
363
|
+
e.id,
|
|
364
|
+
e.basePath.split("/").filter(Boolean).at(-1) || "",
|
|
365
|
+
e.name
|
|
366
|
+
].map((e) => `VITE_MICRO_APP_ENTRY_${xe(e)}`).find((e) => !!t[e]);
|
|
367
|
+
return (n ? t[n] : "") || t.VITE_MICRO_APP_ENTRY || t.VITE_SUB_APP_ENTRY || "http://localhost:8082";
|
|
368
|
+
}
|
|
369
|
+
function xe(e) {
|
|
370
|
+
return e.trim().replace(/([a-z])([A-Z])/g, "$1_$2").replace(/[^a-zA-Z0-9]+/g, "_").replace(/^_+|_+$/g, "").toUpperCase();
|
|
371
|
+
}
|
|
372
|
+
function Se(e) {
|
|
373
|
+
let t = e.trim();
|
|
374
|
+
if (!t) return "";
|
|
375
|
+
try {
|
|
376
|
+
if (/^https?:\/\//i.test(t)) return new URL(t).hostname;
|
|
377
|
+
if (/^\/\//.test(t)) return new URL(`http:${t}`).hostname;
|
|
378
|
+
let e = (t.split("/")[0] || "").split(":")[0] || "";
|
|
379
|
+
if (e === "localhost" || e.includes(".") || /^\d{1,3}(?:\.\d{1,3}){3}$/.test(e)) return e;
|
|
380
|
+
} catch {
|
|
381
|
+
return "";
|
|
382
|
+
}
|
|
383
|
+
return "";
|
|
384
|
+
}
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/main/micro-apps/status.ts
|
|
387
|
+
var W = i({}), G = i({});
|
|
388
|
+
function K() {
|
|
389
|
+
return W;
|
|
390
|
+
}
|
|
391
|
+
function Ce(e) {
|
|
392
|
+
return G[e];
|
|
393
|
+
}
|
|
394
|
+
function we(e) {
|
|
395
|
+
return L(I()).find((t) => e === t.activeRule || e.startsWith(`${t.activeRule}/`));
|
|
396
|
+
}
|
|
397
|
+
function Te(e) {
|
|
398
|
+
let t = W[e.name];
|
|
399
|
+
return t ? (t.title = e.title, t.entry = e.entry, t.activeRule = e.activeRule, t) : (W[e.name] = {
|
|
400
|
+
name: e.name,
|
|
401
|
+
title: e.title,
|
|
402
|
+
entry: e.entry,
|
|
403
|
+
activeRule: e.activeRule,
|
|
404
|
+
status: "idle",
|
|
405
|
+
updatedAt: Date.now()
|
|
406
|
+
}, W[e.name]);
|
|
407
|
+
}
|
|
408
|
+
function q(e) {
|
|
409
|
+
ke(e, {
|
|
410
|
+
status: "loading",
|
|
411
|
+
message: void 0
|
|
412
|
+
});
|
|
413
|
+
}
|
|
414
|
+
function Ee(e) {
|
|
415
|
+
ke(e, {
|
|
416
|
+
status: "mounted",
|
|
417
|
+
message: void 0
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function De(e, t) {
|
|
421
|
+
let n = W[e];
|
|
422
|
+
return n ? (n.status = "error", n.message = Ae(t), n.updatedAt = Date.now(), !0) : !1;
|
|
423
|
+
}
|
|
424
|
+
function Oe(e, t, n) {
|
|
425
|
+
G[t] = {
|
|
426
|
+
path: t,
|
|
427
|
+
name: e.name,
|
|
428
|
+
title: e.title,
|
|
429
|
+
entry: e.entry,
|
|
430
|
+
activeRule: e.activeRule,
|
|
431
|
+
message: Ae(n),
|
|
432
|
+
updatedAt: Date.now()
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
function J(e) {
|
|
436
|
+
delete G[e];
|
|
437
|
+
}
|
|
438
|
+
function ke(e, t) {
|
|
439
|
+
let n = W[e];
|
|
440
|
+
n && (n.status = t.status, n.message = t.message, n.updatedAt = Date.now());
|
|
441
|
+
}
|
|
442
|
+
function Ae(e) {
|
|
443
|
+
let t = je(e);
|
|
444
|
+
return t ? Ne(Me(t)) : "子应用入口不可访问、服务未启动,或加载过程中发生异常。";
|
|
445
|
+
}
|
|
446
|
+
function je(e) {
|
|
447
|
+
return e instanceof Error ? e.message : typeof e == "string" ? e : "";
|
|
448
|
+
}
|
|
449
|
+
function Me(e) {
|
|
450
|
+
return e.trim().replace(/^(application ['"][^'"]+['"] died in status [A-Z_]+:\s*)\1+/, "$1");
|
|
451
|
+
}
|
|
452
|
+
function Ne(e) {
|
|
453
|
+
let t = e.trim(), n = t.toLowerCase(), r = t.match(/application ['"]([^'"]+)['"]/)?.[1], i = r ? `子应用“${r}”` : "子应用";
|
|
454
|
+
return n.includes("cannot use import statement outside a module") ? `${i}入口已响应,但加载失败。请确认子应用服务已启动,并确认入口地址指向子应用服务。` : n.includes("unexpected token <") ? `${i}入口返回了 HTML,但 qiankun 正在按脚本解析。请检查入口地址是否填错、子应用服务是否启动,以及访问入口时是否被重定向到了登录页或 404 页面。` : n.includes("failed to fetch") || n.includes("networkerror") || n.includes("load failed") || n.includes("loading source code") || n.includes("loading_source_code") ? `${i}入口资源加载失败。请确认子应用服务已启动、入口地址可直接访问,并检查浏览器控制台是否有跨域、404 或网络连接错误。` : n.includes("application died in status not_mounted") ? `${i}加载后挂载失败。请检查子应用是否正确导出了 qiankun 生命周期,并确认挂载容器和路由基座配置正确。` : t;
|
|
455
|
+
}
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/main/micro-apps/types.ts
|
|
458
|
+
var Pe = "morningfast:theme-change", Y = !1, Fe = !1, Ie = !1, Le = !1, X = /* @__PURE__ */ new Set(), Re = new Set(["idle", "loading"]);
|
|
459
|
+
function Z() {
|
|
460
|
+
if (Y) {
|
|
461
|
+
Ve();
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
Y = !0;
|
|
465
|
+
let e = L(I());
|
|
466
|
+
e.forEach(Te), X.clear(), e.forEach((e) => X.add(e.name)), l(e.map((e) => ({
|
|
467
|
+
name: e.name,
|
|
468
|
+
entry: e.entry,
|
|
469
|
+
container: e.container,
|
|
470
|
+
activeRule: e.activeRule,
|
|
471
|
+
loader: (t) => {
|
|
472
|
+
t && (J(window.location.pathname), q(e.name));
|
|
473
|
+
},
|
|
474
|
+
props: Ge(e)
|
|
475
|
+
})), {
|
|
476
|
+
beforeLoad: [async (e) => {
|
|
477
|
+
J(window.location.pathname), q(e.name);
|
|
478
|
+
}],
|
|
479
|
+
beforeMount: [async (e) => {
|
|
480
|
+
J(window.location.pathname), q(e.name);
|
|
481
|
+
}],
|
|
482
|
+
afterMount: [async (e) => {
|
|
483
|
+
J(window.location.pathname), Ee(e.name);
|
|
484
|
+
}]
|
|
485
|
+
}), He(), Ve(), Ke();
|
|
486
|
+
}
|
|
487
|
+
async function ze() {
|
|
488
|
+
let e = Array.from(new Set([...X, ...d().filter((e) => e.startsWith("morningfast-"))]));
|
|
489
|
+
Y = !1, X.clear(), await Promise.all(e.map(async (e) => {
|
|
490
|
+
try {
|
|
491
|
+
await p(e);
|
|
492
|
+
} catch {}
|
|
493
|
+
})), Z(), await f();
|
|
494
|
+
}
|
|
495
|
+
async function Be(e) {
|
|
496
|
+
let t = we(e);
|
|
497
|
+
if (!t) return !1;
|
|
498
|
+
Z(), J(e), q(t.name);
|
|
499
|
+
try {
|
|
500
|
+
await ee(t.name), await f();
|
|
501
|
+
} catch (n) {
|
|
502
|
+
De(t.name, n) && Oe(t, e, n);
|
|
503
|
+
}
|
|
504
|
+
return !0;
|
|
505
|
+
}
|
|
506
|
+
function Ve() {
|
|
507
|
+
Fe || document.querySelector("#micro-app-container") && (Fe = !0, u({
|
|
508
|
+
prefetch: !1,
|
|
509
|
+
sandbox: { experimentalStyleIsolation: !0 },
|
|
510
|
+
urlRerouteOnly: !0
|
|
511
|
+
}));
|
|
512
|
+
}
|
|
513
|
+
function He() {
|
|
514
|
+
Ie || (Ie = !0, c((e) => {
|
|
515
|
+
let t = e.appOrParcelName;
|
|
516
|
+
if (!t || !We(t)) return;
|
|
517
|
+
let n = L(I()).find((e) => e.name === t);
|
|
518
|
+
!n || !Ue(n, window.location.pathname) || De(t, e) && Oe(n, window.location.pathname, e);
|
|
519
|
+
}));
|
|
520
|
+
}
|
|
521
|
+
function Ue(e, t) {
|
|
522
|
+
return t === e.activeRule || t.startsWith(`${e.activeRule}/`);
|
|
523
|
+
}
|
|
524
|
+
function We(e) {
|
|
525
|
+
let t = K()[e]?.status;
|
|
526
|
+
return !t || Re.has(t);
|
|
527
|
+
}
|
|
528
|
+
function Ge(e) {
|
|
529
|
+
let t = j();
|
|
530
|
+
return {
|
|
531
|
+
basePath: e.activeRule,
|
|
532
|
+
app: he(e),
|
|
533
|
+
runtime: {
|
|
534
|
+
env: "production",
|
|
535
|
+
apiBaseUrl: "/api"
|
|
536
|
+
},
|
|
537
|
+
theme: Q(t.isDark),
|
|
538
|
+
getRuntimeProps: () => ({ theme: Q(t.isDark) })
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function Ke() {
|
|
542
|
+
if (Le) return;
|
|
543
|
+
Le = !0;
|
|
544
|
+
let e = j();
|
|
545
|
+
o(() => [
|
|
546
|
+
e.isDark,
|
|
547
|
+
e.themeColor,
|
|
548
|
+
e.themeColorPosition
|
|
549
|
+
], () => {
|
|
550
|
+
window.setTimeout(() => {
|
|
551
|
+
qe(Q(e.isDark));
|
|
552
|
+
}, 0);
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
function qe(e) {
|
|
556
|
+
window.dispatchEvent(new CustomEvent(Pe, { detail: e }));
|
|
557
|
+
}
|
|
558
|
+
function Q(e) {
|
|
559
|
+
let t = getComputedStyle(document.documentElement);
|
|
560
|
+
return {
|
|
561
|
+
colorPrimary: $(t, "--el-color-primary", "#409EFF"),
|
|
562
|
+
colorPrimaryLight3: $(t, "--el-color-primary-light-3", "#79bbff"),
|
|
563
|
+
colorPrimaryLight5: $(t, "--el-color-primary-light-5", "#a0cfff"),
|
|
564
|
+
colorPrimaryLight7: $(t, "--el-color-primary-light-7", "#c6e2ff"),
|
|
565
|
+
colorPrimaryLight8: $(t, "--el-color-primary-light-8", "#d9ecff"),
|
|
566
|
+
colorPrimaryLight9: $(t, "--el-color-primary-light-9", "#ecf5ff"),
|
|
567
|
+
colorPrimaryDark2: $(t, "--el-color-primary-dark-2", "#337ecc"),
|
|
568
|
+
mode: e ? "dark" : "light"
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
function $(e, t, n) {
|
|
572
|
+
return e.getPropertyValue(t).trim() || n;
|
|
573
|
+
}
|
|
574
|
+
//#endregion
|
|
575
|
+
export { ce as _, Ce as a, I as c, ve as d, R as f, j as g, pe as h, we as i, B as l, _e as m, Be as n, K as o, me as p, Z as r, F as s, ze as t, V as u, _ as v };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MICRO_AUTH_EXPIRED_EVENT as e } from "./micro-contract.js";
|
|
2
|
-
import { _ as t, a as n,
|
|
3
|
-
import { ApiError as
|
|
4
|
-
import { a as
|
|
5
|
-
import { i as
|
|
6
|
-
import {
|
|
2
|
+
import { _ as t, a as n, c as r, d as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, p, r as m, s as h, t as g, u as _, v, y } from "./chunks/main-8Nctu65O.js";
|
|
3
|
+
import { ApiError as b, RequestManager as x, createRequestClient as S, formatErrorMessage as C } from "./request.js";
|
|
4
|
+
import { a as w, i as T, n as E, r as D, t as O } from "./chunks/auth-C3RvRgcW.js";
|
|
5
|
+
import { i as k, n as A, r as j, t as M } from "./chunks/system-DZaKDrG6.js";
|
|
6
|
+
import { g as N, h as P } from "./chunks/register-dGBgzdRh.js";
|
|
7
7
|
import { a as F, c as I, d as L, l as R, n as z, o as B, r as V, s as H, t as U, u as W } from "./chunks/sub-LssKnIb1.js";
|
|
8
|
-
export {
|
|
8
|
+
export { b as ApiError, p as HOME_TAB_PATH, e as MICRO_AUTH_EXPIRED_EVENT, r as MicroAppView, x as RequestManager, F as SUB_APP_NAME, B as SUB_APP_THEME_CHANGE_EVENT, z as applySubAppTheme, s as configureMorningfastRequestClient, o as createApi, E as createMockLoginResult, D as createMockUserProfile, _ as createMorningfastBaseRoutes, l as createMorningfastRouter, S as createRequestClient, h as createRoutesFromItems, W as createSubAppContext, V as createSubAppRouter, C as formatErrorMessage, A as getPersistedValue, n as getStoredUpdateCheckEnabled, t as http, g as mountMorningfastApp, U as mountSubApp, T as normalizeLoginResult, w as normalizeUserProfile, j as removePersistedValue, v as requestManager, H as resolveSubAppBasePath, d as restartAppUpdateChecker, P as setDefaultAppConfigs, k as setPersistedValue, f as setStoredUpdateCheckEnabled, m as setupAppUpdateChecker, y as setupAuthExpiredHandler, c as stopAppUpdateChecker, L as subAppContextKey, N as useAppStore, O as useAuthStore, I as useRequestClient, a as useShortcutStore, i as useSortable, R as useSubAppContext, M as useSystemStore, u as useTabsStore };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MicroAppConfig, MicroAppInfo } from './types';
|
|
2
2
|
export declare const DEFAULT_SUB_APP_ENTRY = "http://localhost:8082";
|
|
3
|
+
export type MicroAppEntrySource = 'local' | 'config' | 'env';
|
|
3
4
|
export interface AppConfigItem {
|
|
4
5
|
id: string;
|
|
5
6
|
name: string;
|
|
@@ -8,6 +9,13 @@ export interface AppConfigItem {
|
|
|
8
9
|
basePath: string;
|
|
9
10
|
entry: string;
|
|
10
11
|
}
|
|
12
|
+
export interface MicroAppEntryResolution {
|
|
13
|
+
entry: string;
|
|
14
|
+
source: MicroAppEntrySource;
|
|
15
|
+
localEntry: string;
|
|
16
|
+
configEntry: string;
|
|
17
|
+
envEntry: string;
|
|
18
|
+
}
|
|
11
19
|
export declare const MICRO_APP_CONTAINER_ID = "micro-app-container";
|
|
12
20
|
export declare function getAppConfigs(): AppConfigItem[];
|
|
13
21
|
export declare function setDefaultAppConfigs(apps: AppConfigItem[]): void;
|
|
@@ -22,4 +30,11 @@ export declare function getMicroAppConfigs(apps: AppConfigItem[]): {
|
|
|
22
30
|
}[];
|
|
23
31
|
export declare function toMicroAppInfo(app: MicroAppConfig): MicroAppInfo;
|
|
24
32
|
export declare function toMicroAppName(app: AppConfigItem): string;
|
|
33
|
+
export declare function resolveMicroAppEntry(app: AppConfigItem): MicroAppEntryResolution;
|
|
34
|
+
export declare function getLocalMicroAppEntryOverrides(): {
|
|
35
|
+
[k: string]: string;
|
|
36
|
+
};
|
|
37
|
+
export declare function saveLocalMicroAppEntryOverride(appId: string, entry: string): Promise<void>;
|
|
38
|
+
export declare function removeLocalMicroAppEntryOverride(appId: string): Promise<void>;
|
|
39
|
+
export declare function isUnsafePublicMicroAppEntry(entry: string): boolean;
|
|
25
40
|
export declare function normalizeMicroAppBasePath(basePath: string): string;
|
package/dist/main.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as e, a as t,
|
|
2
|
-
import { a as
|
|
3
|
-
import { i as
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
1
|
+
import { _ as e, a as t, c as n, d as r, f as i, g as a, h as o, i as s, l as c, m as l, n as u, o as d, p as f, r as p, s as m, t as h, u as g, v as _, y as v } from "./chunks/main-8Nctu65O.js";
|
|
2
|
+
import { a as y, i as b, n as x, r as S, t as C } from "./chunks/auth-C3RvRgcW.js";
|
|
3
|
+
import { i as w, n as T, r as E, t as D } from "./chunks/system-DZaKDrG6.js";
|
|
4
|
+
import { g as O, h as k } from "./chunks/register-dGBgzdRh.js";
|
|
5
|
+
export { f as HOME_TAB_PATH, n as MicroAppView, o as configureMorningfastRequestClient, a as createApi, x as createMockLoginResult, S as createMockUserProfile, g as createMorningfastBaseRoutes, c as createMorningfastRouter, m as createRoutesFromItems, T as getPersistedValue, t as getStoredUpdateCheckEnabled, e as http, h as mountMorningfastApp, b as normalizeLoginResult, y as normalizeUserProfile, E as removePersistedValue, _ as requestManager, u as restartAppUpdateChecker, k as setDefaultAppConfigs, w as setPersistedValue, d as setStoredUpdateCheckEnabled, p as setupAppUpdateChecker, v as setupAuthExpiredHandler, s as stopAppUpdateChecker, O as useAppStore, C as useAuthStore, i as useShortcutStore, r as useSortable, D as useSystemStore, l as useTabsStore };
|
package/dist/sub.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as e } from "./chunks/route-items-
|
|
1
|
+
import { t as e } from "./chunks/route-items-CYTYHd0U.js";
|
|
2
2
|
import { a as t, c as n, d as r, i, l as a, n as o, o as s, r as c, s as l, t as u, u as d } from "./chunks/sub-LssKnIb1.js";
|
|
3
3
|
export { i as DEFAULT_SUB_APP_BASE, t as SUB_APP_NAME, s as SUB_APP_THEME_CHANGE_EVENT, o as applySubAppTheme, e as createRoutesFromItems, d as createSubAppContext, c as createSubAppRouter, u as mountSubApp, l as resolveSubAppBasePath, r as subAppContextKey, n as useRequestClient, a as useSubAppContext };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morningfast/platform",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"description": "Morningfast platform runtime for main and sub applications.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -52,6 +52,7 @@
|
|
|
52
52
|
"morningfast-plus": "^1.1.0",
|
|
53
53
|
"localforage": "^1.10.0",
|
|
54
54
|
"nprogress": "^0.2.0",
|
|
55
|
+
"single-spa": "^5.9.2",
|
|
55
56
|
"vite-plugin-qiankun": "^1.0.15"
|
|
56
57
|
},
|
|
57
58
|
"peerDependencies": {
|