@morningfast/platform 0.0.9 → 0.0.11

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.
@@ -152,7 +152,7 @@ function U(e) {
152
152
  //#endregion
153
153
  //#region src/main/stores/app.ts
154
154
  var W = "sidebar-collapsed", G = "menu-search-placement", K = "layout-mode", q = "top-menu-path", J = T("app", () => {
155
- let e = y(localStorage.getItem(W) === "true"), t = y(!1), n = y("theme"), r = y(I()), i = y(F()), a = y(re()), s = y(localStorage.getItem(K) || "side"), c = y(localStorage.getItem(G) || "header"), l = y(localStorage.getItem(q) || ""), u = y(!0), d = o(() => L(r.value)), f = o(() => s.value === "top" ? ["header"] : ["header", "sidebar"]), p = o(() => s.value !== "top" && c.value === "sidebar");
155
+ let e = y(localStorage.getItem(W) === "true"), t = y(!1), n = y("theme"), r = y(I()), i = y(F()), a = y(re()), s = y(ce(localStorage.getItem(K))), c = y(localStorage.getItem(G) || "header"), l = y(localStorage.getItem(q) || ""), u = y(!0), d = o(() => L(r.value)), f = o(() => s.value === "top" ? ["header"] : ["header", "sidebar"]), p = o(() => s.value !== "top" && c.value === "sidebar");
156
156
  function m() {
157
157
  e.value = !e.value;
158
158
  }
@@ -221,17 +221,23 @@ var W = "sidebar-collapsed", G = "menu-search-placement", K = "layout-mode", q =
221
221
  toggleDarkMode: x,
222
222
  toggleSidebar: m
223
223
  };
224
- }), Y = v({}), X = v({});
225
- function ce() {
224
+ });
225
+ function ce(e) {
226
+ return e === "side" || e === "top" || e === "mix" ? e : "default";
227
+ }
228
+ //#endregion
229
+ //#region src/main/micro-apps/status.ts
230
+ var Y = v({}), X = v({});
231
+ function le() {
226
232
  return Y;
227
233
  }
228
- function le(e) {
234
+ function ue(e) {
229
235
  return X[e];
230
236
  }
231
- function ue(e) {
237
+ function de(e) {
232
238
  return n(t()).find((t) => e === t.activeRule || e.startsWith(`${t.activeRule}/`));
233
239
  }
234
- function de(e) {
240
+ function fe(e) {
235
241
  return Y[e.name] || (Y[e.name] = {
236
242
  name: e.name,
237
243
  title: e.title,
@@ -241,29 +247,29 @@ function de(e) {
241
247
  updatedAt: Date.now()
242
248
  }, Y[e.name]);
243
249
  }
244
- function fe(e) {
245
- ve(e, {
250
+ function pe(e) {
251
+ ye(e, {
246
252
  status: "loading",
247
253
  message: void 0
248
254
  });
249
255
  }
250
- function pe(e) {
251
- ve(e, {
256
+ function me(e) {
257
+ ye(e, {
252
258
  status: "mounted",
253
259
  message: void 0
254
260
  });
255
261
  }
256
- function me(e, t) {
257
- ye(e, {
262
+ function he(e, t) {
263
+ be(e, {
258
264
  status: "error",
259
265
  message: Z(t)
260
266
  });
261
267
  }
262
- function he(e, t) {
268
+ function ge(e, t) {
263
269
  let n = Y[e];
264
270
  return n ? (n.status = "error", n.message = Z(t), n.updatedAt = Date.now(), !0) : !1;
265
271
  }
266
- function ge(e, t, n) {
272
+ function _e(e, t, n) {
267
273
  X[t] = {
268
274
  path: t,
269
275
  name: e.name,
@@ -274,77 +280,77 @@ function ge(e, t, n) {
274
280
  updatedAt: Date.now()
275
281
  };
276
282
  }
277
- function _e(e) {
283
+ function ve(e) {
278
284
  delete X[e];
279
285
  }
280
- function ve(e, t) {
286
+ function ye(e, t) {
281
287
  let n = Y[e];
282
288
  n && (n.status = t.status, n.message = t.message, n.updatedAt = Date.now());
283
289
  }
284
- function ye(e, t) {
285
- let n = de(e);
290
+ function be(e, t) {
291
+ let n = fe(e);
286
292
  n.title = e.title, n.entry = e.entry, n.activeRule = e.activeRule, n.status = t.status, n.message = t.message, n.updatedAt = Date.now();
287
293
  }
288
294
  function Z(e) {
289
- let t = be(e);
290
- return t ? Se(xe(t)) : "子应用入口不可访问、服务未启动,或加载过程中发生异常。";
295
+ let t = xe(e);
296
+ return t ? Ce(Se(t)) : "子应用入口不可访问、服务未启动,或加载过程中发生异常。";
291
297
  }
292
- function be(e) {
298
+ function xe(e) {
293
299
  return e instanceof Error ? e.message : typeof e == "string" ? e : "";
294
300
  }
295
- function xe(e) {
301
+ function Se(e) {
296
302
  return e.trim().replace(/^(application ['"][^'"]+['"] died in status [A-Z_]+:\s*)\1+/, "$1");
297
303
  }
298
- function Se(e) {
304
+ function Ce(e) {
299
305
  let t = e.trim(), n = t.toLowerCase(), r = t.match(/application ['"]([^'"]+)['"]/)?.[1], i = r ? `子应用“${r}”` : "子应用";
300
- return n.includes("cannot use import statement outside a module") ? `${i}入口已响应,但脚本格式不是 qiankun 当前加载方式可执行的格式。请确认子应用使用 qiankun dev 模式启动,或检查子应用构建配置是否输出 qiankun 需要的入口格式;同时确认主应用配置的入口地址指向子应用 dev server,而不是普通静态文件地址。` : 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;
306
+ 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;
301
307
  }
302
308
  //#endregion
303
309
  //#region src/main/micro-apps/types.ts
304
- var Ce = "morningfast:theme-change", we = !1, Te = !1;
305
- function Ee() {
306
- if (we) {
307
- De();
310
+ var we = "morningfast:theme-change", Te = !1, Ee = !1;
311
+ function De() {
312
+ if (Te) {
313
+ Oe();
308
314
  return;
309
315
  }
310
- we = !0;
316
+ Te = !0;
311
317
  let e = n(t());
312
- e.forEach(de), k(e.map((e) => ({
318
+ e.forEach(fe), k(e.map((e) => ({
313
319
  name: e.name,
314
320
  entry: e.entry,
315
321
  container: e.container,
316
322
  activeRule: e.activeRule,
317
- props: ke(e)
323
+ props: Ae(e)
318
324
  })), {
319
325
  beforeLoad: [async (e) => {
320
- _e(window.location.pathname), fe(e.name);
326
+ ve(window.location.pathname), pe(e.name);
321
327
  }],
322
328
  afterMount: [async (e) => {
323
- _e(window.location.pathname), pe(e.name);
329
+ ve(window.location.pathname), me(e.name);
324
330
  }]
325
331
  }), O((t) => {
326
- let n = t instanceof ErrorEvent ? t.error || t.message : t, r = Oe(n) || Oe(t);
327
- if (r && he(r, n)) {
332
+ let n = t instanceof ErrorEvent ? t.error || t.message : t, r = ke(n) || ke(t);
333
+ if (r && ge(r, n)) {
328
334
  let t = e.find((e) => e.name === r);
329
- t && ge(t, window.location.pathname, n);
335
+ t && _e(t, window.location.pathname, n);
330
336
  return;
331
337
  }
332
338
  e.forEach((e) => {
333
- (window.location.pathname === e.activeRule || window.location.pathname.startsWith(`${e.activeRule}/`)) && (me(e, n), ge(e, window.location.pathname, n));
339
+ (window.location.pathname === e.activeRule || window.location.pathname.startsWith(`${e.activeRule}/`)) && (he(e, n), _e(e, window.location.pathname, n));
334
340
  });
335
- }), De(), Ae();
341
+ }), Oe(), je();
336
342
  }
337
- function De() {
338
- Te || document.querySelector("#micro-app-container") && (Te = !0, A({
343
+ function Oe() {
344
+ Ee || document.querySelector("#micro-app-container") && (Ee = !0, A({
339
345
  prefetch: !1,
340
346
  sandbox: { experimentalStyleIsolation: !0 },
341
347
  urlRerouteOnly: !0
342
348
  }));
343
349
  }
344
- function Oe(e) {
350
+ function ke(e) {
345
351
  return (e instanceof Error ? e.message : String(e || "")).match(/application ['"]?([^'"\s]+)['"]?/i)?.[1];
346
352
  }
347
- function ke(e) {
353
+ function Ae(e) {
348
354
  let t = J();
349
355
  return {
350
356
  basePath: e.activeRule,
@@ -357,7 +363,7 @@ function ke(e) {
357
363
  getRuntimeProps: () => ({ theme: Q(t.isDark) })
358
364
  };
359
365
  }
360
- function Ae() {
366
+ function je() {
361
367
  let e = J();
362
368
  C(() => [
363
369
  e.isDark,
@@ -365,12 +371,12 @@ function Ae() {
365
371
  e.themeColorPosition
366
372
  ], () => {
367
373
  window.setTimeout(() => {
368
- je(Q(e.isDark));
374
+ Me(Q(e.isDark));
369
375
  }, 0);
370
376
  });
371
377
  }
372
- function je(e) {
373
- window.dispatchEvent(new CustomEvent(Ce, { detail: e }));
378
+ function Me(e) {
379
+ window.dispatchEvent(new CustomEvent(we, { detail: e }));
374
380
  }
375
381
  function Q(e) {
376
382
  let t = getComputedStyle(document.documentElement);
@@ -390,86 +396,85 @@ function $(e, t, n) {
390
396
  }
391
397
  //#endregion
392
398
  //#region src/main/pages/micro/MicroAppView.vue?vue&type=script&setup=true&lang.ts
393
- var Me = { class: "micro-app-page" }, Ne = {
399
+ var Ne = { class: "micro-app-page" }, Pe = {
394
400
  key: 0,
395
401
  class: "micro-app-page__state micro-app-page__state--error"
396
- }, Pe = { class: "micro-app-page__body" }, Fe = { class: "micro-app-page__desc" }, Ie = { class: "micro-app-page__meta" }, Le = { key: 0 }, Re = { key: 1 }, ze = { key: 2 }, Be = { class: "micro-app-page__actions" }, Ve = ["id"], He = /* @__PURE__ */ e(/* @__PURE__ */ p({
402
+ }, Fe = { class: "micro-app-page__body" }, Ie = { class: "micro-app-page__meta" }, Le = { key: 0 }, Re = { key: 1 }, ze = { class: "micro-app-page__actions" }, Be = ["id"], Ve = /* @__PURE__ */ e(/* @__PURE__ */ p({
397
403
  name: "MicroAppView",
398
404
  __name: "MicroAppView",
399
405
  setup(e) {
400
- let t = a(), n = ce(), r = y(""), p = null, v = o(() => ue(t.path)), T = o(() => {
406
+ let t = a(), n = le(), r = y(""), p = null, v = o(() => de(t.path)), T = o(() => {
401
407
  let e = v.value;
402
408
  return e ? n[e.name] : void 0;
403
- }), O = o(() => le(t.path)), k = o(() => T.value?.title || v.value?.title || O.value?.title || "未知子应用"), A = o(() => T.value?.entry || v.value?.entry || O.value?.entry || "-"), j = o(() => T.value?.message ? T.value.message : O.value?.message ? O.value.message : v.value ? "子应用暂时无法访问,请稍后重试。" : "当前路径没有匹配到子应用配置,请检查应用配置里的路由前缀。"), M = o(() => t.path.startsWith("/micro/")), N = o(() => T.value?.status === "error" || !!O.value || !!r.value || M.value && !v.value);
409
+ }), O = o(() => ue(t.path)), k = o(() => T.value?.title || v.value?.title || O.value?.title || "未知子应用"), A = o(() => T.value?.entry || v.value?.entry || O.value?.entry || "-"), j = o(() => "子应用暂时无法访问,请稍后重试。"), M = o(() => T.value?.status === "error" || !!O.value || !!r.value || !v.value);
404
410
  C(() => t.path, () => {
405
411
  m(() => {
406
- Ee(), P();
412
+ De(), N();
407
413
  });
408
414
  }, { immediate: !0 }), g(() => {
409
415
  m(() => {
410
- Ee(), P();
416
+ De(), N();
411
417
  });
412
418
  }), C(() => T.value?.status, (e) => {
413
- e === "mounted" && (F(), r.value = "");
419
+ e === "mounted" && (P(), r.value = "");
414
420
  }), h(() => {
415
- F();
421
+ P();
416
422
  });
417
- function P() {
418
- F(), r.value = "", !(!M.value || !v.value) && (p = window.setTimeout(() => {
423
+ function N() {
424
+ P(), r.value = "", v.value && (p = window.setTimeout(() => {
419
425
  T.value?.status !== "mounted" && (r.value = "子应用暂时无法访问,请稍后重试。");
420
426
  }, 15e3));
421
427
  }
422
- function F() {
428
+ function P() {
423
429
  p !== null && (window.clearTimeout(p), p = null);
424
430
  }
425
- function I() {
431
+ function F() {
426
432
  window.location.reload();
427
433
  }
428
- function te() {
434
+ function I() {
429
435
  let e = A.value;
430
436
  e && e !== "-" && window.open(e, "_blank", "noopener,noreferrer");
431
437
  }
432
438
  return (e, t) => {
433
- let n = b("el-icon"), a = b("el-button");
434
- return _(), l("div", Me, [N.value ? (_(), l("div", Ne, [f(n, { class: "micro-app-page__icon" }, {
439
+ let n = b("el-icon"), r = b("el-button");
440
+ return _(), l("div", Ne, [M.value ? (_(), l("div", Pe, [f(n, { class: "micro-app-page__icon" }, {
435
441
  default: w(() => [f(S(ee))]),
436
442
  _: 1
437
- }), u("div", Pe, [
438
- t[6] ||= u("p", { class: "micro-app-page__title" }, "子应用加载失败", -1),
439
- u("p", Fe, x(j.value), 1),
443
+ }), u("div", Fe, [
444
+ t[5] ||= u("p", { class: "micro-app-page__title" }, "子应用加载失败", -1),
440
445
  u("dl", Ie, [
441
446
  u("div", null, [t[0] ||= u("dt", null, "应用", -1), u("dd", null, x(k.value), 1)]),
442
447
  S(!1) ? (_(), l("div", Le, [t[1] ||= u("dt", null, "入口", -1), u("dd", null, x(A.value), 1)])) : c("", !0),
443
- T.value?.message ? (_(), l("div", Re, [t[2] ||= u("dt", null, "原因", -1), u("dd", null, x(T.value.message), 1)])) : r.value ? (_(), l("div", ze, [t[3] ||= u("dt", null, "原因", -1), u("dd", null, x(r.value), 1)])) : c("", !0)
448
+ j.value ? (_(), l("div", Re, [t[2] ||= u("dt", null, "原因", -1), u("dd", null, x(j.value), 1)])) : c("", !0)
444
449
  ]),
445
- u("div", Be, [f(a, {
450
+ u("div", ze, [f(r, {
446
451
  type: "primary",
447
452
  icon: S(D),
448
- onClick: I
453
+ onClick: F
449
454
  }, {
450
- default: w(() => [...t[4] ||= [d("重新加载", -1)]]),
455
+ default: w(() => [...t[3] ||= [d("重新加载", -1)]]),
451
456
  _: 1
452
- }, 8, ["icon"]), S(!1) && (T.value?.entry || v.value?.entry) ? (_(), s(a, {
457
+ }, 8, ["icon"]), S(!1) && (T.value?.entry || v.value?.entry) ? (_(), s(r, {
453
458
  key: 0,
454
459
  icon: S(E),
455
- onClick: te
460
+ onClick: I
456
461
  }, {
457
- default: w(() => [...t[5] ||= [d(" 打开入口 ", -1)]]),
462
+ default: w(() => [...t[4] ||= [d(" 打开入口 ", -1)]]),
458
463
  _: 1
459
464
  }, 8, ["icon"])) : c("", !0)])
460
465
  ])])) : c("", !0), u("section", {
461
466
  id: S(i),
462
467
  class: "micro-app-page__container"
463
- }, null, 8, Ve)]);
468
+ }, null, 8, Be)]);
464
469
  };
465
470
  }
466
- }), [["__scopeId", "data-v-90c11f85"]]);
471
+ }), [["__scopeId", "data-v-944de23f"]]);
467
472
  //#endregion
468
473
  //#region src/main/router/route-items.ts
469
- function Ue(e, t) {
470
- return e.map((e) => We(e, t));
474
+ function He(e, t) {
475
+ return e.map((e) => Ue(e, t));
471
476
  }
472
- function We(e, t) {
477
+ function Ue(e, t) {
473
478
  let n = {
474
479
  path: e.path,
475
480
  name: e.name,
@@ -480,7 +485,7 @@ function We(e, t) {
480
485
  hidden: e.hidden
481
486
  }
482
487
  };
483
- return e.redirect && (n.redirect = e.redirect), e.componentKey && (n.component = t[e.componentKey]), e.microApp && (n.component = He), e.children?.length && (n.children = Ue(e.children, t)), n;
488
+ return e.redirect && (n.redirect = e.redirect), e.componentKey && (n.component = t[e.componentKey]), e.microApp && (n.component = Ve), e.children?.length && (n.children = He(e.children, t)), n;
484
489
  }
485
490
  //#endregion
486
- export { P as a, se as i, He as n, J as r, Ue as t };
491
+ export { P as a, se as i, Ve as n, J as r, He as t };