@das-fed/upf-web 6.4.0-dev.215 → 6.4.0-dev.216

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