@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.
@@ -1,44 +1,74 @@
1
- import { reactive as g, ref as L, computed as w } from "vue";
2
- import { getUrlParams as D } from "@das-fed/upf-utils/common-tools";
3
- const C = "language", l = g({}), i = g({}), m = g({}), h = D(location.href, "uiCulture") || "", j = h || window.localStorage.getItem(C) || window.navigator.language || "zh-CN", c = L(j), b = "dasI18n", p = () => {
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", c.value);
6
- }, M = (t = {}, a) => {
7
- const e = a === "global", r = !e;
8
- console.log("setLangRule===", t, a);
9
- const s = {};
10
- for (const o in t)
11
- for (const n in t[o])
12
- s[n] || (s[n] = {}), s[n][o] = t[o][n] ?? "", e && (i[n] || (i[n] = {}), i[n][o] = s[n][o]), r && (l[n] || (l[n] = {}, console.log(`${l[n]}为空,重新设置为{}`)), l[n][o] = s[n][o]);
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 e = a === "global", r = !e;
17
- for (const o in t)
18
- if (e && !i[o] && (i[o] = t[o]), r) {
19
- const n = (s = t[o]) != null && s._appCode ? t[o]._appCode.toLowerCase() : "";
20
- n && (m[n] || (m[n] = {}), m[n][o] = t[o]), l[o] || (l[o] = t[o]);
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
- }, R = async (t) => {
23
- p();
24
- const a = window[b];
25
- a && y(a, "global");
26
- }, v = (t) => {
27
- let a = "";
28
- const e = /\/([^\/]+)\/([^\/]+)\//, r = t.match(e);
29
- return r && r.length >= 3 && (a = r[1] + "/" + r[2]), a ? a.toLowerCase() : "";
30
- }, A = (t, ...a) => w(() => {
31
- const e = v(location.pathname);
32
- let r = m.framework ?? {}, s = m[e] ?? {}, o = l[t] || i[t] || r[t] || s[t] || t;
33
- if (o === t) return t;
34
- console.log("customLangeData===获取时", l, l[t]), console.log("globalLangeData===获取时", i, i[t]), typeof o == "string" && (o = { "zh-CN": o });
35
- let n = o[c.value];
36
- return c.value === "zh-CN" && o["zh-cn"] && !o["zh-CN"] && (n = o["zh-cn"]), a.map((f, d) => {
37
- n && (n = n.replace(`$${d}`, f));
38
- }), n;
39
- }), I = A, N = (t, ...a) => I(t, ...a).value, T = (t) => {
40
- c.value = t, console.log("currentLang.value===", c.value), p();
41
- }, _ = () => c, u = {
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 x(t, a) {
57
- var r;
58
- const e = window.DATE_FORMAT_MAP;
59
- return e && e[t] && e[t][a] ? e[t][a] : ((r = window.DATE_FORMAT_MAP[t]) == null ? void 0 : r[a]) || "YYYY-MM-DD";
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 O = async (t) => {
62
- const a = u[t] || u["zh-CN"];
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 e = await a.ant();
65
- return await a.dayjs(), e.default;
66
- } catch (e) {
67
- console.warn(`未找到对应的语言包: ${e}`);
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
- c as currentLang,
72
- l as customLangeData,
73
- x as getDateFormat,
74
- A as getI18nRule,
75
- _ as getLang,
76
- I as i18n,
77
- R as initI18n,
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
- O as loadLocale,
80
- y as setI18nRule,
81
- T as setLang,
82
- M as setLangRule,
83
- N as t
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 registerI18nData: (appName: string[], currentLang: langType) => Promise<Record<string, any>>;
13
- export declare const registerMicroI18nData: (i18nCodes?: string[], currentLang?: langType) => Promise<void>;
12
+ export declare const getMicroI18nData: (appName: string[], currentLang: langType) => Promise<Record<string, any>>;
@@ -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
- export { languageKey, initI18n, setI18nRule, getI18nRule, i18n, t, setLang, getLang, currentLang, setLangRule, customLangeData, loadLocale, };
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, };
Binary file
Binary file