@das-fed/upf-web 6.4.0-dev.200 → 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,104 +1,150 @@
1
1
  'use strict';
2
2
 
3
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
5
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
3
6
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
7
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t4 in e) "default" !== _t4 && {}.hasOwnProperty.call(e, _t4) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t4)) && (i.get || i.set) ? o(f, _t4, i) : f[_t4] = e[_t4]); return f; })(e, t); }
5
8
  function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
6
9
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
7
10
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
8
11
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
9
12
  var vue = require('vue');
10
13
  var commonTools = require('@das-fed/upf-utils/common-tools');
11
- var s = vue.reactive({}),
14
+ var config = require('@das-fed/upf-utils/config');
15
+ var k = /*#__PURE__*/function () {
16
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(t, n) {
17
+ var _ref2, _ref3, _ref4;
18
+ var m, u, b, a, o, s, e, r, l, _t;
19
+ return _regenerator().w(function (_context) {
20
+ while (1) switch (_context.p = _context.n) {
21
+ case 0:
22
+ a = config.getConfig() || {}, o = (_ref2 = (m = a.i18n) == null ? undefined : m.fromOss) !== null && _ref2 !== void 0 ? _ref2 : true, s = (_ref3 = (u = a.i18n) == null ? undefined : u.isPullBack) !== null && _ref3 !== void 0 ? _ref3 : true, e = (_ref4 = (b = a.i18n) == null ? undefined : b.isDasUI) !== null && _ref4 !== void 0 ? _ref4 : true;
23
+ r = "/oss/resource/";
24
+ _context.p = 1;
25
+ _context.n = 2;
26
+ return commonTools.handleI18nData({
27
+ baseUrl: o ? r : "/",
28
+ currentLang: n,
29
+ appName: t,
30
+ isPullBack: s,
31
+ fallbackBaseUrl: "/",
32
+ isDasUI: e
33
+ });
34
+ case 2:
35
+ l = _context.v;
36
+ if (!(!l || !(l != null && l.frontEnd))) {
37
+ _context.n = 3;
38
+ break;
39
+ }
40
+ throw new Error("Failed to fetch i18n data");
41
+ case 3:
42
+ return _context.a(2, l);
43
+ case 4:
44
+ _context.p = 4;
45
+ _t = _context.v;
46
+ throw new Error("registerResources error: ".concat(_t));
47
+ case 5:
48
+ return _context.a(2);
49
+ }
50
+ }, _callee, null, [[1, 4]]);
51
+ }));
52
+ return function k(_x, _x2) {
53
+ return _ref.apply(this, arguments);
54
+ };
55
+ }(),
56
+ j = "language",
12
57
  c = vue.reactive({}),
13
- l = vue.reactive({}),
14
- p = commonTools.getUrlParams(location.href, "uiCulture") || {},
15
- j = (p == null ? undefined : p.uiCulture) || window.localStorage.getItem("language") || window.navigator.language || "zh-CN",
16
- m = vue.ref(j),
17
- D = "dasI18n",
18
- g = function g() {
58
+ i = vue.reactive({}),
59
+ f = vue.reactive({}),
60
+ U = commonTools.getUrlParams(location.href, "uiCulture") || "",
61
+ D = U || window.localStorage.getItem(j) || window.navigator.language || "zh-CN",
62
+ g = vue.ref(D),
63
+ O = "dasI18n",
64
+ E = function E() {
19
65
  var t = document.documentElement;
20
- t && t.setAttribute("lang", m.value);
66
+ t && t.setAttribute("lang", g.value);
21
67
  },
22
- M = function M() {
68
+ d = function d() {
23
69
  var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
24
- var a = arguments.length > 1 ? arguments[1] : undefined;
25
- var r = a === "global",
26
- e = !r,
27
- i = {};
28
- for (var o in t) for (var n in t[o]) {
29
- var _t$o$n;
30
- i[n] || (i[n] = {}), i[n][o] = (_t$o$n = t[o][n]) !== null && _t$o$n !== void 0 ? _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]);
70
+ var n = arguments.length > 1 ? arguments[1] : undefined;
71
+ var a = n === "global",
72
+ o = !a,
73
+ s = {};
74
+ for (var e in t) for (var r in t[e]) {
75
+ var _t$e$r;
76
+ s[r] || (s[r] = {}), s[r][e] = (_t$e$r = t[e][r]) !== null && _t$e$r !== void 0 ? _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
77
  }
32
78
  },
33
- y = function y() {
79
+ z = function z() {
34
80
  var t = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
35
- var a = arguments.length > 1 ? arguments[1] : undefined;
36
- var i;
37
- var r = a === "global",
38
- e = !r;
39
- for (var o in t) if (r && !c[o] && (c[o] = t[o]), e) {
40
- var n = (i = t[o]) != null && i._appCode ? t[o]._appCode.toLowerCase() : "";
41
- n && (l[n] || (l[n] = {}), l[n][o] = t[o]), s[o] || (s[o] = t[o]);
81
+ var n = arguments.length > 1 ? arguments[1] : undefined;
82
+ var s;
83
+ var a = n === "global",
84
+ o = !a;
85
+ for (var e in t) if (a && !i[e] && (i[e] = t[e]), o) {
86
+ var r = (s = t[e]) != null && s._appCode ? t[e]._appCode.toLowerCase() : "";
87
+ r && (f[r] || (f[r] = {}), f[r][e] = t[e]), c[e] || (c[e] = t[e]);
42
88
  }
43
89
  },
44
- v = /*#__PURE__*/function () {
45
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(t) {
46
- var a;
47
- return _regenerator().w(function (_context) {
48
- while (1) switch (_context.n) {
90
+ x = /*#__PURE__*/function () {
91
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(t) {
92
+ var n;
93
+ return _regenerator().w(function (_context2) {
94
+ while (1) switch (_context2.n) {
49
95
  case 0:
50
- g();
51
- a = window[D];
52
- a && y(a, "global");
96
+ E();
97
+ n = window[O];
98
+ n && z(n, "global");
53
99
  case 1:
54
- return _context.a(2);
100
+ return _context2.a(2);
55
101
  }
56
- }, _callee);
102
+ }, _callee2);
57
103
  }));
58
- return function v(_x) {
59
- return _ref.apply(this, arguments);
104
+ return function x(_x3) {
105
+ return _ref5.apply(this, arguments);
60
106
  };
61
107
  }(),
62
- b = function b(t) {
63
- var a = "";
64
- var r = /\/([^\/]+)\/([^\/]+)\//,
65
- e = t.match(r);
66
- return e && e.length >= 3 && (a = e[1] + "/" + e[2]), a ? a.toLowerCase() : "";
67
- },
68
108
  A = function A(t) {
69
- for (var _len = arguments.length, a = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
70
- a[_key - 1] = arguments[_key];
109
+ var n = "";
110
+ var a = /\/([^\/]+)\/([^\/]+)\//,
111
+ o = t.match(a);
112
+ return o && o.length >= 3 && (n = o[1] + "/" + o[2]), n ? n.toLowerCase() : "";
113
+ },
114
+ v = function v(t) {
115
+ for (var _len = arguments.length, n = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
116
+ n[_key - 1] = arguments[_key];
71
117
  }
72
118
  return vue.computed(function () {
73
- var _l$framework, _l$r;
74
- var r = b(location.pathname);
75
- var e = (_l$framework = l.framework) !== null && _l$framework !== void 0 ? _l$framework : {},
76
- i = (_l$r = l[r]) !== null && _l$r !== void 0 ? _l$r : {},
77
- o = s[t] || c[t] || e[t] || i[t] || t;
78
- if (o === t) return t;
79
- typeof o == "string" && (o = {
80
- "zh-CN": o
119
+ var _f$framework, _f$a;
120
+ var a = A(location.pathname);
121
+ var o = (_f$framework = f.framework) !== null && _f$framework !== void 0 ? _f$framework : {},
122
+ s = (_f$a = f[a]) !== null && _f$a !== void 0 ? _f$a : {},
123
+ e = c[t] || i[t] || o[t] || s[t] || t;
124
+ if (e === t) return t;
125
+ typeof e == "string" && (e = {
126
+ "zh-CN": e
81
127
  });
82
- var n = o[m.value];
83
- return m.value === "zh-CN" && o["zh-cn"] && !o["zh-CN"] && (n = o["zh-cn"]), a.map(function (d, w) {
84
- n && (n = n.replace("$".concat(w), d));
85
- }), n;
128
+ var r = e[g.value];
129
+ return g.value === "zh-CN" && e["zh-cn"] && !e["zh-CN"] && (r = e["zh-cn"]), n.map(function (m, u) {
130
+ r && (r = r.replace("$".concat(u), m));
131
+ }), r;
86
132
  });
87
133
  },
88
- I = A,
89
- R = function R(t) {
90
- for (var _len2 = arguments.length, a = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
91
- a[_key2 - 1] = arguments[_key2];
134
+ N = v,
135
+ B = function B(t) {
136
+ for (var _len2 = arguments.length, n = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
137
+ n[_key2 - 1] = arguments[_key2];
92
138
  }
93
- return I.apply(void 0, [t].concat(a)).value;
139
+ return N.apply(void 0, [t].concat(n)).value;
94
140
  },
95
- N = function N(t) {
96
- m.value = t, g();
141
+ R = function R(t) {
142
+ g.value = t, E();
97
143
  },
98
- _ = function _() {
99
- return m;
144
+ F = function F() {
145
+ return g;
100
146
  },
101
- f = {
147
+ y = {
102
148
  "en-US": {
103
149
  ant: function ant() {
104
150
  return Promise.resolve().then(function () {
@@ -256,48 +302,79 @@ var s = vue.reactive({}),
256
302
  }
257
303
  }
258
304
  };
259
- function T(t, a) {
260
- var e;
261
- var r = window.DATE_FORMAT_MAP;
262
- return r && r[t] && r[t][a] ? r[t][a] : ((e = window.DATE_FORMAT_MAP[t]) == null ? undefined : e[a]) || "YYYY-MM-DD";
305
+ function G(t, n) {
306
+ var o;
307
+ var a = window.DATE_FORMAT_MAP;
308
+ return a && a[t] && a[t][n] ? a[t][n] : ((o = window.DATE_FORMAT_MAP[t]) == null ? undefined : o[n]) || "YYYY-MM-DD";
263
309
  }
264
- var x = /*#__PURE__*/function () {
265
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(t) {
266
- var a, r, _t;
267
- return _regenerator().w(function (_context2) {
268
- while (1) switch (_context2.p = _context2.n) {
269
- case 0:
270
- a = f[t] || f["zh-CN"];
271
- _context2.p = 1;
272
- _context2.n = 2;
273
- return a.ant();
274
- case 2:
275
- r = _context2.v;
276
- _context2.n = 3;
277
- return a.dayjs();
278
- case 3:
279
- return _context2.a(2, r["default"]);
280
- case 4:
281
- _context2.p = 4;
282
- _t = _context2.v;
283
- case 5:
284
- return _context2.a(2);
285
- }
286
- }, _callee2, null, [[1, 4]]);
287
- }));
288
- return function x(_x2) {
289
- return _ref2.apply(this, arguments);
290
- };
291
- }();
292
- exports.currentLang = m;
293
- exports.customLangeData = s;
294
- exports.getDateFormat = T;
295
- exports.getI18nRule = A;
296
- exports.getLang = _;
297
- exports.i18n = I;
298
- exports.initI18n = v;
299
- exports.loadLocale = x;
300
- exports.setI18nRule = y;
301
- exports.setLang = N;
302
- exports.setLangRule = M;
303
- exports.t = R;
310
+ var Y = /*#__PURE__*/function () {
311
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(t) {
312
+ var n, a, _t2;
313
+ return _regenerator().w(function (_context3) {
314
+ while (1) switch (_context3.p = _context3.n) {
315
+ case 0:
316
+ n = y[t] || y["zh-CN"];
317
+ _context3.p = 1;
318
+ _context3.n = 2;
319
+ return n.ant();
320
+ case 2:
321
+ a = _context3.v;
322
+ _context3.n = 3;
323
+ return n.dayjs();
324
+ case 3:
325
+ return _context3.a(2, a["default"]);
326
+ case 4:
327
+ _context3.p = 4;
328
+ _t2 = _context3.v;
329
+ case 5:
330
+ return _context3.a(2);
331
+ }
332
+ }, _callee3, null, [[1, 4]]);
333
+ }));
334
+ return function Y(_x4) {
335
+ return _ref6.apply(this, arguments);
336
+ };
337
+ }(),
338
+ K = /*#__PURE__*/function () {
339
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(t) {
340
+ var n, a, o, _t3;
341
+ return _regenerator().w(function (_context4) {
342
+ while (1) switch (_context4.p = _context4.n) {
343
+ case 0:
344
+ n = commonTools.getUrlParams(location.href, "uiCulture") || window.localStorage.getItem(j) || window.navigator.language || "zh-CN", a = (t == null ? undefined : t.i18n) || [];
345
+ _context4.p = 1;
346
+ _context4.n = 2;
347
+ return k(a, n);
348
+ case 2:
349
+ o = _context4.v;
350
+ o != null && o.frontEnd && _typeof(o.frontEnd) == "object" && Object.keys(o.frontEnd).length && a.forEach(function (s) {
351
+ o.frontEnd[s] && _typeof(o.frontEnd[s]) == "object" && Object.keys(o.frontEnd[s]).length && d(_defineProperty({}, n, o.frontEnd[s]));
352
+ }), 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(_defineProperty({}, n, o.backMsg.aiot)), o != null && o.dasUiEnd && _typeof(o.dasUiEnd) == "object" && Object.keys(o.dasUiEnd).length && d(_defineProperty({}, n, o.dasUiEnd)), R(n);
353
+ _context4.n = 4;
354
+ break;
355
+ case 3:
356
+ _context4.p = 3;
357
+ _t3 = _context4.v;
358
+ case 4:
359
+ return _context4.a(2);
360
+ }
361
+ }, _callee4, null, [[1, 3]]);
362
+ }));
363
+ return function K(_x5) {
364
+ return _ref7.apply(this, arguments);
365
+ };
366
+ }();
367
+ exports.currentLang = g;
368
+ exports.customLangeData = c;
369
+ exports.getDateFormat = G;
370
+ exports.getI18nRule = v;
371
+ exports.getLang = F;
372
+ exports.i18n = N;
373
+ exports.initI18n = x;
374
+ exports.languageKey = j;
375
+ exports.loadLocale = Y;
376
+ exports.registerMicroI18nData = K;
377
+ exports.setI18nRule = z;
378
+ exports.setLang = R;
379
+ exports.setLangRule = d;
380
+ exports.t = B;
@@ -1,41 +1,61 @@
1
- import { reactive as u, ref as C, computed as L } from "vue";
2
- import { getUrlParams as h } from "@das-fed/upf-utils/common-tools";
3
- const s = u({}), c = u({}), l = u({}), p = h(location.href, "uiCulture") || {}, j = (p == null ? void 0 : p.uiCulture) || window.localStorage.getItem("language") || window.navigator.language || "zh-CN", m = C(j), 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
- }, M = (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
- }, y = (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
- }, v = async (t) => {
20
- g();
21
- const a = window[D];
22
- a && y(a, "global");
23
- }, b = (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
- }, A = (t, ...a) => L(() => {
28
- const r = b(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((d, w) => {
34
- n && (n = n.replace(`$${w}`, d));
35
- }), n;
36
- }), I = A, R = (t, ...a) => I(t, ...a).value, N = (t) => {
37
- m.value = t, g();
38
- }, _ = () => m, f = {
39
+ }, x = async (t) => {
40
+ E();
41
+ const n = window[O];
42
+ n && z(n, "global");
43
+ }, A = (t) => {
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,30 +70,41 @@ const s = u({}), c = u({}), l = u({}), p = h(location.href, "uiCulture") || {},
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 T(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 x = async (t) => {
59
- const a = f[t] || f["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
- T as getDateFormat,
70
- A as getI18nRule,
71
- _ as getLang,
72
- I as i18n,
73
- v as initI18n,
74
- x as loadLocale,
75
- y as setI18nRule,
76
- N as setLang,
77
- M as setLangRule,
78
- R 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
79
110
  };
Binary file
@@ -1,4 +1,6 @@
1
- type langType = 'zh-CN' | 'en-US' | 'zh-MO';
1
+ import { langType } from './type';
2
+
3
+ declare const languageKey = "language";
2
4
  declare const customLangeData: any;
3
5
  declare const currentLang: import('vue').Ref<any, any>;
4
6
  declare const setLangRule: (data?: any, type?: "global" | "custom") => void;
@@ -23,4 +25,5 @@ declare const setLang: (lang: langType) => void;
23
25
  declare const getLang: () => import('vue').Ref<any, any>;
24
26
  export declare function getDateFormat(type: 'month' | 'date' | 'datetime' | 'time', lang: string): string;
25
27
  declare const loadLocale: (lang: string) => unknown;
26
- export { 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, };
@@ -0,0 +1,3 @@
1
+ import { langType } from './type';
2
+
3
+ export declare const registerI18nData: (appName: string[], currentLang: langType) => Promise<Record<string, any>>;
Binary file
Binary file