yh-i18n 2.2.14 → 2.2.15
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/index.js +4 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -40,6 +40,7 @@ window.translateReady = localStorage.translateReady ? localStorage.translateRead
|
|
|
40
40
|
let contentReady = false;
|
|
41
41
|
|
|
42
42
|
const keySet = new Set();
|
|
43
|
+
window.keySet = keySet;
|
|
43
44
|
Object.keys(zhCNBase).forEach((key) => {
|
|
44
45
|
keySet.add(key);
|
|
45
46
|
});
|
|
@@ -47,7 +48,7 @@ Object.keys(zhCNBase).forEach((key) => {
|
|
|
47
48
|
const unHandle = [];
|
|
48
49
|
|
|
49
50
|
function addTranslate (key) {
|
|
50
|
-
if (key.indexOf("vxe") === -1) {
|
|
51
|
+
if (key && key.indexOf("vxe") === -1) {
|
|
51
52
|
try {
|
|
52
53
|
axios.request({
|
|
53
54
|
url: "/translate/insert",
|
|
@@ -77,7 +78,6 @@ function recursionAddTranslate () {
|
|
|
77
78
|
}
|
|
78
79
|
// 通过延时降低任务密度,避免挤兑正常逻辑的运算资源
|
|
79
80
|
recursionAddTimer = setTimeout(() => {
|
|
80
|
-
cLog(`${unHandle.length} ${key}`);
|
|
81
81
|
recursionAddTimer = null;
|
|
82
82
|
recursionAddTranslate();
|
|
83
83
|
}, 150);
|
|
@@ -85,14 +85,14 @@ function recursionAddTranslate () {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
export const ct = (key, args) => {
|
|
88
|
-
if (window.translateReady && window.translateCollect) {
|
|
88
|
+
if (key && window.translateReady && window.translateCollect) {
|
|
89
89
|
// 将 键的处理全部放入队列中,避免挤兑正常逻辑的运算资源
|
|
90
90
|
if (!keySet.has(key) && !unHandle.includes(key)) {
|
|
91
91
|
unHandle.push(key);
|
|
92
92
|
recursionAddTranslate();
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
|
-
if (i18n) {
|
|
95
|
+
if (key && i18n) {
|
|
96
96
|
return i18n.global.t(key, args);
|
|
97
97
|
} else {
|
|
98
98
|
return key;
|