gc_i18n 1.3.0 → 1.3.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/lang/index.js +1 -1
- package/package.json +3 -3
- package/packages/index.js +24 -22
- package/vite.config.js +3 -0
- package/lib/gc_i18n.css +0 -1
- package/lib/gc_i18n.js +0 -4332
- package/lib/gc_i18n.umd.cjs +0 -22
package/lang/index.js
CHANGED
|
@@ -27,7 +27,7 @@ export default {
|
|
|
27
27
|
appCode: "TEST",
|
|
28
28
|
router,
|
|
29
29
|
orgCode: import.meta.env.MODE === "unit" ? "DD" : "GREENCLOUD",
|
|
30
|
-
|
|
30
|
+
// locale: localStorage.getItem("I18N_LANGUAGE"),
|
|
31
31
|
// loginRouteName: "Login",
|
|
32
32
|
dev: true,
|
|
33
33
|
login: false,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gc_i18n",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./lib/gc_i18n.umd.cjs",
|
|
6
6
|
"module": "./lib/gc_i18n.js",
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"axios": "^1.7.9",
|
|
17
|
-
"jose": "^6.0.11",
|
|
18
17
|
"jsrsasign": "^11.1.0",
|
|
19
18
|
"keyboardjs": "^2.7.0",
|
|
20
19
|
"lodash-es": "^4.17.21",
|
|
@@ -35,5 +34,6 @@
|
|
|
35
34
|
"vite": "^6.1.0",
|
|
36
35
|
"vite-gc-i18n-plugin": "^1.0.4",
|
|
37
36
|
"vite-plugin-libcss": "^1.1.1"
|
|
38
|
-
}
|
|
37
|
+
},
|
|
38
|
+
"packageManager": "pnpm@10.15.1+sha512.34e538c329b5553014ca8e8f4535997f96180a1d0f614339357449935350d924e22f8614682191264ec33d1462ac21561aff97f6bb18065351c162c7e8f6de67"
|
|
39
39
|
}
|
package/packages/index.js
CHANGED
|
@@ -37,13 +37,15 @@ export default class I18n {
|
|
|
37
37
|
orgCode,
|
|
38
38
|
loginRouteName,
|
|
39
39
|
login,
|
|
40
|
-
keyboard
|
|
40
|
+
keyboard,
|
|
41
|
+
locale
|
|
41
42
|
} = options;
|
|
42
43
|
this.token = token || generateJWT(orgCode) || store2.get("I18N_TOKEN");
|
|
43
44
|
this.loadI18n = true;
|
|
44
45
|
this.appCode = appCode;
|
|
45
46
|
this.router = router;
|
|
46
|
-
this.locale =
|
|
47
|
+
this.locale =
|
|
48
|
+
locale || store2.get("I18N_LANGUAGE") || navigator.language || "zh-CN";
|
|
47
49
|
this.name = "";
|
|
48
50
|
this.messages = messages || {};
|
|
49
51
|
this.translationKeys = [];
|
|
@@ -110,8 +112,8 @@ export default class I18n {
|
|
|
110
112
|
);
|
|
111
113
|
});
|
|
112
114
|
|
|
113
|
-
if (loginRoute) {
|
|
114
|
-
let loginComponent = loginRoute.components
|
|
115
|
+
if (loginRoute && loginRoute.components) {
|
|
116
|
+
let loginComponent = loginRoute.components?.default;
|
|
115
117
|
if (
|
|
116
118
|
typeof loginComponent === "function" &&
|
|
117
119
|
loginComponent.toString().includes("import(")
|
|
@@ -131,29 +133,29 @@ export default class I18n {
|
|
|
131
133
|
this.loginTranslationKeys = loginRouteKeys;
|
|
132
134
|
}
|
|
133
135
|
if (to.matched.length > 0) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
136
|
+
try {
|
|
137
|
+
// 兼容保留:静态扫描路由组件,获取初步 keys(可能不包含自动注册的子组件)
|
|
138
|
+
const allTranslationKeys = [];
|
|
139
|
+
for (const match of to.matched) {
|
|
140
|
+
let component = match.components?.default;
|
|
141
|
+
if (
|
|
142
|
+
typeof component === "function" &&
|
|
143
|
+
component.toString().includes("import(")
|
|
144
|
+
) {
|
|
143
145
|
component = await component();
|
|
144
146
|
component = component.default;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
}
|
|
148
|
+
if (component) {
|
|
149
|
+
const keys = extractTranslationKeys(component);
|
|
150
|
+
allTranslationKeys.push(...keys);
|
|
149
151
|
}
|
|
150
152
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
this.translationKeys = allTranslationKeys;
|
|
154
|
+
} catch (error) {
|
|
155
|
+
console.error("加载异步组件时出错:", error);
|
|
156
|
+
next();
|
|
157
|
+
return;
|
|
155
158
|
}
|
|
156
|
-
this.translationKeys = allTranslationKeys;
|
|
157
159
|
}
|
|
158
160
|
next();
|
|
159
161
|
});
|
package/vite.config.js
CHANGED
package/lib/gc_i18n.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.gc_i18n_spin[data-v-1f438196]{min-height:300px;display:flex;justify-content:center;padding-top:50px}.gc_i18n_tabs[data-v-1f438196]{padding-top:5px}.gc_i18n_tabs[data-v-1f438196] .ivu-tabs-tab{width:111px}.gc_i18n_tabs[data-v-1f438196] .ivu-tabs-content{width:100%}.gc_i18n_tabs[data-v-1f438196] .ivu-tabs-bar{margin-bottom:0!important}.gc_i18n_tabs .ivu-tabs-content[data-v-1f438196]{position:relative;top:-1px}.gc_i18n_tabs .extra[data-v-1f438196]{position:relative;top:-3px;display:flex;align-items:center}.gc_i18n_page[data-v-1f438196]{display:flex;justify-content:space-between;align-items:center;margin-top:10px}
|