@morningfast/platform 0.0.6 → 0.0.7

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.
@@ -10,4 +10,4 @@
10
10
  .config-center[data-v-5d22ada6]{height:100%;min-height:0}.config-center__content[data-v-5d22ada6]{background:var(--el-bg-color);border-radius:12px;align-content:start;gap:20px;min-height:100%;padding:20px 20px 32px;display:grid}.config-center__header[data-v-5d22ada6]{justify-content:flex-end;display:flex}.config-center__actions[data-v-5d22ada6]{gap:12px;display:inline-flex}.config-center__form[data-v-5d22ada6]{gap:18px;padding-top:6px;display:grid}.config-center__item[data-v-5d22ada6]{margin-bottom:0}.config-center__item--assets[data-v-5d22ada6] .el-form-item__content{display:block}.config-center__item[data-v-5d22ada6] .el-form-item__label{color:var(--el-text-color-primary);font-weight:600}.config-center__field[data-v-5d22ada6]{width:min(460px,100%)}.config-center__asset-row[data-v-5d22ada6]{flex-wrap:wrap;align-items:flex-end;gap:24px;width:100%;display:flex}.config-center__asset-list[data-v-5d22ada6]{border-top:1px solid var(--el-border-color-lighter);padding-top:18px}.config-center__asset-card[data-v-5d22ada6]{justify-items:center;gap:12px;display:grid}.config-center__asset-card span[data-v-5d22ada6]{color:var(--el-text-color-primary);font-weight:600}.config-center__asset-preview[data-v-5d22ada6]{border:1px solid var(--el-border-color-lighter);background:#fff;border-radius:10px;flex:none;justify-content:center;align-items:center;display:flex;overflow:hidden}.config-center__asset-preview--wide[data-v-5d22ada6]{width:180px;height:92px;padding:8px 10px}.config-center__asset-preview--login[data-v-5d22ada6]{width:240px;height:150px;padding:8px}.config-center__asset-preview--square[data-v-5d22ada6],.config-center__asset-preview--icon[data-v-5d22ada6]{width:92px;height:92px;padding:8px}.config-center__asset-image[data-v-5d22ada6]{object-fit:contain;max-width:100%;max-height:100%;display:block}.config-center__asset-image--icon[data-v-5d22ada6]{width:100%;height:100%}.config-center__file[data-v-5d22ada6]{display:none}
11
11
 
12
12
  /* application-config.css */
13
- .app-config-page[data-v-0066cec3]{box-sizing:border-box;grid-template-rows:minmax(0,1fr);gap:12px;height:100%;min-height:0;padding:16px;display:grid;overflow:hidden}.app-config-page__apps[data-v-0066cec3],.app-config-page__empty[data-v-0066cec3]{border:1px solid var(--el-border-color-lighter);background:var(--el-bg-color);border-radius:8px}.app-config-section__header h2[data-v-0066cec3]{color:var(--el-text-color-primary);margin:0;font-weight:600}.app-config-page__apps[data-v-0066cec3]{grid-template-rows:auto minmax(0,1fr);min-height:0;display:grid;overflow:hidden}.app-config-section__header[data-v-0066cec3]{border-bottom:1px solid var(--el-border-color-lighter);justify-content:space-between;align-items:center;gap:12px;padding:12px 16px;display:flex}.app-config-section__title[data-v-0066cec3]{align-items:center;gap:8px;min-width:0;display:inline-flex}.app-config-section__header h2[data-v-0066cec3]{font-size:16px}.app-config-page__scroll[data-v-0066cec3]{min-height:0}.app-config-page__grid[data-v-0066cec3]{grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:12px;display:grid}.app-config-card[data-v-0066cec3]{border:1px solid var(--el-border-color-lighter);background:var(--el-bg-color);cursor:pointer;border-radius:8px;gap:8px;min-height:124px;padding:12px;display:grid}.app-config-card.is-active[data-v-0066cec3]{border-color:var(--el-color-primary);box-shadow:0 8px 20px #409eff1f}.app-config-card__title-row[data-v-0066cec3]{align-items:center;gap:8px;display:flex}.app-config-card__title-row h2[data-v-0066cec3]{color:var(--el-text-color-primary);margin:0;font-size:15px;font-weight:600}.app-config-card__desc[data-v-0066cec3]{color:var(--el-text-color-secondary);margin:6px 0 0;font-size:13px}.app-config-card__path[data-v-0066cec3]{color:var(--el-text-color-secondary);margin-top:8px;font-size:13px}.app-config-card__entry[data-v-0066cec3]{color:var(--el-text-color-secondary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.app-config-card__footer[data-v-0066cec3]{justify-content:space-between;align-items:center;gap:12px;display:flex}.app-config-card__mount[data-v-0066cec3]{color:var(--el-text-color-secondary);font-size:13px}.app-config-card__footer-actions[data-v-0066cec3]{gap:10px;display:inline-flex}.app-config-page__empty[data-v-0066cec3]{place-items:center;min-height:240px;padding:24px;display:grid}.app-config-empty__actions[data-v-0066cec3]{margin-top:12px}.app-config-dialog__footer[data-v-0066cec3]{justify-content:flex-end;gap:12px;display:flex}.app-config-remove__text[data-v-0066cec3]{color:var(--el-text-color-primary);margin:0}@media (width<=1400px){.app-config-page__grid[data-v-0066cec3]{grid-template-columns:repeat(auto-fill,minmax(240px,1fr))}}@media (width<=1100px){.app-config-page[data-v-0066cec3]{height:auto;overflow:visible}.app-config-page__grid[data-v-0066cec3]{grid-template-columns:1fr}}
13
+ .app-config-page[data-v-ada45daa]{box-sizing:border-box;grid-template-rows:minmax(0,1fr);gap:12px;height:100%;min-height:0;padding:16px;display:grid;overflow:hidden}.app-config-page__apps[data-v-ada45daa],.app-config-page__empty[data-v-ada45daa]{border:1px solid var(--el-border-color-lighter);background:var(--el-bg-color);border-radius:8px}.app-config-section__header h2[data-v-ada45daa]{color:var(--el-text-color-primary);margin:0;font-weight:600}.app-config-page__apps[data-v-ada45daa]{grid-template-rows:auto minmax(0,1fr);min-height:0;display:grid;overflow:hidden}.app-config-section__header[data-v-ada45daa]{border-bottom:1px solid var(--el-border-color-lighter);justify-content:space-between;align-items:center;gap:12px;padding:12px 16px;display:flex}.app-config-section__title[data-v-ada45daa]{align-items:center;gap:8px;min-width:0;display:inline-flex}.app-config-section__header h2[data-v-ada45daa]{font-size:16px}.app-config-page__scroll[data-v-ada45daa]{min-height:0}.app-config-page__grid[data-v-ada45daa]{grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:12px;display:grid}.app-config-card[data-v-ada45daa]{border:1px solid var(--el-border-color-lighter);background:var(--el-bg-color);cursor:pointer;border-radius:8px;gap:8px;min-height:124px;padding:12px;display:grid}.app-config-card.is-active[data-v-ada45daa]{border-color:var(--el-color-primary);box-shadow:0 8px 20px #409eff1f}.app-config-card__title-row[data-v-ada45daa]{align-items:center;gap:8px;display:flex}.app-config-card__title-row h2[data-v-ada45daa]{color:var(--el-text-color-primary);margin:0;font-size:15px;font-weight:600}.app-config-card__desc[data-v-ada45daa]{color:var(--el-text-color-secondary);margin:6px 0 0;font-size:13px}.app-config-card__path[data-v-ada45daa]{color:var(--el-text-color-secondary);margin-top:8px;font-size:13px}.app-config-card__entry[data-v-ada45daa]{color:var(--el-text-color-secondary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;overflow:hidden}.app-config-card__footer[data-v-ada45daa]{justify-content:space-between;align-items:center;gap:12px;display:flex}.app-config-card__mount[data-v-ada45daa]{color:var(--el-text-color-secondary);font-size:13px}.app-config-card__footer-actions[data-v-ada45daa]{gap:10px;display:inline-flex}.app-config-page__empty[data-v-ada45daa]{place-items:center;min-height:240px;padding:24px;display:grid}.app-config-empty__actions[data-v-ada45daa]{margin-top:12px}.app-config-dialog__footer[data-v-ada45daa]{justify-content:flex-end;gap:12px;display:flex}.app-config-remove__text[data-v-ada45daa]{color:var(--el-text-color-primary);margin:0}@media (width<=1400px){.app-config-page__grid[data-v-ada45daa]{grid-template-columns:repeat(auto-fill,minmax(240px,1fr))}}@media (width<=1100px){.app-config-page[data-v-ada45daa]{height:auto;overflow:visible}.app-config-page__grid[data-v-ada45daa]{grid-template-columns:1fr}}
@@ -0,0 +1,253 @@
1
+ import { t as e } from "./app-Cn5iHmfI.js";
2
+ import { t } from "./_plugin-vue_export-helper-DvRHjpsZ.js";
3
+ import { n, o as r, r as i, t as a } from "./config-MbLdbbb7.js";
4
+ import { useRoute as o } from "vue-router";
5
+ import { computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createTextVNode as f, createVNode as p, defineComponent as m, nextTick as h, onBeforeUnmount as g, onMounted as _, openBlock as v, reactive as y, ref as b, resolveComponent as x, toDisplayString as S, unref as C, watch as w, withCtx as T } from "vue";
6
+ import { Link as ee, RefreshRight as te, WarningFilled as E } from "@element-plus/icons-vue";
7
+ import { addGlobalUncaughtErrorHandler as D, registerMicroApps as O, start as k } from "qiankun";
8
+ //#region src/main/micro-apps/status.ts
9
+ var A = y({}), j = y({});
10
+ function ne() {
11
+ return A;
12
+ }
13
+ function re(e) {
14
+ return j[e];
15
+ }
16
+ function M(e) {
17
+ return i(n()).find((t) => e === t.activeRule || e.startsWith(`${t.activeRule}/`));
18
+ }
19
+ function N(e) {
20
+ return A[e.name] || (A[e.name] = {
21
+ name: e.name,
22
+ title: e.title,
23
+ entry: e.entry,
24
+ activeRule: e.activeRule,
25
+ status: "idle",
26
+ updatedAt: Date.now()
27
+ }, A[e.name]);
28
+ }
29
+ function P(e) {
30
+ B(e, {
31
+ status: "loading",
32
+ message: void 0
33
+ });
34
+ }
35
+ function F(e) {
36
+ B(e, {
37
+ status: "mounted",
38
+ message: void 0
39
+ });
40
+ }
41
+ function I(e, t) {
42
+ V(e, {
43
+ status: "error",
44
+ message: H(t)
45
+ });
46
+ }
47
+ function L(e, t) {
48
+ let n = A[e];
49
+ return n ? (n.status = "error", n.message = H(t), n.updatedAt = Date.now(), !0) : !1;
50
+ }
51
+ function R(e, t, n) {
52
+ j[t] = {
53
+ path: t,
54
+ name: e.name,
55
+ title: e.title,
56
+ entry: e.entry,
57
+ activeRule: e.activeRule,
58
+ message: H(n),
59
+ updatedAt: Date.now()
60
+ };
61
+ }
62
+ function z(e) {
63
+ delete j[e];
64
+ }
65
+ function B(e, t) {
66
+ let n = A[e];
67
+ n && (n.status = t.status, n.message = t.message, n.updatedAt = Date.now());
68
+ }
69
+ function V(e, t) {
70
+ let n = N(e);
71
+ n.title = e.title, n.entry = e.entry, n.activeRule = e.activeRule, n.status = t.status, n.message = t.message, n.updatedAt = Date.now();
72
+ }
73
+ function H(e) {
74
+ let t = U(e);
75
+ return t ? G(W(t)) : "子应用入口不可访问、服务未启动,或加载过程中发生异常。";
76
+ }
77
+ function U(e) {
78
+ return e instanceof Error ? e.message : typeof e == "string" ? e : "";
79
+ }
80
+ function W(e) {
81
+ return e.trim().replace(/^(application ['"][^'"]+['"] died in status [A-Z_]+:\s*)\1+/, "$1");
82
+ }
83
+ function G(e) {
84
+ let t = e.trim(), n = t.toLowerCase(), r = t.match(/application ['"]([^'"]+)['"]/)?.[1], i = r ? `子应用“${r}”` : "子应用";
85
+ 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;
86
+ }
87
+ //#endregion
88
+ //#region src/main/micro-apps/types.ts
89
+ var K = "morningfast:theme-change", q = !1, J = !1;
90
+ function Y() {
91
+ if (q) {
92
+ X();
93
+ return;
94
+ }
95
+ q = !0;
96
+ let e = i(n());
97
+ e.forEach(N), O(e.map((e) => ({
98
+ name: e.name,
99
+ entry: e.entry,
100
+ container: e.container,
101
+ activeRule: e.activeRule,
102
+ props: ie(e)
103
+ })), {
104
+ beforeLoad: [async (e) => {
105
+ z(window.location.pathname), P(e.name);
106
+ }],
107
+ afterMount: [async (e) => {
108
+ z(window.location.pathname), F(e.name);
109
+ }]
110
+ }), D((t) => {
111
+ let n = t instanceof ErrorEvent ? t.error || t.message : t, r = Z(n) || Z(t);
112
+ if (r && L(r, n)) {
113
+ let t = e.find((e) => e.name === r);
114
+ t && R(t, window.location.pathname, n);
115
+ return;
116
+ }
117
+ e.forEach((e) => {
118
+ (window.location.pathname === e.activeRule || window.location.pathname.startsWith(`${e.activeRule}/`)) && (I(e, n), R(e, window.location.pathname, n));
119
+ });
120
+ }), X(), ae();
121
+ }
122
+ function X() {
123
+ J || document.querySelector("#micro-app-container") && (J = !0, k({
124
+ prefetch: !1,
125
+ sandbox: { experimentalStyleIsolation: !0 },
126
+ urlRerouteOnly: !0
127
+ }));
128
+ }
129
+ function Z(e) {
130
+ return (e instanceof Error ? e.message : String(e || "")).match(/application ['"]?([^'"\s]+)['"]?/i)?.[1];
131
+ }
132
+ function ie(t) {
133
+ let n = e();
134
+ return {
135
+ basePath: t.activeRule,
136
+ app: r(t),
137
+ runtime: {
138
+ env: "production",
139
+ apiBaseUrl: "/api"
140
+ },
141
+ theme: Q(n.isDark),
142
+ getRuntimeProps: () => ({ theme: Q(n.isDark) })
143
+ };
144
+ }
145
+ function ae() {
146
+ let t = e();
147
+ w(() => [
148
+ t.isDark,
149
+ t.themeColor,
150
+ t.themeColorPosition
151
+ ], () => {
152
+ window.setTimeout(() => {
153
+ oe(Q(t.isDark));
154
+ }, 0);
155
+ });
156
+ }
157
+ function oe(e) {
158
+ window.dispatchEvent(new CustomEvent(K, { detail: e }));
159
+ }
160
+ function Q(e) {
161
+ let t = getComputedStyle(document.documentElement);
162
+ return {
163
+ colorPrimary: $(t, "--el-color-primary", "#409EFF"),
164
+ colorPrimaryLight3: $(t, "--el-color-primary-light-3", "#79bbff"),
165
+ colorPrimaryLight5: $(t, "--el-color-primary-light-5", "#a0cfff"),
166
+ colorPrimaryLight7: $(t, "--el-color-primary-light-7", "#c6e2ff"),
167
+ colorPrimaryLight8: $(t, "--el-color-primary-light-8", "#d9ecff"),
168
+ colorPrimaryLight9: $(t, "--el-color-primary-light-9", "#ecf5ff"),
169
+ colorPrimaryDark2: $(t, "--el-color-primary-dark-2", "#337ecc"),
170
+ mode: e ? "dark" : "light"
171
+ };
172
+ }
173
+ function $(e, t, n) {
174
+ return e.getPropertyValue(t).trim() || n;
175
+ }
176
+ //#endregion
177
+ //#region src/main/pages/micro/MicroAppView.vue?vue&type=script&setup=true&lang.ts
178
+ var se = { class: "micro-app-page" }, ce = {
179
+ key: 0,
180
+ class: "micro-app-page__state micro-app-page__state--error"
181
+ }, le = { class: "micro-app-page__body" }, ue = { class: "micro-app-page__desc" }, de = { class: "micro-app-page__meta" }, fe = { key: 0 }, pe = { key: 1 }, me = { key: 2 }, he = { class: "micro-app-page__actions" }, ge = ["id"], _e = /* @__PURE__ */ t(/* @__PURE__ */ m({
182
+ name: "MicroAppView",
183
+ __name: "MicroAppView",
184
+ setup(e) {
185
+ let t = o(), n = ne(), r = b(""), i = null, m = s(() => M(t.path)), y = s(() => {
186
+ let e = m.value;
187
+ return e ? n[e.name] : void 0;
188
+ }), D = s(() => re(t.path)), O = s(() => y.value?.title || m.value?.title || D.value?.title || "未知子应用"), k = s(() => y.value?.entry || m.value?.entry || D.value?.entry || "-"), A = s(() => y.value?.message ? y.value.message : D.value?.message ? D.value.message : m.value ? "子应用暂时无法访问,请稍后重试。" : "当前路径没有匹配到子应用配置,请检查应用配置里的路由前缀。"), j = s(() => t.path.startsWith("/micro/")), N = s(() => y.value?.status === "error" || !!D.value || !!r.value || j.value && !m.value);
189
+ w(() => t.path, () => {
190
+ h(() => {
191
+ Y(), P();
192
+ });
193
+ }, { immediate: !0 }), _(() => {
194
+ h(() => {
195
+ Y(), P();
196
+ });
197
+ }), w(() => y.value?.status, (e) => {
198
+ e === "mounted" && (F(), r.value = "");
199
+ }), g(() => {
200
+ F();
201
+ });
202
+ function P() {
203
+ F(), r.value = "", !(!j.value || !m.value) && (i = window.setTimeout(() => {
204
+ y.value?.status !== "mounted" && (r.value = "子应用暂时无法访问,请稍后重试。");
205
+ }, 15e3));
206
+ }
207
+ function F() {
208
+ i !== null && (window.clearTimeout(i), i = null);
209
+ }
210
+ function I() {
211
+ window.location.reload();
212
+ }
213
+ function L() {
214
+ let e = k.value;
215
+ e && e !== "-" && window.open(e, "_blank", "noopener,noreferrer");
216
+ }
217
+ return (e, t) => {
218
+ let n = x("el-icon"), i = x("el-button");
219
+ return v(), u("div", se, [N.value ? (v(), u("div", ce, [p(n, { class: "micro-app-page__icon" }, {
220
+ default: T(() => [p(C(E))]),
221
+ _: 1
222
+ }), d("div", le, [
223
+ t[6] ||= d("p", { class: "micro-app-page__title" }, "子应用加载失败", -1),
224
+ d("p", ue, S(A.value), 1),
225
+ d("dl", de, [
226
+ d("div", null, [t[0] ||= d("dt", null, "应用", -1), d("dd", null, S(O.value), 1)]),
227
+ C(!1) ? (v(), u("div", fe, [t[1] ||= d("dt", null, "入口", -1), d("dd", null, S(k.value), 1)])) : l("", !0),
228
+ y.value?.message ? (v(), u("div", pe, [t[2] ||= d("dt", null, "原因", -1), d("dd", null, S(y.value.message), 1)])) : r.value ? (v(), u("div", me, [t[3] ||= d("dt", null, "原因", -1), d("dd", null, S(r.value), 1)])) : l("", !0)
229
+ ]),
230
+ d("div", he, [p(i, {
231
+ type: "primary",
232
+ icon: C(te),
233
+ onClick: I
234
+ }, {
235
+ default: T(() => [...t[4] ||= [f("重新加载", -1)]]),
236
+ _: 1
237
+ }, 8, ["icon"]), C(!1) && (y.value?.entry || m.value?.entry) ? (v(), c(i, {
238
+ key: 0,
239
+ icon: C(ee),
240
+ onClick: L
241
+ }, {
242
+ default: T(() => [...t[5] ||= [f(" 打开入口 ", -1)]]),
243
+ _: 1
244
+ }, 8, ["icon"])) : l("", !0)])
245
+ ])])) : l("", !0), d("section", {
246
+ id: C(a),
247
+ class: "micro-app-page__container"
248
+ }, null, 8, ge)]);
249
+ };
250
+ }
251
+ }), [["__scopeId", "data-v-90c11f85"]]);
252
+ //#endregion
253
+ export { _e as default };
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./_plugin-vue_export-helper-DvRHjpsZ.js";
2
- import { a as t, i as n, n as r } from "./config-DkMAgPn_.js";
2
+ import { a as t, i as n, n as r } from "./config-MbLdbbb7.js";
3
3
  import { ElMessage as i } from "element-plus";
4
4
  import { Fragment as a, computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, normalizeClass as p, openBlock as m, reactive as h, ref as g, renderList as _, resolveComponent as v, toDisplayString as y, withCtx as b, withModifiers as x } from "vue";
5
5
  //#region src/main/pages/system/application-config/index.vue?vue&type=script&setup=true&lang.ts
@@ -223,7 +223,7 @@ var S = { class: "app-config-page" }, C = { class: "app-config-page__apps" }, w
223
223
  default: b(() => [d(h, {
224
224
  modelValue: K.entry,
225
225
  "onUpdate:modelValue": t[2] ||= (e) => K.entry = e,
226
- placeholder: "例如 http://localhost:5174"
226
+ placeholder: "例如 http://localhost:8082"
227
227
  }, null, 8, ["modelValue"])]),
228
228
  _: 1
229
229
  })]),
@@ -282,6 +282,6 @@ var S = { class: "app-config-page" }, C = { class: "app-config-page__apps" }, w
282
282
  ]);
283
283
  };
284
284
  }
285
- }), [["__scopeId", "data-v-0066cec3"]]);
285
+ }), [["__scopeId", "data-v-ada45daa"]]);
286
286
  //#endregion
287
287
  export { R as default };
@@ -6,7 +6,7 @@ var n = "system:apps", r = [{
6
6
  type: "sub",
7
7
  description: "独立业务子应用,先在本地配置里测试子应用结构和菜单入口。",
8
8
  basePath: "/micro/sub-app",
9
- entry: "http://localhost:5174"
9
+ entry: "http://localhost:8082"
10
10
  }], i = "micro-app-container";
11
11
  function a() {
12
12
  return t(n, r).filter((e) => e.type === "sub");
@@ -19,7 +19,7 @@ function s(e) {
19
19
  id: e.id,
20
20
  name: l(e),
21
21
  title: e.name,
22
- entry: e.entry || "http://localhost:5174",
22
+ entry: e.entry || "http://localhost:8082",
23
23
  activeRule: u(e.basePath),
24
24
  container: "#micro-app-container"
25
25
  }));
@@ -1111,32 +1111,28 @@ var wn = {
1111
1111
  keyword: {}
1112
1112
  },
1113
1113
  setup(e) {
1114
- let t = e, n = _(), r = w(() => bn(t.node.title, t.keyword ?? ""));
1115
- function i() {
1116
- t.node.children?.length || n.push(t.node.fullPath);
1117
- }
1118
- return (t, n) => {
1119
- let a = z("el-icon"), o = z("AppSidebarNode", !0), s = z("el-sub-menu"), c = z("el-menu-item");
1120
- return e.node.children?.length ? (I(), E(s, {
1114
+ let t = e, n = w(() => bn(t.node.title, t.keyword ?? ""));
1115
+ return (t, r) => {
1116
+ let i = z("el-icon"), a = z("AppSidebarNode", !0), o = z("el-sub-menu"), s = z("el-menu-item");
1117
+ return e.node.children?.length ? (I(), E(o, {
1121
1118
  key: 0,
1122
1119
  index: e.node.fullPath
1123
1120
  }, {
1124
- title: G(() => [j(a, null, {
1121
+ title: G(() => [j(i, null, {
1125
1122
  default: G(() => [(I(), E(B(H($)(e.node.icon))))]),
1126
1123
  _: 1
1127
- }), k("span", { innerHTML: r.value }, null, 8, En)]),
1128
- default: G(() => [(I(!0), O(x, null, R(e.node.children, (t) => (I(), E(o, {
1124
+ }), k("span", { innerHTML: n.value }, null, 8, En)]),
1125
+ default: G(() => [(I(!0), O(x, null, R(e.node.children, (t) => (I(), E(a, {
1129
1126
  key: t.fullPath,
1130
1127
  node: t,
1131
1128
  keyword: e.keyword
1132
1129
  }, null, 8, ["node", "keyword"]))), 128))]),
1133
1130
  _: 1
1134
- }, 8, ["index"])) : (I(), E(c, {
1131
+ }, 8, ["index"])) : (I(), E(s, {
1135
1132
  key: 1,
1136
- index: e.node.fullPath,
1137
- onClick: i
1133
+ index: e.node.fullPath
1138
1134
  }, {
1139
- default: G(() => [k("span", { innerHTML: r.value }, null, 8, Dn)]),
1135
+ default: G(() => [k("span", { innerHTML: n.value }, null, 8, Dn)]),
1140
1136
  _: 1
1141
1137
  }, 8, ["index"]));
1142
1138
  };
@@ -1148,18 +1144,18 @@ var wn = {
1148
1144
  name: "AppSidebar",
1149
1145
  __name: "AppSidebar",
1150
1146
  setup(e) {
1151
- let t = f(), n = l(), { activeMenu: r, sideMenus: i } = Nt(), a = L(""), o = w(() => t.isSidebarMenuSearch ? yn(i.value, a.value) : i.value), s = w(() => !t.isSidebarMenuSearch || !a.value.trim() ? [] : u(o.value)), c = w(() => t.isSidebarMenuSearch ? `search:${t.layoutMode}:${t.selectedTopMenuPath}:${a.value.trim()}:${s.value.join("|")}` : `default:${t.layoutMode}:${t.selectedTopMenuPath}`);
1147
+ let t = f(), n = l(), { activeMenu: r, sideMenus: i } = Nt(), a = L(""), o = w(() => t.isSidebarMenuSearch ? yn(i.value, a.value) : i.value), s = w(() => !t.isSidebarMenuSearch || !a.value.trim() ? [] : c(o.value));
1152
1148
  U(() => t.isSidebarMenuSearch, (e) => {
1153
1149
  e || (a.value = "");
1154
1150
  });
1155
- function u(e) {
1151
+ function c(e) {
1156
1152
  let t = [];
1157
- for (let n of e) n.children?.length && (t.push(n.fullPath), t.push(...u(n.children)));
1153
+ for (let n of e) n.children?.length && (t.push(n.fullPath), t.push(...c(n.children)));
1158
1154
  return t;
1159
1155
  }
1160
1156
  return (e, i) => {
1161
- let l = z("el-menu"), u = z("el-scrollbar"), d = z("el-aside");
1162
- return H(t).layoutMode === "top" ? D("", !0) : (I(), E(d, {
1157
+ let c = z("el-menu"), l = z("el-scrollbar"), u = z("el-aside");
1158
+ return H(t).layoutMode === "top" ? D("", !0) : (I(), E(u, {
1163
1159
  key: 0,
1164
1160
  width: H(t).sidebarCollapsed ? "72px" : "220px",
1165
1161
  class: P(["app-layout__aside", { "is-mix-mode": H(t).layoutMode === "mix" }])
@@ -1188,14 +1184,14 @@ var wn = {
1188
1184
  keyword: a.value,
1189
1185
  "onUpdate:keyword": i[0] ||= (e) => a.value = e
1190
1186
  }, null, 8, ["collapsed", "keyword"])) : D("", !0),
1191
- j(u, null, {
1192
- default: G(() => [(I(), E(l, {
1193
- key: c.value,
1187
+ j(l, null, {
1188
+ default: G(() => [j(c, {
1194
1189
  collapse: H(t).sidebarCollapsed,
1195
1190
  "default-active": H(r),
1196
1191
  "default-openeds": s.value,
1197
1192
  class: "app-layout__menu",
1198
- router: ""
1193
+ router: "",
1194
+ "unique-opened": ""
1199
1195
  }, {
1200
1196
  default: G(() => [(I(!0), O(x, null, R(o.value, (e) => (I(), E(On, {
1201
1197
  key: e.fullPath,
@@ -1207,7 +1203,7 @@ var wn = {
1207
1203
  "collapse",
1208
1204
  "default-active",
1209
1205
  "default-openeds"
1210
- ]))]),
1206
+ ])]),
1211
1207
  _: 1
1212
1208
  })
1213
1209
  ]),
@@ -1671,12 +1667,12 @@ function Jn(e = []) {
1671
1667
  children: [{
1672
1668
  path: "sub-app/demo/orders",
1673
1669
  name: "micro-sub-app-demo-orders",
1674
- component: () => import("./MicroAppView-DqTrIZZa.js"),
1670
+ component: () => import("./MicroAppView-P0ma5ujY.js"),
1675
1671
  meta: { title: "订单管理" }
1676
1672
  }, {
1677
1673
  path: "sub-app/:pathMatch(.*)*",
1678
1674
  name: "micro-sub-app-fallback",
1679
- component: () => import("./MicroAppView-DqTrIZZa.js"),
1675
+ component: () => import("./MicroAppView-P0ma5ujY.js"),
1680
1676
  meta: {
1681
1677
  title: "子应用页面",
1682
1678
  hidden: !0
@@ -1694,7 +1690,7 @@ function Jn(e = []) {
1694
1690
  children: [{
1695
1691
  path: "apps",
1696
1692
  name: "config-apps",
1697
- component: () => import("./application-config-0d6f-odq.js"),
1693
+ component: () => import("./application-config-kHggv6q1.js"),
1698
1694
  meta: {
1699
1695
  title: "应用配置",
1700
1696
  icon: "Connection"
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { MICRO_AUTH_EXPIRED_EVENT as e } from "./micro-contract.js";
2
- import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./chunks/main-CfTD1njJ.js";
2
+ import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l, u } from "./chunks/main-B00aDVlh.js";
3
3
  import { ApiError as d, RequestManager as f, createRequestClient as p, formatErrorMessage as m } from "./request.js";
4
4
  import { a as h, i as g, n as _, r as v, t as y } from "./chunks/auth-C3RvRgcW.js";
5
5
  import { t as b } from "./chunks/system-BbMsTIBR.js";
@@ -1,5 +1,5 @@
1
1
  import { MicroAppConfig, MicroAppInfo } from './types';
2
- export declare const DEFAULT_SUB_APP_ENTRY = "http://localhost:5174";
2
+ export declare const DEFAULT_SUB_APP_ENTRY = "http://localhost:8082";
3
3
  export interface AppConfigItem {
4
4
  id: string;
5
5
  name: string;
package/dist/main.js CHANGED
@@ -1,4 +1,4 @@
1
- import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./chunks/main-CfTD1njJ.js";
1
+ import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./chunks/main-B00aDVlh.js";
2
2
  import { a as u, i as d, n as f, r as p, t as m } from "./chunks/auth-C3RvRgcW.js";
3
3
  import { t as h } from "./chunks/system-BbMsTIBR.js";
4
4
  import { t as g } from "./chunks/app-Cn5iHmfI.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@morningfast/platform",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Morningfast platform runtime for main and sub applications.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -1,249 +0,0 @@
1
- import { t as e } from "./app-Cn5iHmfI.js";
2
- import { t } from "./_plugin-vue_export-helper-DvRHjpsZ.js";
3
- import { n, o as r, r as i, t as a } from "./config-DkMAgPn_.js";
4
- import { useRoute as o } from "vue-router";
5
- import { computed as s, createBlock as c, createCommentVNode as l, createElementBlock as u, createElementVNode as d, createTextVNode as f, createVNode as p, defineComponent as m, nextTick as h, onBeforeUnmount as g, onMounted as ee, openBlock as _, reactive as v, ref as y, resolveComponent as b, toDisplayString as x, unref as S, watch as C, withCtx as w } from "vue";
6
- import { Link as te, RefreshRight as T, WarningFilled as ne } from "@element-plus/icons-vue";
7
- import { addGlobalUncaughtErrorHandler as E, registerMicroApps as D, start as O } from "qiankun";
8
- //#region src/main/micro-apps/status.ts
9
- var k = v({}), A = v({});
10
- function j() {
11
- return k;
12
- }
13
- function M(e) {
14
- return A[e];
15
- }
16
- function N(e) {
17
- return i(n()).find((t) => e === t.activeRule || e.startsWith(`${t.activeRule}/`));
18
- }
19
- function P(e) {
20
- return k[e.name] || (k[e.name] = {
21
- name: e.name,
22
- title: e.title,
23
- entry: e.entry,
24
- activeRule: e.activeRule,
25
- status: "idle",
26
- updatedAt: Date.now()
27
- }, k[e.name]);
28
- }
29
- function F(e) {
30
- V(e, {
31
- status: "loading",
32
- message: void 0
33
- });
34
- }
35
- function I(e) {
36
- V(e, {
37
- status: "mounted",
38
- message: void 0
39
- });
40
- }
41
- function L(e, t) {
42
- H(e, {
43
- status: "error",
44
- message: U(t)
45
- });
46
- }
47
- function R(e, t) {
48
- let n = k[e];
49
- return n ? (n.status = "error", n.message = U(t), n.updatedAt = Date.now(), !0) : !1;
50
- }
51
- function z(e, t, n) {
52
- A[t] = {
53
- path: t,
54
- name: e.name,
55
- title: e.title,
56
- entry: e.entry,
57
- activeRule: e.activeRule,
58
- message: U(n),
59
- updatedAt: Date.now()
60
- };
61
- }
62
- function B(e) {
63
- delete A[e];
64
- }
65
- function V(e, t) {
66
- let n = k[e];
67
- n && (n.status = t.status, n.message = t.message, n.updatedAt = Date.now());
68
- }
69
- function H(e, t) {
70
- let n = P(e);
71
- n.title = e.title, n.entry = e.entry, n.activeRule = e.activeRule, n.status = t.status, n.message = t.message, n.updatedAt = Date.now();
72
- }
73
- function U(e) {
74
- let t = W(e);
75
- return t ? G(t) : "子应用入口不可访问、服务未启动,或加载过程中发生异常。";
76
- }
77
- function W(e) {
78
- return e instanceof Error ? e.message : typeof e == "string" ? e : "";
79
- }
80
- function G(e) {
81
- return e.trim().replace(/^(application ['"][^'"]+['"] died in status [A-Z_]+:\s*)\1+/, "$1");
82
- }
83
- //#endregion
84
- //#region src/main/micro-apps/types.ts
85
- var K = "morningfast:theme-change", q = !1, J = !1;
86
- function Y() {
87
- if (q) {
88
- X();
89
- return;
90
- }
91
- q = !0;
92
- let e = i(n());
93
- e.forEach(P), D(e.map((e) => ({
94
- name: e.name,
95
- entry: e.entry,
96
- container: e.container,
97
- activeRule: e.activeRule,
98
- props: re(e)
99
- })), {
100
- beforeLoad: [async (e) => {
101
- B(window.location.pathname), F(e.name);
102
- }],
103
- afterMount: [async (e) => {
104
- B(window.location.pathname), I(e.name);
105
- }]
106
- }), E((t) => {
107
- let n = t instanceof ErrorEvent ? t.error || t.message : t, r = Z(n) || Z(t);
108
- if (r && R(r, n)) {
109
- let t = e.find((e) => e.name === r);
110
- t && z(t, window.location.pathname, n);
111
- return;
112
- }
113
- e.forEach((e) => {
114
- (window.location.pathname === e.activeRule || window.location.pathname.startsWith(`${e.activeRule}/`)) && (L(e, n), z(e, window.location.pathname, n));
115
- });
116
- }), X(), ie();
117
- }
118
- function X() {
119
- J || document.querySelector("#micro-app-container") && (J = !0, O({
120
- prefetch: !1,
121
- sandbox: { experimentalStyleIsolation: !0 },
122
- urlRerouteOnly: !0
123
- }));
124
- }
125
- function Z(e) {
126
- return (e instanceof Error ? e.message : String(e || "")).match(/application ['"]?([^'"\s]+)['"]?/i)?.[1];
127
- }
128
- function re(t) {
129
- let n = e();
130
- return {
131
- basePath: t.activeRule,
132
- app: r(t),
133
- runtime: {
134
- env: "production",
135
- apiBaseUrl: "/api"
136
- },
137
- theme: Q(n.isDark),
138
- getRuntimeProps: () => ({ theme: Q(n.isDark) })
139
- };
140
- }
141
- function ie() {
142
- let t = e();
143
- C(() => [
144
- t.isDark,
145
- t.themeColor,
146
- t.themeColorPosition
147
- ], () => {
148
- window.setTimeout(() => {
149
- ae(Q(t.isDark));
150
- }, 0);
151
- });
152
- }
153
- function ae(e) {
154
- window.dispatchEvent(new CustomEvent(K, { detail: e }));
155
- }
156
- function Q(e) {
157
- let t = getComputedStyle(document.documentElement);
158
- return {
159
- colorPrimary: $(t, "--el-color-primary", "#409EFF"),
160
- colorPrimaryLight3: $(t, "--el-color-primary-light-3", "#79bbff"),
161
- colorPrimaryLight5: $(t, "--el-color-primary-light-5", "#a0cfff"),
162
- colorPrimaryLight7: $(t, "--el-color-primary-light-7", "#c6e2ff"),
163
- colorPrimaryLight8: $(t, "--el-color-primary-light-8", "#d9ecff"),
164
- colorPrimaryLight9: $(t, "--el-color-primary-light-9", "#ecf5ff"),
165
- colorPrimaryDark2: $(t, "--el-color-primary-dark-2", "#337ecc"),
166
- mode: e ? "dark" : "light"
167
- };
168
- }
169
- function $(e, t, n) {
170
- return e.getPropertyValue(t).trim() || n;
171
- }
172
- //#endregion
173
- //#region src/main/pages/micro/MicroAppView.vue?vue&type=script&setup=true&lang.ts
174
- var oe = { class: "micro-app-page" }, se = {
175
- key: 0,
176
- class: "micro-app-page__state micro-app-page__state--error"
177
- }, ce = { class: "micro-app-page__body" }, le = { class: "micro-app-page__desc" }, ue = { class: "micro-app-page__meta" }, de = { key: 0 }, fe = { key: 1 }, pe = { key: 2 }, me = { class: "micro-app-page__actions" }, he = ["id"], ge = /* @__PURE__ */ t(/* @__PURE__ */ m({
178
- name: "MicroAppView",
179
- __name: "MicroAppView",
180
- setup(e) {
181
- let t = o(), n = j(), r = y(""), i = null, m = s(() => N(t.path)), v = s(() => {
182
- let e = m.value;
183
- return e ? n[e.name] : void 0;
184
- }), E = s(() => M(t.path)), D = s(() => v.value?.title || m.value?.title || E.value?.title || "未知子应用"), O = s(() => v.value?.entry || m.value?.entry || E.value?.entry || "-"), k = s(() => v.value?.message ? v.value.message : E.value?.message ? E.value.message : m.value ? "子应用暂时无法访问,请稍后重试。" : "当前路径没有匹配到子应用配置,请检查应用配置里的路由前缀。"), A = s(() => t.path.startsWith("/micro/")), P = s(() => v.value?.status === "error" || !!E.value || !!r.value || A.value && !m.value);
185
- C(() => t.path, () => {
186
- h(() => {
187
- Y(), F();
188
- });
189
- }, { immediate: !0 }), ee(() => {
190
- h(() => {
191
- Y(), F();
192
- });
193
- }), C(() => v.value?.status, (e) => {
194
- e === "mounted" && (I(), r.value = "");
195
- }), g(() => {
196
- I();
197
- });
198
- function F() {
199
- I(), r.value = "", !(!A.value || !m.value) && (i = window.setTimeout(() => {
200
- v.value?.status !== "mounted" && (r.value = "子应用暂时无法访问,请稍后重试。");
201
- }, 15e3));
202
- }
203
- function I() {
204
- i !== null && (window.clearTimeout(i), i = null);
205
- }
206
- function L() {
207
- window.location.reload();
208
- }
209
- function R() {
210
- let e = O.value;
211
- e && e !== "-" && window.open(e, "_blank", "noopener,noreferrer");
212
- }
213
- return (e, t) => {
214
- let n = b("el-icon"), i = b("el-button");
215
- return _(), u("div", oe, [P.value ? (_(), u("div", se, [p(n, { class: "micro-app-page__icon" }, {
216
- default: w(() => [p(S(ne))]),
217
- _: 1
218
- }), d("div", ce, [
219
- t[6] ||= d("p", { class: "micro-app-page__title" }, "子应用加载失败", -1),
220
- d("p", le, x(k.value), 1),
221
- d("dl", ue, [
222
- d("div", null, [t[0] ||= d("dt", null, "应用", -1), d("dd", null, x(D.value), 1)]),
223
- S(!1) ? (_(), u("div", de, [t[1] ||= d("dt", null, "入口", -1), d("dd", null, x(O.value), 1)])) : l("", !0),
224
- v.value?.message ? (_(), u("div", fe, [t[2] ||= d("dt", null, "原因", -1), d("dd", null, x(v.value.message), 1)])) : r.value ? (_(), u("div", pe, [t[3] ||= d("dt", null, "原因", -1), d("dd", null, x(r.value), 1)])) : l("", !0)
225
- ]),
226
- d("div", me, [p(i, {
227
- type: "primary",
228
- icon: S(T),
229
- onClick: L
230
- }, {
231
- default: w(() => [...t[4] ||= [f("重新加载", -1)]]),
232
- _: 1
233
- }, 8, ["icon"]), S(!1) && (v.value?.entry || m.value?.entry) ? (_(), c(i, {
234
- key: 0,
235
- icon: S(te),
236
- onClick: R
237
- }, {
238
- default: w(() => [...t[5] ||= [f(" 打开入口 ", -1)]]),
239
- _: 1
240
- }, 8, ["icon"])) : l("", !0)])
241
- ])])) : l("", !0), d("section", {
242
- id: S(a),
243
- class: "micro-app-page__container"
244
- }, null, 8, he)]);
245
- };
246
- }
247
- }), [["__scopeId", "data-v-90c11f85"]]);
248
- //#endregion
249
- export { ge as default };