@das-fed/upf-web 6.4.0-dev.201 → 6.4.0-dev.203
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/es5.js +84 -84
- package/esm-map.json +2 -4
- package/{index-Dda2lRZV.js → index-4gY_dDQ-.js} +1 -1
- package/index-4gY_dDQ-.js.gz +0 -0
- package/{index-BJ0qSbnM.js → index-DBJqJe-a.js} +1899 -1863
- package/index-DBJqJe-a.js.gz +0 -0
- package/{index-DpqH658a.js → index-DC6Eay0b.js} +1 -1
- package/index.js +17 -19
- package/package.json +6 -6
- package/packages/create-das-web-app/es5.js +294 -81
- package/packages/create-das-web-app/index.js +127 -49
- package/packages/create-das-web-app/index.js.gz +0 -0
- package/packages/layout/index.js.gz +0 -0
- package/packages/micro-frontend/index.js.gz +0 -0
- package/types/i18n/microI18n.d.ts +13 -0
- package/types/index.d.ts +0 -1
- package/index-BJ0qSbnM.js.gz +0 -0
- package/index-Dda2lRZV.js.gz +0 -0
- package/types/i18n/register.d.ts +0 -4
|
@@ -1,59 +1,137 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { initTheme as
|
|
3
|
-
import { DasWebLayout as
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { reactive as L, ref as j, createApp as B } from "vue";
|
|
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);
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 = () => {
|
|
23
|
+
const e = document.documentElement;
|
|
24
|
+
e && e.setAttribute("lang", $.value);
|
|
25
|
+
}, R = (e = {}, n) => {
|
|
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 = {
|
|
33
|
+
loaded: {},
|
|
34
|
+
isLoaded(e) {
|
|
35
|
+
return !!this.loaded[e];
|
|
36
|
+
},
|
|
37
|
+
markLoaded(e) {
|
|
38
|
+
this.loaded[e] = !0;
|
|
39
|
+
},
|
|
40
|
+
markUnloaded(e) {
|
|
41
|
+
delete this.loaded[e];
|
|
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;
|
|
46
|
+
let i = "/oss/resource/";
|
|
47
|
+
try {
|
|
48
|
+
const f = await S({
|
|
49
|
+
baseUrl: a ? i : "/",
|
|
50
|
+
currentLang: n,
|
|
51
|
+
appName: e,
|
|
52
|
+
isPullBack: t,
|
|
53
|
+
fallbackBaseUrl: "/",
|
|
54
|
+
isDasUI: s
|
|
55
|
+
});
|
|
56
|
+
if (!f || !(f != null && f.frontEnd))
|
|
57
|
+
throw new Error("Failed to fetch i18n data");
|
|
58
|
+
return f;
|
|
59
|
+
} catch (h) {
|
|
60
|
+
throw new Error(`registerResources error: ${h}`);
|
|
61
|
+
}
|
|
62
|
+
}, Q = async (e = []) => {
|
|
63
|
+
const n = O(location.href, "uiCulture") || window.localStorage.getItem(P) || window.navigator.language || "zh-CN";
|
|
64
|
+
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);
|
|
69
|
+
} catch {
|
|
70
|
+
}
|
|
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) => ({
|
|
83
|
+
path: c.path,
|
|
84
|
+
redirect: `/${u.microAppName}${c.path}`,
|
|
85
|
+
meta: { ...c.meta || {}, isMicroAppRouteRedirect: !0 }
|
|
33
86
|
}))
|
|
34
87
|
);
|
|
35
88
|
});
|
|
36
|
-
const
|
|
37
|
-
...
|
|
38
|
-
...i
|
|
39
|
-
...
|
|
40
|
-
];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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) => {
|
|
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;
|
|
104
|
+
const x = typeof m == "string" ? [m] : m;
|
|
105
|
+
typeof l.markLoaded == "function" && l.markLoaded(b);
|
|
106
|
+
try {
|
|
107
|
+
await Q(x);
|
|
108
|
+
} catch {
|
|
109
|
+
typeof l.markUnloaded == "function" && l.markUnloaded(b);
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
} catch {
|
|
114
|
+
} finally {
|
|
115
|
+
c();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
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;
|
|
47
125
|
e || (e = {});
|
|
48
|
-
const
|
|
49
|
-
Promise.all([
|
|
50
|
-
|
|
126
|
+
const n = j(!0);
|
|
127
|
+
Promise.all([I(e)]).then(() => {
|
|
128
|
+
n.value = !1;
|
|
51
129
|
});
|
|
52
|
-
const { container:
|
|
53
|
-
|
|
54
|
-
const { router:
|
|
55
|
-
return
|
|
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 };
|
|
56
134
|
};
|
|
57
135
|
export {
|
|
58
|
-
|
|
136
|
+
ce as createDasWebApp
|
|
59
137
|
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { langType } from './type';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 内存存储:记录本次页面会话中哪些 micro app 的 i18n 已加载。
|
|
5
|
+
*/
|
|
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;
|
|
11
|
+
};
|
|
12
|
+
export declare const registerI18nData: (appName: string[], currentLang: langType) => Promise<Record<string, any>>;
|
|
13
|
+
export declare const registerMicroI18nData: (i18nCodes?: string[]) => Promise<void>;
|
package/types/index.d.ts
CHANGED
package/index-BJ0qSbnM.js.gz
DELETED
|
Binary file
|
package/index-Dda2lRZV.js.gz
DELETED
|
Binary file
|
package/types/i18n/register.d.ts
DELETED