gc_i18n 1.6.9 → 1.7.1
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/lib/gc_i18n.es.js +252 -254
- package/lib/gc_i18n.umd.js +10 -10
- package/package.json +1 -1
- package/packages/index.js +13 -14
package/lib/gc_i18n.es.js
CHANGED
|
@@ -3,7 +3,7 @@ import xt from "keyboardjs";
|
|
|
3
3
|
import { h as xe, ref as ie, computed as He, onMounted as to, nextTick as _t, Vue as _e } from "vue-demi";
|
|
4
4
|
import st from "axios";
|
|
5
5
|
import E from "store2";
|
|
6
|
-
import
|
|
6
|
+
import b from "lodash-es";
|
|
7
7
|
import { jws as no } from "jsrsasign";
|
|
8
8
|
const oo = [
|
|
9
9
|
"ar-SA",
|
|
@@ -24,9 +24,9 @@ const oo = [
|
|
|
24
24
|
return e;
|
|
25
25
|
}, io = (t, e, n) => (e.forEach((o) => {
|
|
26
26
|
const s = o.key.split(".");
|
|
27
|
-
s[0] === "common" &&
|
|
28
|
-
const i =
|
|
29
|
-
i ?
|
|
27
|
+
s[0] === "common" && b.find(t, { key: `${n}.${s[1]}` }) && b.remove(t, { key: `${n}.${s[1]}` });
|
|
28
|
+
const i = b.find(t, { key: o.key });
|
|
29
|
+
i ? b.merge(i, o) : t.push(o);
|
|
30
30
|
}), t), ce = st.create({
|
|
31
31
|
timeout: 8e3
|
|
32
32
|
}), Ae = /* @__PURE__ */ new Map(), ro = "https://extendapi.ihotel.cn", ao = "https://test.ihotel.cn", lo = /^https?:\/\//i, Je = (t) => String(t || "guest").replace(/[^\w-]/g, "_"), we = async (t, e) => typeof e != "function" ? t : await e(t) || t, Kt = ({ env: t, dev: e } = {}) => {
|
|
@@ -55,9 +55,9 @@ const oo = [
|
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
57
|
if (l.data && l.data.result === 0) {
|
|
58
|
-
const a =
|
|
59
|
-
langCode:
|
|
60
|
-
langName:
|
|
58
|
+
const a = b.get(l.data, "retVal", []), d = a.map((p) => ({
|
|
59
|
+
langCode: p.language || p.langCode || p,
|
|
60
|
+
langName: p.langName || p.language || p
|
|
61
61
|
}));
|
|
62
62
|
return E.set("I18N_LANGUAGES", a), d;
|
|
63
63
|
}
|
|
@@ -122,7 +122,7 @@ const oo = [
|
|
|
122
122
|
const e = t.trim();
|
|
123
123
|
return !e || /^<!doctype/i.test(e) || /^<html/i.test(e) ? (console.warn("i18n_token 接口未返回有效 token,请检查业务项目接口"), "") : e;
|
|
124
124
|
}
|
|
125
|
-
return
|
|
125
|
+
return b.get(t, "retVal.i18n_token") || b.get(t, "retVal.token") || b.get(t, "i18n_token") || b.get(t, "token") || "";
|
|
126
126
|
}, co = async ({
|
|
127
127
|
request: t,
|
|
128
128
|
appCode: e,
|
|
@@ -165,58 +165,58 @@ const oo = [
|
|
|
165
165
|
getRequestToken: r
|
|
166
166
|
}) => {
|
|
167
167
|
try {
|
|
168
|
-
const l = Je(i), a = `I18N_${
|
|
168
|
+
const l = Je(i), a = `I18N_${b.toUpper(e)}_${l}`, d = E.namespace(a), p = {
|
|
169
169
|
baseUrl: t,
|
|
170
170
|
appCode: e,
|
|
171
171
|
language: n,
|
|
172
172
|
token: o,
|
|
173
173
|
getRequestToken: r
|
|
174
|
-
},
|
|
174
|
+
}, u = d.get(n), h = [
|
|
175
175
|
t || "",
|
|
176
176
|
e || "",
|
|
177
177
|
n || "",
|
|
178
178
|
l,
|
|
179
179
|
o || "",
|
|
180
|
-
|
|
180
|
+
b.get(u, "lastPullDate", "")
|
|
181
181
|
].join("|");
|
|
182
|
-
if (Ae.has(
|
|
183
|
-
return Ae.get(
|
|
182
|
+
if (Ae.has(h))
|
|
183
|
+
return Ae.get(h);
|
|
184
184
|
const x = (async () => {
|
|
185
|
-
if (!
|
|
186
|
-
const _ = await Et(
|
|
187
|
-
return _ ? (d.set(n, _),
|
|
185
|
+
if (!u || !u.lastPullDate) {
|
|
186
|
+
const _ = await Et(p);
|
|
187
|
+
return _ ? (d.set(n, _), b.get(_, "translatesDTOs", [])) : b.get(u, "translatesDTOs", []);
|
|
188
188
|
}
|
|
189
|
-
const { lastPullDate:
|
|
190
|
-
...
|
|
191
|
-
lastPullDate:
|
|
189
|
+
const { lastPullDate: L } = u, S = await Et({
|
|
190
|
+
...p,
|
|
191
|
+
lastPullDate: L
|
|
192
192
|
});
|
|
193
|
-
if (!
|
|
194
|
-
return
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
197
|
-
const _ = io(
|
|
198
|
-
lastPullDate:
|
|
193
|
+
if (!S)
|
|
194
|
+
return b.get(u, "translatesDTOs", []);
|
|
195
|
+
const B = b.get(u, "translatesDTOs", []);
|
|
196
|
+
if (!b.isEmpty(S.translatesDTOs)) {
|
|
197
|
+
const _ = io(B, S.translatesDTOs, s), w = {
|
|
198
|
+
lastPullDate: S.lastPullDate,
|
|
199
199
|
translatesDTOs: _
|
|
200
200
|
};
|
|
201
201
|
return d.set(n, w, ":"), _;
|
|
202
202
|
}
|
|
203
|
-
return
|
|
203
|
+
return B;
|
|
204
204
|
})();
|
|
205
|
-
return Ae.set(
|
|
206
|
-
Ae.delete(
|
|
205
|
+
return Ae.set(h, x), x.finally(() => {
|
|
206
|
+
Ae.delete(h);
|
|
207
207
|
}), x;
|
|
208
208
|
} catch (l) {
|
|
209
209
|
console.error("处理翻译数据失败:", l);
|
|
210
|
-
const a = Je(i), d = E.namespace(`I18N_${
|
|
211
|
-
return
|
|
210
|
+
const a = Je(i), d = E.namespace(`I18N_${b.toUpper(e)}_${a}`);
|
|
211
|
+
return b.get(d.get(n), "translatesDTOs", []);
|
|
212
212
|
}
|
|
213
213
|
}, Tt = ({ appCode: t, cacheScope: e } = {}) => {
|
|
214
214
|
if (t) {
|
|
215
215
|
if (e) {
|
|
216
|
-
E.namespace(`I18N_${
|
|
216
|
+
E.namespace(`I18N_${b.toUpper(t)}_${Je(e)}`).clearAll();
|
|
217
217
|
return;
|
|
218
218
|
}
|
|
219
|
-
E.namespace(`I18N_${
|
|
219
|
+
E.namespace(`I18N_${b.toUpper(t)}`).clearAll();
|
|
220
220
|
}
|
|
221
221
|
};
|
|
222
222
|
function St(t) {
|
|
@@ -314,7 +314,7 @@ function Xt(t) {
|
|
|
314
314
|
}), n.length ? n : [{ type: "text", value: t }];
|
|
315
315
|
}
|
|
316
316
|
function $t(t) {
|
|
317
|
-
return
|
|
317
|
+
return b.reduce(
|
|
318
318
|
t,
|
|
319
319
|
(e, n) => {
|
|
320
320
|
const o = e[e.length - 1];
|
|
@@ -397,11 +397,11 @@ class mo {
|
|
|
397
397
|
baseUrl: this.baseUrl,
|
|
398
398
|
appCode: this.appCode
|
|
399
399
|
}), o = Fe(n);
|
|
400
|
-
o && o.result === 0 ? (
|
|
400
|
+
o && o.result === 0 ? (b.isEmpty(e) && (e = ["zh-CN", "en-US", "zh-TW"]), this.languages = b.map(o.retVal || [], (s) => {
|
|
401
401
|
const i = go(s);
|
|
402
402
|
return {
|
|
403
403
|
...i,
|
|
404
|
-
checked:
|
|
404
|
+
checked: b.includes(e, i.langCode)
|
|
405
405
|
};
|
|
406
406
|
}), await this.getPageData()) : (this.loading = !1, this.showError("获取语言失败,出错了"), this.render());
|
|
407
407
|
} catch (e) {
|
|
@@ -409,8 +409,8 @@ class mo {
|
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
saveLanguageSetting() {
|
|
412
|
-
const e =
|
|
413
|
-
|
|
412
|
+
const e = b.map(
|
|
413
|
+
b.filter(this.languages, (n) => n.checked),
|
|
414
414
|
"langCode"
|
|
415
415
|
);
|
|
416
416
|
E.set("I18N_LANGUAGE_SETTING", e);
|
|
@@ -428,7 +428,7 @@ class mo {
|
|
|
428
428
|
});
|
|
429
429
|
}
|
|
430
430
|
updateTranslationValue(e, n, o) {
|
|
431
|
-
const { dictKey: s } = e, i =
|
|
431
|
+
const { dictKey: s } = e, i = b.findIndex(this.mySaveData, {
|
|
432
432
|
dictKey: s
|
|
433
433
|
});
|
|
434
434
|
e[n] = o, e[`${n}_fromAi`] = "F", i > -1 ? (this.mySaveData[i][n] = o, this.mySaveData[i][`${n}_fromAi`] = "F", this.mySaveData[i].changedLangs = {
|
|
@@ -443,11 +443,11 @@ class mo {
|
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
445
|
isProtectedValue(e) {
|
|
446
|
-
return
|
|
446
|
+
return b.some(St(e), { type: "locked" });
|
|
447
447
|
}
|
|
448
448
|
isProtectedEditor() {
|
|
449
449
|
var e;
|
|
450
|
-
return
|
|
450
|
+
return b.some(((e = this.editor) == null ? void 0 : e.parts) || [], { type: "locked" });
|
|
451
451
|
}
|
|
452
452
|
openEditor(e, n) {
|
|
453
453
|
const o = this.data[e];
|
|
@@ -466,13 +466,13 @@ class mo {
|
|
|
466
466
|
const e = (n = this.root) == null ? void 0 : n.querySelector(
|
|
467
467
|
".gc_i18n_config_protected_editor"
|
|
468
468
|
);
|
|
469
|
-
!e || !this.editor ||
|
|
469
|
+
!e || !this.editor || b.forEach(e.querySelectorAll("[data-editor-index]"), (o) => {
|
|
470
470
|
const s = Number(o.dataset.editorIndex), i = this.editor.parts[s];
|
|
471
471
|
i && i.type === "text" && (i.value = o.innerText);
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
474
|
getEditorSubmitValue() {
|
|
475
|
-
return this.editor ? this.isProtectedEditor() ? (this.syncEditorPartsFromDom(),
|
|
475
|
+
return this.editor ? this.isProtectedEditor() ? (this.syncEditorPartsFromDom(), b.map(this.editor.parts, "value").join("")) : this.editor.value : "";
|
|
476
476
|
}
|
|
477
477
|
confirmEditor() {
|
|
478
478
|
if (!this.editor)
|
|
@@ -485,8 +485,8 @@ class mo {
|
|
|
485
485
|
}
|
|
486
486
|
getSubmitData() {
|
|
487
487
|
const e = [];
|
|
488
|
-
return
|
|
489
|
-
|
|
488
|
+
return b.map(this.mySaveData, (n) => {
|
|
489
|
+
b.map(b.keys(n.changedLangs || {}), (o) => {
|
|
490
490
|
e.push({
|
|
491
491
|
key: n.dictKey,
|
|
492
492
|
page: n.page,
|
|
@@ -499,7 +499,7 @@ class mo {
|
|
|
499
499
|
}
|
|
500
500
|
async saveData({ msg: e = "保存成功" } = {}, n = !0) {
|
|
501
501
|
const o = this.getSubmitData();
|
|
502
|
-
if (
|
|
502
|
+
if (b.isEmpty(o)) {
|
|
503
503
|
this.showError("没有需要保存的数据");
|
|
504
504
|
return;
|
|
505
505
|
}
|
|
@@ -536,7 +536,7 @@ class mo {
|
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
538
|
async saveNoEqual() {
|
|
539
|
-
|
|
539
|
+
b.isEmpty(this.mySaveData) || await this.saveData({ msg: "已为您自动保存" }, !1);
|
|
540
540
|
}
|
|
541
541
|
async changePage(e) {
|
|
542
542
|
await this.saveNoEqual();
|
|
@@ -571,7 +571,7 @@ class mo {
|
|
|
571
571
|
data: {
|
|
572
572
|
appCode: this.appCode,
|
|
573
573
|
searchBlur: this.searchText,
|
|
574
|
-
commaSeparatedLangs:
|
|
574
|
+
commaSeparatedLangs: b.map(this.languages, "langCode").toString(),
|
|
575
575
|
page: n === "loginData" ? this.loginRouteName : n === "pageData" ? this.name : "common",
|
|
576
576
|
pageSize: 10,
|
|
577
577
|
...e
|
|
@@ -581,7 +581,7 @@ class mo {
|
|
|
581
581
|
}), s = Fe(o);
|
|
582
582
|
if (s && s.result === 0) {
|
|
583
583
|
const i = s.retVal || {};
|
|
584
|
-
this.data =
|
|
584
|
+
this.data = b.cloneDeep(i.datas || []), this.page = {
|
|
585
585
|
firstResult: i.firstResult || 0,
|
|
586
586
|
pageSize: i.pageSize || 10,
|
|
587
587
|
totalRows: i.totalRows || 0
|
|
@@ -643,7 +643,7 @@ class mo {
|
|
|
643
643
|
return Math.max(1, Math.ceil((this.page.totalRows || 0) / this.page.pageSize));
|
|
644
644
|
}
|
|
645
645
|
get checkedLanguages() {
|
|
646
|
-
return
|
|
646
|
+
return b.filter(this.languages, (e) => e.checked);
|
|
647
647
|
}
|
|
648
648
|
renderStatus() {
|
|
649
649
|
var n;
|
|
@@ -741,7 +741,7 @@ class mo {
|
|
|
741
741
|
return '<div class="gc_i18n_config_loading">加载中...</div>';
|
|
742
742
|
}
|
|
743
743
|
renderTable() {
|
|
744
|
-
return
|
|
744
|
+
return b.isEmpty(this.data) ? `
|
|
745
745
|
<div class="gc_i18n_config_table_wrap">
|
|
746
746
|
<div class="gc_i18n_config_empty">暂无数据</div>
|
|
747
747
|
</div>
|
|
@@ -1227,14 +1227,14 @@ const es = ["input", "file", "range", "select", "radio", "checkbox", "textarea"]
|
|
|
1227
1227
|
}, ns = (t) => {
|
|
1228
1228
|
if (!t.input)
|
|
1229
1229
|
return;
|
|
1230
|
-
if (!
|
|
1231
|
-
te(`Unexpected type of input! Expected ${Object.keys(
|
|
1230
|
+
if (!I[t.input]) {
|
|
1231
|
+
te(`Unexpected type of input! Expected ${Object.keys(I).join(" | ")}, got "${t.input}"`);
|
|
1232
1232
|
return;
|
|
1233
1233
|
}
|
|
1234
1234
|
const e = cn(t.input);
|
|
1235
1235
|
if (!e)
|
|
1236
1236
|
return;
|
|
1237
|
-
const n =
|
|
1237
|
+
const n = I[t.input](e, t);
|
|
1238
1238
|
R(e), t.inputAutoFocus && setTimeout(() => {
|
|
1239
1239
|
rn(n);
|
|
1240
1240
|
});
|
|
@@ -1274,8 +1274,8 @@ const es = ["input", "file", "range", "select", "radio", "checkbox", "textarea"]
|
|
|
1274
1274
|
] || c.input);
|
|
1275
1275
|
}, $e = (t, e) => {
|
|
1276
1276
|
["string", "number"].includes(typeof e) ? t.value = `${e}` : at(e) || O(`Unexpected type of inputValue! Expected "string", "number" or "Promise", got "${typeof e}"`);
|
|
1277
|
-
},
|
|
1278
|
-
|
|
1277
|
+
}, I = {};
|
|
1278
|
+
I.text = I.email = I.password = I.number = I.tel = I.url = I.search = I.date = I["datetime-local"] = I.time = I.week = I.month = /** @type {(input: Input | HTMLElement, params: SweetAlertOptions) => Input} */
|
|
1279
1279
|
(t, e) => {
|
|
1280
1280
|
const n = (
|
|
1281
1281
|
/** @type {HTMLInputElement} */
|
|
@@ -1284,14 +1284,14 @@ P.text = P.email = P.password = P.number = P.tel = P.url = P.search = P.date = P
|
|
|
1284
1284
|
return $e(n, e.inputValue), Ce(n, n, e), wt(n, e), n.type = /** @type {string} */
|
|
1285
1285
|
e.input, n;
|
|
1286
1286
|
};
|
|
1287
|
-
|
|
1287
|
+
I.file = (t, e) => {
|
|
1288
1288
|
const n = (
|
|
1289
1289
|
/** @type {HTMLInputElement} */
|
|
1290
1290
|
t
|
|
1291
1291
|
);
|
|
1292
1292
|
return Ce(n, n, e), wt(n, e), n;
|
|
1293
1293
|
};
|
|
1294
|
-
|
|
1294
|
+
I.range = (t, e) => {
|
|
1295
1295
|
const n = (
|
|
1296
1296
|
/** @type {HTMLElement} */
|
|
1297
1297
|
t
|
|
@@ -1305,7 +1305,7 @@ P.range = (t, e) => {
|
|
|
1305
1305
|
)), s && $e(s, e.inputValue), /** @type {Input} */
|
|
1306
1306
|
t;
|
|
1307
1307
|
};
|
|
1308
|
-
|
|
1308
|
+
I.select = (t, e) => {
|
|
1309
1309
|
const n = (
|
|
1310
1310
|
/** @type {HTMLSelectElement} */
|
|
1311
1311
|
t
|
|
@@ -1316,7 +1316,7 @@ P.select = (t, e) => {
|
|
|
1316
1316
|
}
|
|
1317
1317
|
return Ce(n, n, e), n;
|
|
1318
1318
|
};
|
|
1319
|
-
|
|
1319
|
+
I.radio = (t) => {
|
|
1320
1320
|
const e = (
|
|
1321
1321
|
/** @type {HTMLElement} */
|
|
1322
1322
|
t
|
|
@@ -1324,7 +1324,7 @@ P.radio = (t) => {
|
|
|
1324
1324
|
return e.textContent = "", /** @type {Input} */
|
|
1325
1325
|
t;
|
|
1326
1326
|
};
|
|
1327
|
-
|
|
1327
|
+
I.checkbox = (t, e) => {
|
|
1328
1328
|
const n = T();
|
|
1329
1329
|
if (!n)
|
|
1330
1330
|
throw new Error("Popup not found");
|
|
@@ -1339,7 +1339,7 @@ P.checkbox = (t, e) => {
|
|
|
1339
1339
|
}
|
|
1340
1340
|
return o;
|
|
1341
1341
|
};
|
|
1342
|
-
|
|
1342
|
+
I.textarea = (t, e) => {
|
|
1343
1343
|
const n = (
|
|
1344
1344
|
/** @type {HTMLTextAreaElement} */
|
|
1345
1345
|
t
|
|
@@ -1792,8 +1792,8 @@ function ti(t, e, n) {
|
|
|
1792
1792
|
e.forEach((i) => {
|
|
1793
1793
|
const r = i[0], l = i[1], a = document.createElement("input"), d = document.createElement("label");
|
|
1794
1794
|
a.type = "radio", a.name = c.radio, a.value = r, _n(r, n.inputValue) && (a.checked = !0);
|
|
1795
|
-
const
|
|
1796
|
-
V(
|
|
1795
|
+
const p = document.createElement("span");
|
|
1796
|
+
V(p, l), p.className = c.label, d.appendChild(a), d.appendChild(p), o.appendChild(d);
|
|
1797
1797
|
});
|
|
1798
1798
|
const s = o.querySelectorAll("input");
|
|
1799
1799
|
s.length && s[0].focus();
|
|
@@ -2493,7 +2493,7 @@ https://sweetalert2.github.io/#ajax-request`), Ji(t), typeof t.title == "string"
|
|
|
2493
2493
|
}
|
|
2494
2494
|
let F;
|
|
2495
2495
|
var Te = /* @__PURE__ */ new WeakMap();
|
|
2496
|
-
class
|
|
2496
|
+
class P {
|
|
2497
2497
|
/**
|
|
2498
2498
|
* @param {...(SweetAlertOptions | string)} args
|
|
2499
2499
|
* @this {SweetAlert}
|
|
@@ -2646,32 +2646,32 @@ const er = (t, e, n) => new Promise((o, s) => {
|
|
|
2646
2646
|
}, rr = (t, e) => e.focusDeny && U(t.denyButton) ? (t.denyButton.focus(), !0) : e.focusCancel && U(t.cancelButton) ? (t.cancelButton.focus(), !0) : e.focusConfirm && U(t.confirmButton) ? (t.confirmButton.focus(), !0) : !1, ar = () => {
|
|
2647
2647
|
document.activeElement instanceof HTMLElement && typeof document.activeElement.blur == "function" && document.activeElement.blur();
|
|
2648
2648
|
};
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
Object.assign(
|
|
2649
|
+
P.prototype.disableButtons = In;
|
|
2650
|
+
P.prototype.enableButtons = $n;
|
|
2651
|
+
P.prototype.getInput = Tn;
|
|
2652
|
+
P.prototype.disableInput = Bn;
|
|
2653
|
+
P.prototype.enableInput = Pn;
|
|
2654
|
+
P.prototype.hideLoading = Me;
|
|
2655
|
+
P.prototype.disableLoading = Me;
|
|
2656
|
+
P.prototype.showValidationMessage = Nn;
|
|
2657
|
+
P.prototype.resetValidationMessage = Mn;
|
|
2658
|
+
P.prototype.close = Y;
|
|
2659
|
+
P.prototype.closePopup = Y;
|
|
2660
|
+
P.prototype.closeModal = Y;
|
|
2661
|
+
P.prototype.closeToast = Y;
|
|
2662
|
+
P.prototype.rejectPromise = xn;
|
|
2663
|
+
P.prototype.update = Un;
|
|
2664
|
+
P.prototype._destroy = qn;
|
|
2665
|
+
Object.assign(P, Ri);
|
|
2666
2666
|
Object.keys(gi).forEach((t) => {
|
|
2667
|
-
|
|
2667
|
+
P[t] = function(...e) {
|
|
2668
2668
|
if (F && F[t])
|
|
2669
2669
|
return F[t](...e);
|
|
2670
2670
|
};
|
|
2671
2671
|
});
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
const M =
|
|
2672
|
+
P.DismissReason = fe;
|
|
2673
|
+
P.version = "11.26.18";
|
|
2674
|
+
const M = P;
|
|
2675
2675
|
M.default = M;
|
|
2676
2676
|
typeof document < "u" && (function(t, e) {
|
|
2677
2677
|
var n = t.createElement("style");
|
|
@@ -2715,7 +2715,7 @@ class lr {
|
|
|
2715
2715
|
getRequestToken: this.getRequestToken
|
|
2716
2716
|
});
|
|
2717
2717
|
if (n.data && n.data.result === 0) {
|
|
2718
|
-
const o =
|
|
2718
|
+
const o = b.get(n.data, "retVal", []);
|
|
2719
2719
|
this.languages = o.map((s) => ({
|
|
2720
2720
|
langCode: s.language || s.langCode || s,
|
|
2721
2721
|
langName: s.langName || s.language || s
|
|
@@ -2806,13 +2806,13 @@ class lr {
|
|
|
2806
2806
|
const s = e.textContent, i = document.createDocumentFragment();
|
|
2807
2807
|
let r = 0;
|
|
2808
2808
|
if (n.forEach((l) => {
|
|
2809
|
-
const { translatedValue: a, key: d, index:
|
|
2810
|
-
if (
|
|
2811
|
-
const
|
|
2812
|
-
i.appendChild(document.createTextNode(
|
|
2809
|
+
const { translatedValue: a, key: d, index: p } = l;
|
|
2810
|
+
if (p > r) {
|
|
2811
|
+
const h = s.substring(r, p);
|
|
2812
|
+
i.appendChild(document.createTextNode(h));
|
|
2813
2813
|
}
|
|
2814
|
-
const
|
|
2815
|
-
|
|
2814
|
+
const u = document.createElement("span");
|
|
2815
|
+
u.className = "i18n-editable-text i18n-text-overlay", u.setAttribute("data-i18n-key", d), u.textContent = a, i.appendChild(u), this.wrappedElements.add(u), r = p + a.length;
|
|
2816
2816
|
}), r < s.length) {
|
|
2817
2817
|
const l = s.substring(r);
|
|
2818
2818
|
i.appendChild(document.createTextNode(l));
|
|
@@ -2910,7 +2910,7 @@ class lr {
|
|
|
2910
2910
|
type="text"
|
|
2911
2911
|
class="i18n-edit-input"
|
|
2912
2912
|
data-lang="${l.langCode}"
|
|
2913
|
-
value="${this.escapeHtml(
|
|
2913
|
+
value="${this.escapeHtml(b.get(o, l.langCode) || "")}"
|
|
2914
2914
|
placeholder="请输入${l.langName}翻译"
|
|
2915
2915
|
/>
|
|
2916
2916
|
</div>
|
|
@@ -2935,15 +2935,15 @@ class lr {
|
|
|
2935
2935
|
},
|
|
2936
2936
|
preConfirm: async () => {
|
|
2937
2937
|
const l = document.querySelectorAll(".i18n-edit-input"), a = {};
|
|
2938
|
-
l.forEach((
|
|
2939
|
-
a[
|
|
2938
|
+
l.forEach((p) => {
|
|
2939
|
+
a[p.getAttribute("data-lang")] = p.value;
|
|
2940
2940
|
});
|
|
2941
2941
|
const d = document.getElementById("i18n-save-error");
|
|
2942
2942
|
d && (d.style.display = "none", d.textContent = "");
|
|
2943
2943
|
try {
|
|
2944
2944
|
return await this.saveTranslations(e, a, n), a;
|
|
2945
|
-
} catch (
|
|
2946
|
-
return d && (d.textContent =
|
|
2945
|
+
} catch (p) {
|
|
2946
|
+
return d && (d.textContent = p.message || "保存失败,请检查网络连接或权限", d.style.display = "block"), !1;
|
|
2947
2947
|
}
|
|
2948
2948
|
}
|
|
2949
2949
|
});
|
|
@@ -2975,7 +2975,7 @@ class lr {
|
|
|
2975
2975
|
data: {
|
|
2976
2976
|
appCode: this.appCode,
|
|
2977
2977
|
commaSeparatedKeys: e,
|
|
2978
|
-
commaSeparatedLangs:
|
|
2978
|
+
commaSeparatedLangs: b.map(this.languages, "langCode").toString(),
|
|
2979
2979
|
searchBlur: "",
|
|
2980
2980
|
page: o,
|
|
2981
2981
|
pageSize: 10
|
|
@@ -2984,7 +2984,7 @@ class lr {
|
|
|
2984
2984
|
getRequestToken: this.getRequestToken
|
|
2985
2985
|
});
|
|
2986
2986
|
if (s.data && s.data.result === 0)
|
|
2987
|
-
return
|
|
2987
|
+
return b.get(s.data, "retVal.datas", []);
|
|
2988
2988
|
} catch (n) {
|
|
2989
2989
|
console.error("获取翻译数据失败:", n);
|
|
2990
2990
|
}
|
|
@@ -2995,8 +2995,8 @@ class lr {
|
|
|
2995
2995
|
*/
|
|
2996
2996
|
getChangedTranslationData(e, n, o) {
|
|
2997
2997
|
const s = o[0], i = (s == null ? void 0 : s.page) || "", r = [];
|
|
2998
|
-
return
|
|
2999
|
-
l !==
|
|
2998
|
+
return b.map(n, (l, a) => {
|
|
2999
|
+
l !== b.get(s, a) && r.push({
|
|
3000
3000
|
appCode: this.appCode,
|
|
3001
3001
|
page: i,
|
|
3002
3002
|
key: e,
|
|
@@ -3010,7 +3010,7 @@ class lr {
|
|
|
3010
3010
|
async saveTranslations(e, n, o) {
|
|
3011
3011
|
var r;
|
|
3012
3012
|
const s = this.getChangedTranslationData(e, n, o);
|
|
3013
|
-
if (
|
|
3013
|
+
if (b.isEmpty(s))
|
|
3014
3014
|
return !0;
|
|
3015
3015
|
const i = await Zt({
|
|
3016
3016
|
data: { data: s, isLocal: "F" },
|
|
@@ -3061,16 +3061,16 @@ function ur() {
|
|
|
3061
3061
|
function r(a, d) {
|
|
3062
3062
|
if (!i[a]) {
|
|
3063
3063
|
i[a] = {};
|
|
3064
|
-
for (var
|
|
3065
|
-
i[a][a.charAt(
|
|
3064
|
+
for (var p = 0; p < a.length; p++)
|
|
3065
|
+
i[a][a.charAt(p)] = p;
|
|
3066
3066
|
}
|
|
3067
3067
|
return i[a][d];
|
|
3068
3068
|
}
|
|
3069
3069
|
var l = {
|
|
3070
3070
|
compressToBase64: function(a) {
|
|
3071
3071
|
if (a == null) return "";
|
|
3072
|
-
var d = l._compress(a, 6, function(
|
|
3073
|
-
return o.charAt(
|
|
3072
|
+
var d = l._compress(a, 6, function(p) {
|
|
3073
|
+
return o.charAt(p);
|
|
3074
3074
|
});
|
|
3075
3075
|
switch (d.length % 4) {
|
|
3076
3076
|
// To produce valid Base64
|
|
@@ -3103,22 +3103,22 @@ function ur() {
|
|
|
3103
3103
|
},
|
|
3104
3104
|
//compress into uint8array (UCS-2 big endian format)
|
|
3105
3105
|
compressToUint8Array: function(a) {
|
|
3106
|
-
for (var d = l.compress(a),
|
|
3107
|
-
var x = d.charCodeAt(
|
|
3108
|
-
u
|
|
3106
|
+
for (var d = l.compress(a), p = new Uint8Array(d.length * 2), u = 0, h = d.length; u < h; u++) {
|
|
3107
|
+
var x = d.charCodeAt(u);
|
|
3108
|
+
p[u * 2] = x >>> 8, p[u * 2 + 1] = x % 256;
|
|
3109
3109
|
}
|
|
3110
|
-
return
|
|
3110
|
+
return p;
|
|
3111
3111
|
},
|
|
3112
3112
|
//decompress from uint8array (UCS-2 big endian format)
|
|
3113
3113
|
decompressFromUint8Array: function(a) {
|
|
3114
3114
|
if (a == null)
|
|
3115
3115
|
return l.decompress(a);
|
|
3116
|
-
for (var d = new Array(a.length / 2),
|
|
3117
|
-
d[
|
|
3118
|
-
var
|
|
3116
|
+
for (var d = new Array(a.length / 2), p = 0, u = d.length; p < u; p++)
|
|
3117
|
+
d[p] = a[p * 2] * 256 + a[p * 2 + 1];
|
|
3118
|
+
var h = [];
|
|
3119
3119
|
return d.forEach(function(x) {
|
|
3120
|
-
|
|
3121
|
-
}), l.decompress(
|
|
3120
|
+
h.push(n(x));
|
|
3121
|
+
}), l.decompress(h.join(""));
|
|
3122
3122
|
},
|
|
3123
3123
|
//compress into a string that is already URI encoded
|
|
3124
3124
|
compressToEncodedURIComponent: function(a) {
|
|
@@ -3137,57 +3137,57 @@ function ur() {
|
|
|
3137
3137
|
return n(d);
|
|
3138
3138
|
});
|
|
3139
3139
|
},
|
|
3140
|
-
_compress: function(a, d,
|
|
3140
|
+
_compress: function(a, d, p) {
|
|
3141
3141
|
if (a == null) return "";
|
|
3142
|
-
var
|
|
3142
|
+
var u, h, x = {}, L = {}, S = "", B = "", _ = "", w = 2, C = 3, v = 2, k = [], f = 0, m = 0, y;
|
|
3143
3143
|
for (y = 0; y < a.length; y += 1)
|
|
3144
|
-
if (
|
|
3145
|
-
_ =
|
|
3144
|
+
if (S = a.charAt(y), Object.prototype.hasOwnProperty.call(x, S) || (x[S] = C++, L[S] = !0), B = _ + S, Object.prototype.hasOwnProperty.call(x, B))
|
|
3145
|
+
_ = B;
|
|
3146
3146
|
else {
|
|
3147
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
3147
|
+
if (Object.prototype.hasOwnProperty.call(L, _)) {
|
|
3148
3148
|
if (_.charCodeAt(0) < 256) {
|
|
3149
|
-
for (
|
|
3150
|
-
|
|
3151
|
-
for (
|
|
3152
|
-
|
|
3149
|
+
for (u = 0; u < v; u++)
|
|
3150
|
+
f = f << 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++;
|
|
3151
|
+
for (h = _.charCodeAt(0), u = 0; u < 8; u++)
|
|
3152
|
+
f = f << 1 | h & 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = h >> 1;
|
|
3153
3153
|
} else {
|
|
3154
|
-
for (
|
|
3155
|
-
|
|
3156
|
-
for (
|
|
3157
|
-
|
|
3154
|
+
for (h = 1, u = 0; u < v; u++)
|
|
3155
|
+
f = f << 1 | h, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = 0;
|
|
3156
|
+
for (h = _.charCodeAt(0), u = 0; u < 16; u++)
|
|
3157
|
+
f = f << 1 | h & 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = h >> 1;
|
|
3158
3158
|
}
|
|
3159
|
-
w--, w == 0 && (w = Math.pow(2, v), v++), delete
|
|
3159
|
+
w--, w == 0 && (w = Math.pow(2, v), v++), delete L[_];
|
|
3160
3160
|
} else
|
|
3161
|
-
for (
|
|
3162
|
-
|
|
3163
|
-
w--, w == 0 && (w = Math.pow(2, v), v++), x[
|
|
3161
|
+
for (h = x[_], u = 0; u < v; u++)
|
|
3162
|
+
f = f << 1 | h & 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = h >> 1;
|
|
3163
|
+
w--, w == 0 && (w = Math.pow(2, v), v++), x[B] = C++, _ = String(S);
|
|
3164
3164
|
}
|
|
3165
3165
|
if (_ !== "") {
|
|
3166
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
3166
|
+
if (Object.prototype.hasOwnProperty.call(L, _)) {
|
|
3167
3167
|
if (_.charCodeAt(0) < 256) {
|
|
3168
|
-
for (
|
|
3169
|
-
|
|
3170
|
-
for (
|
|
3171
|
-
|
|
3168
|
+
for (u = 0; u < v; u++)
|
|
3169
|
+
f = f << 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++;
|
|
3170
|
+
for (h = _.charCodeAt(0), u = 0; u < 8; u++)
|
|
3171
|
+
f = f << 1 | h & 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = h >> 1;
|
|
3172
3172
|
} else {
|
|
3173
|
-
for (
|
|
3174
|
-
|
|
3175
|
-
for (
|
|
3176
|
-
|
|
3173
|
+
for (h = 1, u = 0; u < v; u++)
|
|
3174
|
+
f = f << 1 | h, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = 0;
|
|
3175
|
+
for (h = _.charCodeAt(0), u = 0; u < 16; u++)
|
|
3176
|
+
f = f << 1 | h & 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = h >> 1;
|
|
3177
3177
|
}
|
|
3178
|
-
w--, w == 0 && (w = Math.pow(2, v), v++), delete
|
|
3178
|
+
w--, w == 0 && (w = Math.pow(2, v), v++), delete L[_];
|
|
3179
3179
|
} else
|
|
3180
|
-
for (
|
|
3181
|
-
|
|
3180
|
+
for (h = x[_], u = 0; u < v; u++)
|
|
3181
|
+
f = f << 1 | h & 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = h >> 1;
|
|
3182
3182
|
w--, w == 0 && (w = Math.pow(2, v), v++);
|
|
3183
3183
|
}
|
|
3184
|
-
for (
|
|
3185
|
-
|
|
3184
|
+
for (h = 2, u = 0; u < v; u++)
|
|
3185
|
+
f = f << 1 | h & 1, m == d - 1 ? (m = 0, k.push(p(f)), f = 0) : m++, h = h >> 1;
|
|
3186
3186
|
for (; ; )
|
|
3187
|
-
if (
|
|
3188
|
-
k.push(
|
|
3187
|
+
if (f = f << 1, m == d - 1) {
|
|
3188
|
+
k.push(p(f));
|
|
3189
3189
|
break;
|
|
3190
|
-
} else
|
|
3190
|
+
} else m++;
|
|
3191
3191
|
return k.join("");
|
|
3192
3192
|
},
|
|
3193
3193
|
decompress: function(a) {
|
|
@@ -3195,52 +3195,52 @@ function ur() {
|
|
|
3195
3195
|
return a.charCodeAt(d);
|
|
3196
3196
|
});
|
|
3197
3197
|
},
|
|
3198
|
-
_decompress: function(a, d,
|
|
3199
|
-
var
|
|
3198
|
+
_decompress: function(a, d, p) {
|
|
3199
|
+
var u = [], h = 4, x = 4, L = 3, S = "", B = [], _, w, C, v, k, f, m, y = { val: p(0), position: d, index: 1 };
|
|
3200
3200
|
for (_ = 0; _ < 3; _ += 1)
|
|
3201
|
-
|
|
3202
|
-
for (C = 0, k = Math.pow(2, 2),
|
|
3203
|
-
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val =
|
|
3201
|
+
u[_] = _;
|
|
3202
|
+
for (C = 0, k = Math.pow(2, 2), f = 1; f != k; )
|
|
3203
|
+
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val = p(y.index++)), C |= (v > 0 ? 1 : 0) * f, f <<= 1;
|
|
3204
3204
|
switch (C) {
|
|
3205
3205
|
case 0:
|
|
3206
|
-
for (C = 0, k = Math.pow(2, 8),
|
|
3207
|
-
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val =
|
|
3208
|
-
|
|
3206
|
+
for (C = 0, k = Math.pow(2, 8), f = 1; f != k; )
|
|
3207
|
+
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val = p(y.index++)), C |= (v > 0 ? 1 : 0) * f, f <<= 1;
|
|
3208
|
+
m = n(C);
|
|
3209
3209
|
break;
|
|
3210
3210
|
case 1:
|
|
3211
|
-
for (C = 0, k = Math.pow(2, 16),
|
|
3212
|
-
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val =
|
|
3213
|
-
|
|
3211
|
+
for (C = 0, k = Math.pow(2, 16), f = 1; f != k; )
|
|
3212
|
+
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val = p(y.index++)), C |= (v > 0 ? 1 : 0) * f, f <<= 1;
|
|
3213
|
+
m = n(C);
|
|
3214
3214
|
break;
|
|
3215
3215
|
case 2:
|
|
3216
3216
|
return "";
|
|
3217
3217
|
}
|
|
3218
|
-
for (
|
|
3218
|
+
for (u[3] = m, w = m, B.push(m); ; ) {
|
|
3219
3219
|
if (y.index > a)
|
|
3220
3220
|
return "";
|
|
3221
|
-
for (C = 0, k = Math.pow(2,
|
|
3222
|
-
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val =
|
|
3223
|
-
switch (
|
|
3221
|
+
for (C = 0, k = Math.pow(2, L), f = 1; f != k; )
|
|
3222
|
+
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val = p(y.index++)), C |= (v > 0 ? 1 : 0) * f, f <<= 1;
|
|
3223
|
+
switch (m = C) {
|
|
3224
3224
|
case 0:
|
|
3225
|
-
for (C = 0, k = Math.pow(2, 8),
|
|
3226
|
-
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val =
|
|
3227
|
-
|
|
3225
|
+
for (C = 0, k = Math.pow(2, 8), f = 1; f != k; )
|
|
3226
|
+
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val = p(y.index++)), C |= (v > 0 ? 1 : 0) * f, f <<= 1;
|
|
3227
|
+
u[x++] = n(C), m = x - 1, h--;
|
|
3228
3228
|
break;
|
|
3229
3229
|
case 1:
|
|
3230
|
-
for (C = 0, k = Math.pow(2, 16),
|
|
3231
|
-
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val =
|
|
3232
|
-
|
|
3230
|
+
for (C = 0, k = Math.pow(2, 16), f = 1; f != k; )
|
|
3231
|
+
v = y.val & y.position, y.position >>= 1, y.position == 0 && (y.position = d, y.val = p(y.index++)), C |= (v > 0 ? 1 : 0) * f, f <<= 1;
|
|
3232
|
+
u[x++] = n(C), m = x - 1, h--;
|
|
3233
3233
|
break;
|
|
3234
3234
|
case 2:
|
|
3235
|
-
return
|
|
3235
|
+
return B.join("");
|
|
3236
3236
|
}
|
|
3237
|
-
if (
|
|
3238
|
-
|
|
3239
|
-
else if (
|
|
3240
|
-
|
|
3237
|
+
if (h == 0 && (h = Math.pow(2, L), L++), u[m])
|
|
3238
|
+
S = u[m];
|
|
3239
|
+
else if (m === x)
|
|
3240
|
+
S = w + w.charAt(0);
|
|
3241
3241
|
else
|
|
3242
3242
|
return null;
|
|
3243
|
-
|
|
3243
|
+
B.push(S), u[x++] = w + S.charAt(0), h--, w = S, h == 0 && (h = Math.pow(2, L), L++);
|
|
3244
3244
|
}
|
|
3245
3245
|
}
|
|
3246
3246
|
};
|
|
@@ -3463,14 +3463,14 @@ const Ht = {
|
|
|
3463
3463
|
w[v] = C[v];
|
|
3464
3464
|
});
|
|
3465
3465
|
}), w;
|
|
3466
|
-
}), d = He(() => a.value[n.value] || ""),
|
|
3466
|
+
}), d = He(() => a.value[n.value] || ""), p = He(() => Object.keys(a.value).filter((C) => C !== n.value).map((C) => ({
|
|
3467
3467
|
lang: C,
|
|
3468
3468
|
value: a.value[C]
|
|
3469
|
-
}))),
|
|
3469
|
+
}))), u = (w) => {
|
|
3470
3470
|
if (!w) return "";
|
|
3471
3471
|
const C = document.createElement("div");
|
|
3472
3472
|
return C.textContent = w, C.innerHTML;
|
|
3473
|
-
},
|
|
3473
|
+
}, h = (w) => {
|
|
3474
3474
|
w.data && w.data.type === "updateLanguage" && (n.value = E.get("I18N_LANGUAGE") || "zh-CN");
|
|
3475
3475
|
}, x = () => {
|
|
3476
3476
|
if (typeof window > "u") return;
|
|
@@ -3486,11 +3486,11 @@ const Ht = {
|
|
|
3486
3486
|
Array.from(new Set(v)).forEach((k) => {
|
|
3487
3487
|
k.postMessage(w, C);
|
|
3488
3488
|
});
|
|
3489
|
-
},
|
|
3489
|
+
}, L = () => {
|
|
3490
3490
|
window.addEventListener("storage", (w) => {
|
|
3491
3491
|
w.key === "I18N_LANGUAGE" && (n.value = w.newValue || "zh-CN");
|
|
3492
3492
|
});
|
|
3493
|
-
},
|
|
3493
|
+
}, S = async () => {
|
|
3494
3494
|
i.value.length === 0 && await l();
|
|
3495
3495
|
const w = i.value.map(
|
|
3496
3496
|
(k) => `
|
|
@@ -3500,7 +3500,7 @@ const Ht = {
|
|
|
3500
3500
|
type="text"
|
|
3501
3501
|
class="i18n-edit-input"
|
|
3502
3502
|
data-lang="${k.langCode}"
|
|
3503
|
-
value="${
|
|
3503
|
+
value="${u(a.value[k.langCode] || "")}"
|
|
3504
3504
|
placeholder="请输入${k.langName}"
|
|
3505
3505
|
/>
|
|
3506
3506
|
</div>
|
|
@@ -3524,23 +3524,23 @@ const Ht = {
|
|
|
3524
3524
|
htmlContainer: "i18n-earth-modal-content"
|
|
3525
3525
|
},
|
|
3526
3526
|
preConfirm: async () => {
|
|
3527
|
-
const k = document.querySelectorAll(".i18n-edit-input"),
|
|
3527
|
+
const k = document.querySelectorAll(".i18n-edit-input"), f = {};
|
|
3528
3528
|
k.forEach((y) => {
|
|
3529
|
-
|
|
3529
|
+
f[y.getAttribute("data-lang")] = y.value;
|
|
3530
3530
|
});
|
|
3531
|
-
const
|
|
3532
|
-
if (
|
|
3531
|
+
const m = document.getElementById("i18n-save-error");
|
|
3532
|
+
if (m && (m.style.display = "none", m.textContent = ""), t.request && typeof t.request == "function")
|
|
3533
3533
|
try {
|
|
3534
|
-
return await t.request(
|
|
3534
|
+
return await t.request(f), f;
|
|
3535
3535
|
} catch (y) {
|
|
3536
|
-
return
|
|
3536
|
+
return m && (m.textContent = y.message || "保存失败", m.style.display = "block"), !1;
|
|
3537
3537
|
}
|
|
3538
|
-
return
|
|
3538
|
+
return f;
|
|
3539
3539
|
}
|
|
3540
3540
|
});
|
|
3541
3541
|
if (v && C) {
|
|
3542
|
-
const k = Object.keys(C).map((
|
|
3543
|
-
[
|
|
3542
|
+
const k = Object.keys(C).map((f) => ({
|
|
3543
|
+
[f]: C[f]
|
|
3544
3544
|
}));
|
|
3545
3545
|
e("update:modelValue", k), x(), M.fire({
|
|
3546
3546
|
text: "保存成功",
|
|
@@ -3551,8 +3551,8 @@ const Ht = {
|
|
|
3551
3551
|
toast: !0
|
|
3552
3552
|
});
|
|
3553
3553
|
}
|
|
3554
|
-
},
|
|
3555
|
-
const w =
|
|
3554
|
+
}, B = () => {
|
|
3555
|
+
const w = p.value;
|
|
3556
3556
|
if (w.length === 0) {
|
|
3557
3557
|
M.fire({
|
|
3558
3558
|
title: "多语言翻译",
|
|
@@ -3593,10 +3593,10 @@ const Ht = {
|
|
|
3593
3593
|
}
|
|
3594
3594
|
});
|
|
3595
3595
|
}, _ = () => {
|
|
3596
|
-
t.request && typeof t.request == "function" ?
|
|
3596
|
+
t.request && typeof t.request == "function" ? S() : B();
|
|
3597
3597
|
};
|
|
3598
3598
|
return to(() => {
|
|
3599
|
-
r(), l(), window.addEventListener("message",
|
|
3599
|
+
r(), l(), window.addEventListener("message", h), L();
|
|
3600
3600
|
}), {
|
|
3601
3601
|
currentValue: d,
|
|
3602
3602
|
openModal: _
|
|
@@ -3679,41 +3679,41 @@ function yr(t) {
|
|
|
3679
3679
|
const { locale: e = "zh-CN", messages: n = {} } = t, o = Zn(n), s = ie(e), i = ie(0), r = Ct(), l = Qn() && r && typeof r.observable == "function" ? r.observable({
|
|
3680
3680
|
locale: e,
|
|
3681
3681
|
messageVersion: 0
|
|
3682
|
-
}) : null, a = () => l ? l.locale : s.value, d = (
|
|
3683
|
-
s.value =
|
|
3684
|
-
},
|
|
3682
|
+
}) : null, a = () => l ? l.locale : s.value, d = (h) => {
|
|
3683
|
+
s.value = h, l && (l.locale = h);
|
|
3684
|
+
}, p = () => {
|
|
3685
3685
|
i.value += 1, l && (l.messageVersion += 1);
|
|
3686
|
-
},
|
|
3686
|
+
}, u = {
|
|
3687
3687
|
// 当前语言 (兼容 Vue 3 的 .value 访问)
|
|
3688
3688
|
locale: {
|
|
3689
3689
|
get value() {
|
|
3690
3690
|
return a();
|
|
3691
3691
|
},
|
|
3692
|
-
set value(
|
|
3693
|
-
d(
|
|
3692
|
+
set value(h) {
|
|
3693
|
+
d(h);
|
|
3694
3694
|
}
|
|
3695
3695
|
},
|
|
3696
3696
|
// 翻译函数(支持嵌套 key 的点号访问)
|
|
3697
|
-
t(
|
|
3698
|
-
const
|
|
3699
|
-
x =
|
|
3700
|
-
const
|
|
3701
|
-
if (
|
|
3702
|
-
return pe(x ||
|
|
3703
|
-
const _ = Ft(o,
|
|
3704
|
-
let w = _[
|
|
3705
|
-
return w === void 0 &&
|
|
3697
|
+
t(h, x, L) {
|
|
3698
|
+
const S = Xn(x, L);
|
|
3699
|
+
x = S.defaultValue, L = S.values, i.value, l && l.messageVersion;
|
|
3700
|
+
const B = a();
|
|
3701
|
+
if (B === "zh-CN" && !h.startsWith("i.") && !h.startsWith("pro."))
|
|
3702
|
+
return pe(x || h, L);
|
|
3703
|
+
const _ = Ft(o, B);
|
|
3704
|
+
let w = _[h];
|
|
3705
|
+
return w === void 0 && h.includes(".") && (w = h.split(".").reduce((v, k) => v && typeof v == "object" ? v[k] : void 0, _)), w != null && w !== h ? pe(w, L) : pe(x || h, L);
|
|
3706
3706
|
},
|
|
3707
3707
|
// 设置某个语言的所有消息
|
|
3708
|
-
setLocaleMessage(
|
|
3709
|
-
return o[ge(
|
|
3708
|
+
setLocaleMessage(h, x) {
|
|
3709
|
+
return o[ge(h)] = { ...x }, p(), o[ge(h)];
|
|
3710
3710
|
},
|
|
3711
3711
|
// 获取某个语言的消息
|
|
3712
|
-
getLocaleMessage(
|
|
3713
|
-
return Ft(o,
|
|
3712
|
+
getLocaleMessage(h) {
|
|
3713
|
+
return Ft(o, h);
|
|
3714
3714
|
}
|
|
3715
3715
|
};
|
|
3716
|
-
return
|
|
3716
|
+
return u.global = u, u;
|
|
3717
3717
|
}
|
|
3718
3718
|
const Jn = st.create({
|
|
3719
3719
|
timeout: 8e3
|
|
@@ -3819,19 +3819,19 @@ class J {
|
|
|
3819
3819
|
userCode: l,
|
|
3820
3820
|
loginRouteName: a,
|
|
3821
3821
|
login: d,
|
|
3822
|
-
keyboard:
|
|
3823
|
-
locale:
|
|
3824
|
-
env:
|
|
3822
|
+
keyboard: p,
|
|
3823
|
+
locale: u,
|
|
3824
|
+
env: h,
|
|
3825
3825
|
dev: x,
|
|
3826
|
-
i18nTokenRequest:
|
|
3827
|
-
auth:
|
|
3826
|
+
i18nTokenRequest: L,
|
|
3827
|
+
auth: S
|
|
3828
3828
|
} = e;
|
|
3829
|
-
this.env =
|
|
3829
|
+
this.env = h || "local", this.baseUrl = Kt({ env: h, dev: x }), this.i18nTokenRequest = L || null, this.baseToken = i || (E.get("I18N_CONFIG") || {}).token || E.get("token"), this.token = this.baseToken, this.auth = S || null, this.authInfo = {
|
|
3830
3830
|
appCode: o,
|
|
3831
3831
|
orgCode: r || "",
|
|
3832
3832
|
userCode: l || ""
|
|
3833
|
-
}, this.getRequestToken = this.getRequestToken.bind(this), this.requestAuthIdentity = null, this.tokenResolveVersion = 0, this.manualAuthScope = Xe(this.authInfo) || (i ? ot(i) : ""), this.authUnsubscribe = null, this.authVersion = 0, this.languageVersion = 0, this.activeCacheScope = this.manualAuthScope || "guest", this.loadI18n = !0, this.appCode = o, this.router = n, this.locale = this.resolveInitialLocale(
|
|
3834
|
-
if (
|
|
3833
|
+
}, this.getRequestToken = this.getRequestToken.bind(this), this.requestAuthIdentity = null, this.tokenResolveVersion = 0, this.manualAuthScope = Xe(this.authInfo) || (i ? ot(i) : ""), this.authUnsubscribe = null, this.authVersion = 0, this.languageVersion = 0, this.activeCacheScope = this.manualAuthScope || "guest", this.loadI18n = !0, this.appCode = o, this.router = n, this.locale = this.resolveInitialLocale(u), this._isRTL = Ee(this.locale), this.persistI18nConfig(), this.name = "", this.messages = Zn(s || {}), this.translationKeys = [], this.translationKeySet = /* @__PURE__ */ new Set(), this.loginRouteName = a || "login", this.login = d, this.loginTranslationKeys = [], this.keyboard = p || "ctrl+shift+l", this.vueInstances = /* @__PURE__ */ new Set(), this.vueApps = /* @__PURE__ */ new Set(), this.editKeyboard = e.editKeyboard || "ctrl+shift+e", this.applyAuthState(this.resolveAuthState(), { silent: !0 }), this.initI18n(e), this.router && this.initRouterGuards(), xt.bind(this.keyboard, (B) => {
|
|
3834
|
+
if (B.preventDefault(), this.name === this.loginRouteName)
|
|
3835
3835
|
return;
|
|
3836
3836
|
const _ = Array.from(this.translationKeySet);
|
|
3837
3837
|
this.translationKeys = Array.from(
|
|
@@ -3888,8 +3888,8 @@ class J {
|
|
|
3888
3888
|
this.configInstance && (this.configInstance.destroy(), this.configInstance = null);
|
|
3889
3889
|
}
|
|
3890
3890
|
});
|
|
3891
|
-
}), xt.bind(this.editKeyboard, (
|
|
3892
|
-
|
|
3891
|
+
}), xt.bind(this.editKeyboard, (B) => {
|
|
3892
|
+
B.preventDefault(), cr.toggle();
|
|
3893
3893
|
}), this.setupLanguageChangeListener(), this.setupAuthListener(), this.setupMessageListener();
|
|
3894
3894
|
}
|
|
3895
3895
|
/**
|
|
@@ -3925,8 +3925,8 @@ class J {
|
|
|
3925
3925
|
});
|
|
3926
3926
|
}
|
|
3927
3927
|
resolveAuthState() {
|
|
3928
|
-
var u, h
|
|
3929
|
-
const e = this.auth || {}, n = oe(e.getToken) ?? "", o = oe(e.getScope) ?? oe(e.getUserScope) ?? "", s = oe(e.getAppCode) ?? ((
|
|
3928
|
+
var p, u, h;
|
|
3929
|
+
const e = this.auth || {}, n = oe(e.getToken) ?? "", o = oe(e.getScope) ?? oe(e.getUserScope) ?? "", s = oe(e.getAppCode) ?? ((p = this.authInfo) == null ? void 0 : p.appCode) ?? this.appCode, i = oe(e.getOrgCode) ?? ((u = this.authInfo) == null ? void 0 : u.orgCode) ?? "", r = oe(e.getUserCode) ?? ((h = this.authInfo) == null ? void 0 : h.userCode) ?? "", l = Xe({ appCode: s, orgCode: i, userCode: r }), a = typeof e.isAuthenticated == "function" ? !!e.isAuthenticated() : !!n || !!(this.i18nTokenRequest && l), d = a ? String(
|
|
3930
3930
|
o || ot(n) || l || this.manualAuthScope || "user"
|
|
3931
3931
|
) : "guest";
|
|
3932
3932
|
return {
|
|
@@ -4119,21 +4119,21 @@ class J {
|
|
|
4119
4119
|
if (typeof d == "function" && d.toString().includes("import("))
|
|
4120
4120
|
try {
|
|
4121
4121
|
d = await d(), d = d.default;
|
|
4122
|
-
} catch (
|
|
4123
|
-
console.error("加载异步组件时出错:",
|
|
4122
|
+
} catch (u) {
|
|
4123
|
+
console.error("加载异步组件时出错:", u), o();
|
|
4124
4124
|
return;
|
|
4125
4125
|
}
|
|
4126
|
-
const
|
|
4127
|
-
this.loginTranslationKeys =
|
|
4126
|
+
const p = Vt(d);
|
|
4127
|
+
this.loginTranslationKeys = p;
|
|
4128
4128
|
}
|
|
4129
4129
|
if (e.matched.length > 0)
|
|
4130
4130
|
try {
|
|
4131
4131
|
const d = [];
|
|
4132
|
-
for (const
|
|
4133
|
-
let
|
|
4134
|
-
if (typeof
|
|
4135
|
-
const
|
|
4136
|
-
d.push(...
|
|
4132
|
+
for (const p of e.matched) {
|
|
4133
|
+
let u = (a = p.components) == null ? void 0 : a.default;
|
|
4134
|
+
if (typeof u == "function" && u.toString().includes("import(") && (u = await u(), u = u.default), u) {
|
|
4135
|
+
const h = Vt(u);
|
|
4136
|
+
d.push(...h);
|
|
4137
4137
|
}
|
|
4138
4138
|
}
|
|
4139
4139
|
this.translationKeys = d;
|
|
@@ -4168,22 +4168,20 @@ class J {
|
|
|
4168
4168
|
}), this.keyValueMap = {}, globalThis.__I18N_ALL_KEYS__ = /* @__PURE__ */ new Set();
|
|
4169
4169
|
const n = this;
|
|
4170
4170
|
globalThis.$t = (o, s, i) => {
|
|
4171
|
-
var h,
|
|
4171
|
+
var h, x;
|
|
4172
4172
|
const r = Xn(s, i);
|
|
4173
4173
|
if (s = r.defaultValue, i = r.values, typeof o == "string" && (n.translationKeySet.add(o), globalThis.__I18N_ALL_KEYS__ && globalThis.__I18N_ALL_KEYS__.add(o)), n.i18n.global.locale.value === "zh-CN" && typeof o == "string" && !o.startsWith("i.") && !o.startsWith("pro."))
|
|
4174
4174
|
return pe(s || o, i);
|
|
4175
|
-
const a = (h = n.router) == null ? void 0 : h.currentRoute, d = (
|
|
4175
|
+
const a = (h = n.router) == null ? void 0 : h.currentRoute, d = (x = (a == null ? void 0 : a.value) ?? a) == null ? void 0 : x.name, p = () => {
|
|
4176
|
+
const L = `common.${o}`, S = n.i18n.t(L, void 0, i);
|
|
4177
|
+
return S !== L ? S : n.i18n.t(o, void 0, i);
|
|
4178
|
+
};
|
|
4176
4179
|
let u;
|
|
4177
4180
|
if (d) {
|
|
4178
|
-
const
|
|
4179
|
-
|
|
4180
|
-
u = S;
|
|
4181
|
-
else {
|
|
4182
|
-
const L = `common.${o}`, I = n.i18n.t(L, void 0, i);
|
|
4183
|
-
I !== L ? u = I : u = n.i18n.t(o, void 0, i);
|
|
4184
|
-
}
|
|
4181
|
+
const L = `${d}.${o}`, S = n.i18n.t(L, void 0, i);
|
|
4182
|
+
S !== L ? u = S : u = p();
|
|
4185
4183
|
} else
|
|
4186
|
-
u =
|
|
4184
|
+
u = p();
|
|
4187
4185
|
return u === o && typeof s == "string" && s && (u = s), u = pe(u, i), typeof o == "string" && typeof u == "string" && (n.keyValueMap[u] = o, globalThis.__I18N_KEY_VALUE_MAP__ || (globalThis.__I18N_KEY_VALUE_MAP__ = {}), globalThis.__I18N_KEY_VALUE_MAP__[u] = o), u;
|
|
4188
4186
|
}, this.t = globalThis.$t, globalThis.$deepScan = function(o) {
|
|
4189
4187
|
return o;
|
|
@@ -4310,7 +4308,7 @@ class J {
|
|
|
4310
4308
|
e = this.normalizeLocale(e);
|
|
4311
4309
|
const o = n.cacheScope || this.activeCacheScope || "guest", s = n.authVersion || this.authVersion, i = ++this.languageVersion, r = "I18N_MESSAGES_COMMON_" + e;
|
|
4312
4310
|
let l = E.get(r);
|
|
4313
|
-
if (
|
|
4311
|
+
if (b.isEmpty(l))
|
|
4314
4312
|
try {
|
|
4315
4313
|
const a = await Jn.get(
|
|
4316
4314
|
`https://cdn.ihotel.cn/i18n_messages/${e}.json`
|
|
@@ -4338,18 +4336,18 @@ class J {
|
|
|
4338
4336
|
if (s !== this.authVersion || i !== this.languageVersion)
|
|
4339
4337
|
return !1;
|
|
4340
4338
|
if (a && Array.isArray(a)) {
|
|
4341
|
-
const d = so(a),
|
|
4339
|
+
const d = so(a), p = b.assign(
|
|
4342
4340
|
{},
|
|
4343
4341
|
l,
|
|
4344
|
-
|
|
4342
|
+
b.get(this.messages, e),
|
|
4345
4343
|
d
|
|
4346
4344
|
);
|
|
4347
|
-
this.i18n.global.setLocaleMessage(e,
|
|
4345
|
+
this.i18n.global.setLocaleMessage(e, p);
|
|
4348
4346
|
} else {
|
|
4349
|
-
const d =
|
|
4347
|
+
const d = b.assign(
|
|
4350
4348
|
{},
|
|
4351
4349
|
l,
|
|
4352
|
-
|
|
4350
|
+
b.get(this.messages, e)
|
|
4353
4351
|
);
|
|
4354
4352
|
this.i18n.global.setLocaleMessage(e, d);
|
|
4355
4353
|
}
|
|
@@ -4357,10 +4355,10 @@ class J {
|
|
|
4357
4355
|
} catch (a) {
|
|
4358
4356
|
if (console.error(`设置语言 ${e} 失败,使用本地消息继续运行:`, a), s !== this.authVersion || i !== this.languageVersion)
|
|
4359
4357
|
return !1;
|
|
4360
|
-
const d =
|
|
4358
|
+
const d = b.assign(
|
|
4361
4359
|
{},
|
|
4362
4360
|
l,
|
|
4363
|
-
|
|
4361
|
+
b.get(this.messages, e)
|
|
4364
4362
|
);
|
|
4365
4363
|
return this.i18n.global.setLocaleMessage(e, d), this.locale = e, this._isRTL = Ee(e), this.i18n.global.locale.value = e, E.set("I18N_LANGUAGE", e), this.persistI18nConfig(), this.updateDocumentDir(), this.notifyLanguageChanged(e, !1), !1;
|
|
4366
4364
|
}
|