@das-fed/upf-web 6.4.0-hot.6 → 6.4.0-hot.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.
- package/es5.js +42 -42
- package/esm-map.json +4 -1
- package/{index-CihmHNMg.js → index-BHYGpKaC.js} +1 -1
- package/{index-BhEtGWg9.js → index-CrHkmIjO.js} +1 -1
- package/index-CrHkmIjO.js.gz +0 -0
- package/{index-ClQkHyu0.js → index-yBzlMgvo.js} +1217 -1216
- package/index-yBzlMgvo.js.gz +0 -0
- package/index.js +16 -14
- package/package.json +6 -6
- package/packages/create-das-web-app/es5.js +138 -254
- package/packages/create-das-web-app/index.js +67 -122
- package/packages/create-das-web-app/index.js.gz +0 -0
- package/packages/i18n/es5.js +208 -114
- package/packages/i18n/index.js +101 -60
- package/packages/i18n/index.js.gz +0 -0
- package/types/i18n/{microI18n.d.ts → getMicroI18nData.d.ts} +1 -2
- package/types/i18n/index.d.ts +3 -1
- package/index-BhEtGWg9.js.gz +0 -0
- package/index-ClQkHyu0.js.gz +0 -0
package/packages/i18n/index.js
CHANGED
|
@@ -1,44 +1,74 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { reactive as p, ref as b, computed as j } from "vue";
|
|
2
|
+
import { handleI18nData as D, getUrlParams as L } from "@das-fed/upf-utils/common-tools";
|
|
3
|
+
import { getConfig as I } from "@das-fed/upf-utils/config";
|
|
4
|
+
const x = {
|
|
5
|
+
loaded: {},
|
|
6
|
+
isLoaded(t, e) {
|
|
7
|
+
return !!(this.loaded[t] && this.loaded[t][e]);
|
|
8
|
+
},
|
|
9
|
+
markLoaded(t, e) {
|
|
10
|
+
this.loaded[t] || (this.loaded[t] = {}), this.loaded[t][e] = !0;
|
|
11
|
+
},
|
|
12
|
+
markUnloaded(t, e) {
|
|
13
|
+
this.loaded[t] && (delete this.loaded[t][e], Object.keys(this.loaded[t]).length === 0 && delete this.loaded[t]);
|
|
14
|
+
}
|
|
15
|
+
}, U = async (t, e) => {
|
|
16
|
+
var m, u, g;
|
|
17
|
+
const o = I() || {}, a = ((m = o.i18n) == null ? void 0 : m.fromOss) ?? !0, s = ((u = o.i18n) == null ? void 0 : u.isPullBack) ?? !1, n = ((g = o.i18n) == null ? void 0 : g.isDasUI) ?? !0;
|
|
18
|
+
let r = "/oss/resource/";
|
|
19
|
+
try {
|
|
20
|
+
const l = await D({
|
|
21
|
+
baseUrl: a ? r : "/",
|
|
22
|
+
currentLang: e,
|
|
23
|
+
appName: t,
|
|
24
|
+
isPullBack: s,
|
|
25
|
+
fallbackBaseUrl: "/",
|
|
26
|
+
isDasUI: n
|
|
27
|
+
});
|
|
28
|
+
if (!l || !(l != null && l.frontEnd))
|
|
29
|
+
throw new Error("Failed to fetch i18n data");
|
|
30
|
+
return l;
|
|
31
|
+
} catch (h) {
|
|
32
|
+
throw new Error(`registerResources error: ${h}`);
|
|
33
|
+
}
|
|
34
|
+
}, C = "language", i = p({}), c = p({}), d = p({}), M = L(location.href, "uiCulture") || "", O = M || window.localStorage.getItem(C) || window.navigator.language || "zh-CN", f = b(O), z = "dasI18n", E = () => {
|
|
4
35
|
const t = document.documentElement;
|
|
5
|
-
t && t.setAttribute("lang",
|
|
6
|
-
},
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
console.log("customLangeData===注入", l), console.log("globalLangeData===注入", i);
|
|
14
|
-
}, y = (t = {}, a) => {
|
|
36
|
+
t && t.setAttribute("lang", f.value);
|
|
37
|
+
}, w = (t = {}, e) => {
|
|
38
|
+
const o = e === "global", a = !o, s = {};
|
|
39
|
+
for (const n in t)
|
|
40
|
+
for (const r in t[n])
|
|
41
|
+
s[r] || (s[r] = {}), s[r][n] = t[n][r] ?? "", o && (c[r] || (c[r] = {}), c[r][n] = s[r][n]), a && (i[r] || (i[r] = {}), i[r][n] = s[r][n]);
|
|
42
|
+
console.log("注册customLangeData", i);
|
|
43
|
+
}, A = (t = {}, e) => {
|
|
15
44
|
var s;
|
|
16
|
-
const
|
|
17
|
-
for (const
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
|
|
45
|
+
const o = e === "global", a = !o;
|
|
46
|
+
for (const n in t)
|
|
47
|
+
if (o && !c[n] && (c[n] = t[n]), a) {
|
|
48
|
+
const r = (s = t[n]) != null && s._appCode ? t[n]._appCode.toLowerCase() : "";
|
|
49
|
+
r && (d[r] || (d[r] = {}), d[r][n] = t[n]), i[n] || (i[n] = t[n]);
|
|
21
50
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}),
|
|
40
|
-
|
|
41
|
-
|
|
51
|
+
console.log("获取customLangeData", i);
|
|
52
|
+
}, B = async (t) => {
|
|
53
|
+
E();
|
|
54
|
+
const e = window[z];
|
|
55
|
+
e && A(e, "global");
|
|
56
|
+
}, N = (t) => {
|
|
57
|
+
let e = "";
|
|
58
|
+
const o = /\/([^\/]+)\/([^\/]+)\//, a = t.match(o);
|
|
59
|
+
return a && a.length >= 3 && (e = a[1] + "/" + a[2]), e ? e.toLowerCase() : "";
|
|
60
|
+
}, R = (t, ...e) => j(() => {
|
|
61
|
+
const o = N(location.pathname);
|
|
62
|
+
let a = d.framework ?? {}, s = d[o] ?? {}, n = i[t] || c[t] || a[t] || s[t] || t;
|
|
63
|
+
if (n === t) return t;
|
|
64
|
+
typeof n == "string" && (n = { "zh-CN": n });
|
|
65
|
+
let r = n[f.value];
|
|
66
|
+
return f.value === "zh-CN" && n["zh-cn"] && !n["zh-CN"] && (r = n["zh-cn"]), e.map((m, u) => {
|
|
67
|
+
r && (r = r.replace(`$${u}`, m));
|
|
68
|
+
}), r;
|
|
69
|
+
}), k = R, F = (t, ...e) => k(t, ...e).value, v = (t) => {
|
|
70
|
+
f.value = t, E();
|
|
71
|
+
}, $ = () => f, y = {
|
|
42
72
|
"en-US": { ant: () => import("ant-design-vue/es/locale/en_US"), dayjs: () => import("dayjs/locale/en") },
|
|
43
73
|
"zh-CN": { ant: () => import("ant-design-vue/es/locale/zh_CN"), dayjs: () => import("dayjs/locale/zh-cn") },
|
|
44
74
|
"zh-MO": { ant: () => import("ant-design-vue/es/locale/zh_TW"), dayjs: () => import("dayjs/locale/zh-tw") },
|
|
@@ -53,32 +83,43 @@ const C = "language", l = g({}), i = g({}), m = g({}), h = D(location.href, "uiC
|
|
|
53
83
|
"nl-NL": { ant: () => import("ant-design-vue/es/locale/nl_NL"), dayjs: () => import("dayjs/locale/nl") },
|
|
54
84
|
"tr-TR": { ant: () => import("ant-design-vue/es/locale/tr_TR"), dayjs: () => import("dayjs/locale/tr") }
|
|
55
85
|
};
|
|
56
|
-
function
|
|
57
|
-
var
|
|
58
|
-
const
|
|
59
|
-
return
|
|
86
|
+
function G(t, e) {
|
|
87
|
+
var a;
|
|
88
|
+
const o = window.DATE_FORMAT_MAP;
|
|
89
|
+
return o && o[t] && o[t][e] ? o[t][e] : ((a = window.DATE_FORMAT_MAP[t]) == null ? void 0 : a[e]) || "YYYY-MM-DD";
|
|
60
90
|
}
|
|
61
|
-
const
|
|
62
|
-
const
|
|
91
|
+
const Y = async (t) => {
|
|
92
|
+
const e = y[t] || y["zh-CN"];
|
|
93
|
+
try {
|
|
94
|
+
const o = await e.ant();
|
|
95
|
+
return await e.dayjs(), o.default;
|
|
96
|
+
} catch (o) {
|
|
97
|
+
console.warn(`未找到对应的语言包: ${o}`);
|
|
98
|
+
}
|
|
99
|
+
}, K = async (t = [], e = "zh-CN") => {
|
|
63
100
|
try {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
101
|
+
const o = await U(t, e);
|
|
102
|
+
o != null && o.frontEnd && typeof o.frontEnd == "object" && Object.keys(o.frontEnd).length && t.forEach((a) => {
|
|
103
|
+
o.frontEnd[a] && typeof o.frontEnd[a] == "object" && Object.keys(o.frontEnd[a]).length ? w({ [e]: o.frontEnd[a] }) : console.warn(`No front-end i18n data found for app: ${a}`);
|
|
104
|
+
}), o != null && o.dasUiEnd && typeof o.dasUiEnd == "object" && Object.keys(o.dasUiEnd).length && w({ [e]: o.dasUiEnd }), v(e);
|
|
105
|
+
} catch (o) {
|
|
106
|
+
console.error("registerMicroI18nData error:", o);
|
|
68
107
|
}
|
|
69
108
|
};
|
|
70
109
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
110
|
+
f as currentLang,
|
|
111
|
+
i as customLangeData,
|
|
112
|
+
G as getDateFormat,
|
|
113
|
+
R as getI18nRule,
|
|
114
|
+
$ as getLang,
|
|
115
|
+
k as i18n,
|
|
116
|
+
B as initI18n,
|
|
78
117
|
C as languageKey,
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
118
|
+
Y as loadLocale,
|
|
119
|
+
x as microI18nStore,
|
|
120
|
+
K as registerMicroI18nData,
|
|
121
|
+
A as setI18nRule,
|
|
122
|
+
v as setLang,
|
|
123
|
+
w as setLangRule,
|
|
124
|
+
F as t
|
|
84
125
|
};
|
|
Binary file
|
|
@@ -9,5 +9,4 @@ export declare const microI18nStore: {
|
|
|
9
9
|
markLoaded(lang: langType, name: string): void;
|
|
10
10
|
markUnloaded(lang: langType, name: string): void;
|
|
11
11
|
};
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const registerMicroI18nData: (i18nCodes?: string[], currentLang?: langType) => Promise<void>;
|
|
12
|
+
export declare const getMicroI18nData: (appName: string[], currentLang: langType) => Promise<Record<string, any>>;
|
package/types/i18n/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { microI18nStore } from './getMicroI18nData';
|
|
1
2
|
import { langType } from './type';
|
|
2
3
|
|
|
3
4
|
declare const languageKey = "language";
|
|
@@ -25,4 +26,5 @@ declare const setLang: (lang: langType) => void;
|
|
|
25
26
|
declare const getLang: () => import('vue').Ref<any, any>;
|
|
26
27
|
export declare function getDateFormat(type: 'month' | 'date' | 'datetime' | 'time', lang: string): string;
|
|
27
28
|
declare const loadLocale: (lang: string) => unknown;
|
|
28
|
-
|
|
29
|
+
declare const registerMicroI18nData: (i18nCodes?: string[], currentLang?: langType) => Promise<void>;
|
|
30
|
+
export { langType, languageKey, initI18n, setI18nRule, getI18nRule, i18n, t, setLang, getLang, currentLang, setLangRule, customLangeData, loadLocale, microI18nStore, registerMicroI18nData, };
|
package/index-BhEtGWg9.js.gz
DELETED
|
Binary file
|
package/index-ClQkHyu0.js.gz
DELETED
|
Binary file
|