@das-fed/upf-web 6.4.0-dev.201 → 6.4.0-dev.202

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,41 +1,61 @@
1
- import { reactive as p, ref as w, computed as C } from "vue";
2
- import { getUrlParams as L } from "@das-fed/upf-utils/common-tools";
3
- const h = "language", s = p({}), c = p({}), l = p({}), j = L(location.href, "uiCulture") || "", y = j || window.localStorage.getItem(h) || window.navigator.language || "zh-CN", m = w(y), D = "dasI18n", g = () => {
1
+ import { reactive as p, ref as L, computed as C } from "vue";
2
+ import { handleI18nData as M, getUrlParams as w } from "@das-fed/upf-utils/common-tools";
3
+ import { getConfig as I } from "@das-fed/upf-utils/config";
4
+ const k = async (t, n) => {
5
+ var m, u, b;
6
+ const a = I() || {}, o = ((m = a.i18n) == null ? void 0 : m.fromOss) ?? !0, s = ((u = a.i18n) == null ? void 0 : u.isPullBack) ?? !0, e = ((b = a.i18n) == null ? void 0 : b.isDasUI) ?? !0;
7
+ let r = "/oss/resource/";
8
+ try {
9
+ const l = await M({
10
+ baseUrl: o ? r : "/",
11
+ currentLang: n,
12
+ appName: t,
13
+ isPullBack: s,
14
+ fallbackBaseUrl: "/",
15
+ isDasUI: e
16
+ });
17
+ if (!l || !(l != null && l.frontEnd))
18
+ throw new Error("Failed to fetch i18n data");
19
+ return l;
20
+ } catch (h) {
21
+ throw new Error(`registerResources error: ${h}`);
22
+ }
23
+ }, j = "language", c = p({}), i = p({}), f = p({}), U = w(location.href, "uiCulture") || "", D = U || window.localStorage.getItem(j) || window.navigator.language || "zh-CN", g = L(D), O = "dasI18n", E = () => {
4
24
  const t = document.documentElement;
5
- t && t.setAttribute("lang", m.value);
6
- }, v = (t = {}, a) => {
7
- const r = a === "global", e = !r, i = {};
8
- for (const o in t)
9
- for (const n in t[o])
10
- i[n] || (i[n] = {}), i[n][o] = t[o][n] ?? "", r && (c[n] || (c[n] = {}), c[n][o] = i[n][o]), e && (s[n] || (s[n] = {}), s[n][o] = i[n][o]);
11
- }, b = (t = {}, a) => {
12
- var i;
13
- const r = a === "global", e = !r;
14
- for (const o in t)
15
- if (r && !c[o] && (c[o] = t[o]), e) {
16
- const n = (i = t[o]) != null && i._appCode ? t[o]._appCode.toLowerCase() : "";
17
- n && (l[n] || (l[n] = {}), l[n][o] = t[o]), s[o] || (s[o] = t[o]);
25
+ t && t.setAttribute("lang", g.value);
26
+ }, d = (t = {}, n) => {
27
+ const a = n === "global", o = !a, s = {};
28
+ for (const e in t)
29
+ for (const r in t[e])
30
+ s[r] || (s[r] = {}), s[r][e] = t[e][r] ?? "", a && (i[r] || (i[r] = {}), i[r][e] = s[r][e]), o && (c[r] || (c[r] = {}), c[r][e] = s[r][e]);
31
+ }, z = (t = {}, n) => {
32
+ var s;
33
+ const a = n === "global", o = !a;
34
+ for (const e in t)
35
+ if (a && !i[e] && (i[e] = t[e]), o) {
36
+ const r = (s = t[e]) != null && s._appCode ? t[e]._appCode.toLowerCase() : "";
37
+ r && (f[r] || (f[r] = {}), f[r][e] = t[e]), c[e] || (c[e] = t[e]);
18
38
  }
19
- }, R = async (t) => {
20
- g();
21
- const a = window[D];
22
- a && b(a, "global");
39
+ }, x = async (t) => {
40
+ E();
41
+ const n = window[O];
42
+ n && z(n, "global");
23
43
  }, A = (t) => {
24
- let a = "";
25
- const r = /\/([^\/]+)\/([^\/]+)\//, e = t.match(r);
26
- return e && e.length >= 3 && (a = e[1] + "/" + e[2]), a ? a.toLowerCase() : "";
27
- }, I = (t, ...a) => C(() => {
28
- const r = A(location.pathname);
29
- let e = l.framework ?? {}, i = l[r] ?? {}, o = s[t] || c[t] || e[t] || i[t] || t;
30
- if (o === t) return t;
31
- typeof o == "string" && (o = { "zh-CN": o });
32
- let n = o[m.value];
33
- return m.value === "zh-CN" && o["zh-cn"] && !o["zh-CN"] && (n = o["zh-cn"]), a.map((f, d) => {
34
- n && (n = n.replace(`$${d}`, f));
35
- }), n;
36
- }), z = I, N = (t, ...a) => z(t, ...a).value, T = (t) => {
37
- m.value = t, g();
38
- }, _ = () => m, u = {
44
+ let n = "";
45
+ const a = /\/([^\/]+)\/([^\/]+)\//, o = t.match(a);
46
+ return o && o.length >= 3 && (n = o[1] + "/" + o[2]), n ? n.toLowerCase() : "";
47
+ }, v = (t, ...n) => C(() => {
48
+ const a = A(location.pathname);
49
+ let o = f.framework ?? {}, s = f[a] ?? {}, e = c[t] || i[t] || o[t] || s[t] || t;
50
+ if (e === t) return t;
51
+ typeof e == "string" && (e = { "zh-CN": e });
52
+ let r = e[g.value];
53
+ return g.value === "zh-CN" && e["zh-cn"] && !e["zh-CN"] && (r = e["zh-cn"]), n.map((m, u) => {
54
+ r && (r = r.replace(`$${u}`, m));
55
+ }), r;
56
+ }), N = v, B = (t, ...n) => N(t, ...n).value, R = (t) => {
57
+ g.value = t, E();
58
+ }, F = () => g, y = {
39
59
  "en-US": { ant: () => import("ant-design-vue/es/locale/en_US"), dayjs: () => import("dayjs/locale/en") },
40
60
  "zh-CN": { ant: () => import("ant-design-vue/es/locale/zh_CN"), dayjs: () => import("dayjs/locale/zh-cn") },
41
61
  "zh-MO": { ant: () => import("ant-design-vue/es/locale/zh_TW"), dayjs: () => import("dayjs/locale/zh-tw") },
@@ -50,31 +70,41 @@ const h = "language", s = p({}), c = p({}), l = p({}), j = L(location.href, "uiC
50
70
  "nl-NL": { ant: () => import("ant-design-vue/es/locale/nl_NL"), dayjs: () => import("dayjs/locale/nl") },
51
71
  "tr-TR": { ant: () => import("ant-design-vue/es/locale/tr_TR"), dayjs: () => import("dayjs/locale/tr") }
52
72
  };
53
- function x(t, a) {
54
- var e;
55
- const r = window.DATE_FORMAT_MAP;
56
- return r && r[t] && r[t][a] ? r[t][a] : ((e = window.DATE_FORMAT_MAP[t]) == null ? void 0 : e[a]) || "YYYY-MM-DD";
73
+ function G(t, n) {
74
+ var o;
75
+ const a = window.DATE_FORMAT_MAP;
76
+ return a && a[t] && a[t][n] ? a[t][n] : ((o = window.DATE_FORMAT_MAP[t]) == null ? void 0 : o[n]) || "YYYY-MM-DD";
57
77
  }
58
- const O = async (t) => {
59
- const a = u[t] || u["zh-CN"];
78
+ const Y = async (t) => {
79
+ const n = y[t] || y["zh-CN"];
80
+ try {
81
+ const a = await n.ant();
82
+ return await n.dayjs(), a.default;
83
+ } catch {
84
+ }
85
+ }, K = async (t) => {
86
+ const n = w(location.href, "uiCulture") || window.localStorage.getItem(j) || window.navigator.language || "zh-CN", a = (t == null ? void 0 : t.i18n) || [];
60
87
  try {
61
- const r = await a.ant();
62
- return await a.dayjs(), r.default;
88
+ const o = await k(a, n);
89
+ o != null && o.frontEnd && typeof o.frontEnd == "object" && Object.keys(o.frontEnd).length && a.forEach((s) => {
90
+ o.frontEnd[s] && typeof o.frontEnd[s] == "object" && Object.keys(o.frontEnd[s]).length && d({ [n]: o.frontEnd[s] });
91
+ }), o != null && o.backMsg && typeof o.backMsg == "object" && Object.keys(o.backMsg).length && o.backMsg.aiot && typeof o.backMsg.aiot == "object" && Object.keys(o.backMsg.aiot).length && d({ [n]: o.backMsg.aiot }), o != null && o.dasUiEnd && typeof o.dasUiEnd == "object" && Object.keys(o.dasUiEnd).length && d({ [n]: o.dasUiEnd }), R(n);
63
92
  } catch {
64
93
  }
65
94
  };
66
95
  export {
67
- m as currentLang,
68
- s as customLangeData,
69
- x as getDateFormat,
70
- I as getI18nRule,
71
- _ as getLang,
72
- z as i18n,
73
- R as initI18n,
74
- h as languageKey,
75
- O as loadLocale,
76
- b as setI18nRule,
77
- T as setLang,
78
- v as setLangRule,
79
- N as t
96
+ g as currentLang,
97
+ c as customLangeData,
98
+ G as getDateFormat,
99
+ v as getI18nRule,
100
+ F as getLang,
101
+ N as i18n,
102
+ x as initI18n,
103
+ j as languageKey,
104
+ Y as loadLocale,
105
+ K as registerMicroI18nData,
106
+ z as setI18nRule,
107
+ R as setLang,
108
+ d as setLangRule,
109
+ B as t
80
110
  };
Binary file
@@ -25,4 +25,5 @@ declare const setLang: (lang: langType) => void;
25
25
  declare const getLang: () => import('vue').Ref<any, any>;
26
26
  export declare function getDateFormat(type: 'month' | 'date' | 'datetime' | 'time', lang: string): string;
27
27
  declare const loadLocale: (lang: string) => unknown;
28
- export { languageKey, initI18n, setI18nRule, getI18nRule, i18n, t, setLang, getLang, currentLang, setLangRule, customLangeData, loadLocale, };
28
+ declare const registerMicroI18nData: (opt?: any) => any;
29
+ export { languageKey, initI18n, setI18nRule, getI18nRule, i18n, t, setLang, getLang, currentLang, setLangRule, customLangeData, loadLocale, registerMicroI18nData, };
@@ -1,4 +1,3 @@
1
1
  import { langType } from './type';
2
2
 
3
- export declare const registerI18nData: (appName: string[], currentLang: langType, cb: any) => Promise<void>;
4
- export declare const registerMicroI18nData: (opt?: any) => void;
3
+ export declare const registerI18nData: (appName: string[], currentLang: langType) => Promise<Record<string, any>>;
package/types/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  export * from './create-das-web-app';
2
2
  export * from './i18n';
3
- export * from './i18n/register';
4
3
  export * from './theme';
5
4
  export * from './layout';
6
5
  export * from './micro-frontend';
Binary file
Binary file