@das-fed/upf-web 6.4.0-dev.203 → 6.4.0-dev.204

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.
@@ -1,112 +1,112 @@
1
- import { reactive as L, ref as j, createApp as B } from "vue";
1
+ import { reactive as U, ref as O, createApp as B } from "vue";
2
2
  import { initTheme as I } from "@das-fed/upf-web/packages/theme/index";
3
- import { DasWebLayout as N } from "@das-fed/upf-web/packages/layout/index";
4
- import { createPinia as D } from "pinia";
5
- import W from "pinia-plugin-persistedstate";
6
- import { createRouter as C, createWebHistory as M } from "vue-router";
7
- import { getUrlParams as O, handleI18nData as S } from "@das-fed/upf-utils/common-tools";
8
- import { getConfig as z } from "@das-fed/upf-utils/config";
9
- const H = {
10
- install: (e, n) => {
11
- var a;
12
- const r = (a = n == null ? void 0 : n.plugins) == null ? void 0 : a.glob;
13
- r && Object.values(r).sort((t, s) => (t.index ?? 0) - (s.index ?? 0)).filter((t) => t ? !!(t.default && t.default.install || t.install) : !1).forEach((t) => {
14
- t.default && t.default.install && e.use(t.default, n), t.install && e.use(t, n);
3
+ import { DasWebLayout as D } from "@das-fed/upf-web/packages/layout/index";
4
+ import { createPinia as W } from "pinia";
5
+ import C from "pinia-plugin-persistedstate";
6
+ import { createRouter as M, createWebHistory as S } from "vue-router";
7
+ import { getUrlParams as z, handleI18nData as H } from "@das-fed/upf-utils/common-tools";
8
+ import { getConfig as K } from "@das-fed/upf-utils/config";
9
+ const q = {
10
+ install: (e, t) => {
11
+ var s;
12
+ const r = (s = t == null ? void 0 : t.plugins) == null ? void 0 : s.glob;
13
+ r && Object.values(r).sort((a, o) => (a.index ?? 0) - (o.index ?? 0)).filter((a) => a ? !!(a.default && a.default.install || a.install) : !1).forEach((a) => {
14
+ a.default && a.default.install && e.use(a.default, t), a.install && e.use(a, t);
15
15
  });
16
16
  }
17
- }, E = D();
18
- E.use(W);
19
- const P = "language", A = L({});
20
- L({});
21
- L({});
22
- const K = O(location.href, "uiCulture") || "", F = K || window.localStorage.getItem(P) || window.navigator.language || "zh-CN", $ = j(F), G = () => {
17
+ }, v = W();
18
+ v.use(C);
19
+ const N = "language", k = U({});
20
+ U({});
21
+ U({});
22
+ const F = z(location.href, "uiCulture") || "", G = F || window.localStorage.getItem(N) || window.navigator.language || "zh-CN", P = O(G), T = () => {
23
23
  const e = document.documentElement;
24
- e && e.setAttribute("lang", $.value);
25
- }, R = (e = {}, n) => {
24
+ e && e.setAttribute("lang", P.value);
25
+ }, L = (e = {}, t) => {
26
26
  const r = {};
27
- for (const a in e)
28
- for (const t in e[a])
29
- r[t] || (r[t] = {}), r[t][a] = e[a][t] ?? "", A[t] || (A[t] = {}), A[t][a] = r[t][a];
30
- }, T = (e) => {
31
- $.value = e, G();
32
- }, q = {
27
+ for (const s in e)
28
+ for (const a in e[s])
29
+ r[a] || (r[a] = {}), r[a][s] = e[s][a] ?? "", k[a] || (k[a] = {}), k[a][s] = r[a][s];
30
+ }, J = (e) => {
31
+ P.value = e, T();
32
+ }, Q = {
33
33
  loaded: {},
34
- isLoaded(e) {
35
- return !!this.loaded[e];
34
+ isLoaded(e, t) {
35
+ return !!(this.loaded[e] && this.loaded[e][t]);
36
36
  },
37
- markLoaded(e) {
38
- this.loaded[e] = !0;
37
+ markLoaded(e, t) {
38
+ this.loaded[e] || (this.loaded[e] = {}), this.loaded[e][t] = !0;
39
39
  },
40
- markUnloaded(e) {
41
- delete this.loaded[e];
40
+ markUnloaded(e, t) {
41
+ this.loaded[e] && (delete this.loaded[e][t], Object.keys(this.loaded[e]).length === 0 && delete this.loaded[e]);
42
42
  }
43
- }, J = async (e, n) => {
44
- var d, g, l;
45
- const r = z() || {}, a = ((d = r.i18n) == null ? void 0 : d.fromOss) ?? !0, t = ((g = r.i18n) == null ? void 0 : g.isPullBack) ?? !1, s = ((l = r.i18n) == null ? void 0 : l.isDasUI) ?? !0;
43
+ }, V = async (e, t) => {
44
+ var f, h, d;
45
+ const r = K() || {}, s = ((f = r.i18n) == null ? void 0 : f.fromOss) ?? !0, a = ((h = r.i18n) == null ? void 0 : h.isPullBack) ?? !1, o = ((d = r.i18n) == null ? void 0 : d.isDasUI) ?? !0;
46
46
  let i = "/oss/resource/";
47
47
  try {
48
- const f = await S({
49
- baseUrl: a ? i : "/",
50
- currentLang: n,
48
+ const u = await H({
49
+ baseUrl: s ? i : "/",
50
+ currentLang: t,
51
51
  appName: e,
52
- isPullBack: t,
52
+ isPullBack: a,
53
53
  fallbackBaseUrl: "/",
54
- isDasUI: s
54
+ isDasUI: o
55
55
  });
56
- if (!f || !(f != null && f.frontEnd))
56
+ if (!u || !(u != null && u.frontEnd))
57
57
  throw new Error("Failed to fetch i18n data");
58
- return f;
59
- } catch (h) {
60
- throw new Error(`registerResources error: ${h}`);
58
+ return u;
59
+ } catch (g) {
60
+ throw new Error(`registerResources error: ${g}`);
61
61
  }
62
- }, Q = async (e = []) => {
63
- const n = O(location.href, "uiCulture") || window.localStorage.getItem(P) || window.navigator.language || "zh-CN";
62
+ }, X = async (e = [], t = "zh-CN") => {
64
63
  try {
65
- const r = await J(e, n);
66
- r != null && r.frontEnd && typeof r.frontEnd == "object" && Object.keys(r.frontEnd).length && e.forEach((a) => {
67
- r.frontEnd[a] && typeof r.frontEnd[a] == "object" && Object.keys(r.frontEnd[a]).length && R({ [n]: r.frontEnd[a] });
68
- }), r != null && r.dasUiEnd && typeof r.dasUiEnd == "object" && Object.keys(r.dasUiEnd).length && R({ [n]: r.dasUiEnd }), T(n);
64
+ const r = await V(e, t);
65
+ r != null && r.frontEnd && typeof r.frontEnd == "object" && Object.keys(r.frontEnd).length && e.forEach((s) => {
66
+ r.frontEnd[s] && typeof r.frontEnd[s] == "object" && Object.keys(r.frontEnd[s]).length && L({ [t]: r.frontEnd[s] });
67
+ }), r != null && r.dasUiEnd && typeof r.dasUiEnd == "object" && Object.keys(r.dasUiEnd).length && L({ [t]: r.dasUiEnd }), J(t);
69
68
  } catch {
70
69
  }
71
- }, V = (e) => {
72
- var h, p, f, U, v;
73
- const n = ((h = e == null ? void 0 : e.router) == null ? void 0 : h.routerBase) ?? "/", r = ((p = e == null ? void 0 : e.router) == null ? void 0 : p.options) || {};
74
- let a = Object.assign(((f = e == null ? void 0 : e.router) == null ? void 0 : f.glob) || {});
75
- const t = Object.values(a).filter((u) => !!u).flat().sort((u, o) => (u.index ?? 0) - (o.index ?? 0)), s = [];
76
- (U = e == null ? void 0 : e.microApps) == null || U.map((u) => {
77
- var w;
78
- const o = Object.values(((w = u.router) == null ? void 0 : w.glob) || {}).filter((c) => !!c).flat().sort((c, y) => (c.index ?? 0) - (y.index ?? 0));
79
- s.push(
80
- ...o.map((c) => ({ ...c, path: `/${u.microAppName}${c.path}` }))
81
- ), s.push(
82
- ...o.filter((c) => !!c.path).filter((c) => c.path !== "").filter((c) => c.path !== "/").filter((c) => !c.path.startsWith(`/${c.microAppName}`)).map((c) => ({
70
+ }, Y = (e) => {
71
+ var g, p, u, R, j;
72
+ const t = ((g = e == null ? void 0 : e.router) == null ? void 0 : g.routerBase) ?? "/", r = ((p = e == null ? void 0 : e.router) == null ? void 0 : p.options) || {};
73
+ let s = Object.assign(((u = e == null ? void 0 : e.router) == null ? void 0 : u.glob) || {});
74
+ const a = Object.values(s).filter((l) => !!l).flat().sort((l, n) => (l.index ?? 0) - (n.index ?? 0)), o = [];
75
+ (R = e == null ? void 0 : e.microApps) == null || R.map((l) => {
76
+ var A;
77
+ const n = Object.values(((A = l.router) == null ? void 0 : A.glob) || {}).filter((c) => !!c).flat().sort((c, w) => (c.index ?? 0) - (w.index ?? 0));
78
+ o.push(
79
+ ...n.map((c) => ({ ...c, path: `/${l.microAppName}${c.path}` }))
80
+ ), o.push(
81
+ ...n.filter((c) => !!c.path).filter((c) => c.path !== "").filter((c) => c.path !== "/").filter((c) => !c.path.startsWith(`/${c.microAppName}`)).map((c) => ({
83
82
  path: c.path,
84
- redirect: `/${u.microAppName}${c.path}`,
83
+ redirect: `/${l.microAppName}${c.path}`,
85
84
  meta: { ...c.meta || {}, isMicroAppRouteRedirect: !0 }
86
85
  }))
87
86
  );
88
87
  });
89
- const i = ((v = e == null ? void 0 : e.router) == null ? void 0 : v.routers) || [], d = [
90
- ...k(t, e),
91
- ...k(i, e),
92
- ...k(s, e)
93
- ], g = C({ history: M(n), routes: d, ...r }), l = q;
94
- if (Array.isArray(e == null ? void 0 : e.microApps) && e.microApps.length && l) {
95
- const u = /* @__PURE__ */ new Map();
96
- for (const o of e.microApps)
97
- o != null && o.microAppName && (o != null && o.i18n) && u.set(o.microAppName, o.i18n);
98
- g.beforeEach(async (o, w, c) => {
88
+ const i = ((j = e == null ? void 0 : e.router) == null ? void 0 : j.routers) || [], f = [
89
+ ...E(a, e),
90
+ ...E(i, e),
91
+ ...E(o, e)
92
+ ], h = M({ history: S(t), routes: f, ...r }), d = Q;
93
+ if (Array.isArray(e == null ? void 0 : e.microApps) && e.microApps.length && d) {
94
+ const l = /* @__PURE__ */ new Map();
95
+ for (const n of e.microApps)
96
+ n != null && n.microAppName && (n != null && n.i18n) && l.set(n.microAppName, n.i18n);
97
+ h.beforeEach(async (n, A, c) => {
98
+ var w;
99
99
  try {
100
- const y = o.path || "";
101
- for (const [b, m] of u.entries()) {
102
- if (!b || !y.toLowerCase().startsWith(`/${b.toLowerCase()}`)) continue;
103
- if (typeof l.isLoaded == "function" && l.isLoaded(b) || !m || !(m != null && m.length)) break;
100
+ const b = ((w = n.query) == null ? void 0 : w.uiCulture) || window.localStorage.getItem(N) || window.navigator.language || "zh-CN", $ = n.path || "";
101
+ for (const [y, m] of l.entries()) {
102
+ if (!y || !$.toLowerCase().startsWith(`/${y.toLowerCase()}`)) continue;
103
+ if (d.isLoaded(b, y) || !m || !(m != null && m.length)) break;
104
104
  const x = typeof m == "string" ? [m] : m;
105
- typeof l.markLoaded == "function" && l.markLoaded(b);
105
+ d.markLoaded(b, y);
106
106
  try {
107
- await Q(x);
107
+ await X(x, b);
108
108
  } catch {
109
- typeof l.markUnloaded == "function" && l.markUnloaded(b);
109
+ d.markUnloaded(b, y);
110
110
  }
111
111
  break;
112
112
  }
@@ -116,22 +116,22 @@ const K = O(location.href, "uiCulture") || "", F = K || window.localStorage.getI
116
116
  }
117
117
  });
118
118
  }
119
- return { router: g };
120
- }, k = (e, n) => e.map((r) => {
121
- const a = r.meta || {};
122
- return a.keepAlive = a.keepAlive ?? (n == null ? void 0 : n.keepAlive) ?? !0, { ...r, meta: a };
123
- }), ce = (e) => {
124
- var d;
119
+ return { router: h };
120
+ }, E = (e, t) => e.map((r) => {
121
+ const s = r.meta || {};
122
+ return s.keepAlive = s.keepAlive ?? (t == null ? void 0 : t.keepAlive) ?? !0, { ...r, meta: s };
123
+ }), oe = (e) => {
124
+ var f;
125
125
  e || (e = {});
126
- const n = j(!0);
126
+ const t = O(!0);
127
127
  Promise.all([I(e)]).then(() => {
128
- n.value = !1;
128
+ t.value = !1;
129
129
  });
130
- const { container: r, component: a, props: t } = (e == null ? void 0 : e.root) || {}, s = B(a || N, t);
131
- s.use(H, e), s.use(E);
132
- const { router: i } = V(e);
133
- return s.use(i), s.mount(r || "#app"), (d = window.top) != null && d.vueRouter || window.top && (window.top.vueRouter = i), { app: s, router: i, loading: n, store: E };
130
+ const { container: r, component: s, props: a } = (e == null ? void 0 : e.root) || {}, o = B(s || D, a);
131
+ o.use(q, e), o.use(v);
132
+ const { router: i } = Y(e);
133
+ return o.use(i), o.mount(r || "#app"), (f = window.top) != null && f.vueRouter || window.top && (window.top.vueRouter = i), { app: o, router: i, loading: t, store: v };
134
134
  };
135
135
  export {
136
- ce as createDasWebApp
136
+ oe as createDasWebApp
137
137
  };
Binary file
Binary file
@@ -4,10 +4,10 @@ import { langType } from './type';
4
4
  * 内存存储:记录本次页面会话中哪些 micro app 的 i18n 已加载。
5
5
  */
6
6
  export declare const microI18nStore: {
7
- loaded: Record<string, boolean>;
8
- isLoaded(name: string): boolean;
9
- markLoaded(name: string): void;
10
- markUnloaded(name: string): void;
7
+ loaded: Record<string, Record<string, boolean>>;
8
+ isLoaded(lang: langType, name: string): boolean;
9
+ markLoaded(lang: langType, name: string): void;
10
+ markUnloaded(lang: langType, name: string): void;
11
11
  };
12
12
  export declare const registerI18nData: (appName: string[], currentLang: langType) => Promise<Record<string, any>>;
13
- export declare const registerMicroI18nData: (i18nCodes?: string[]) => Promise<void>;
13
+ export declare const registerMicroI18nData: (i18nCodes?: string[], currentLang?: langType) => Promise<void>;
Binary file
Binary file