Skip to content

Commit 2a28e14

Browse files
fix:switching between zh and en bug
1 parent 2f0dcf4 commit 2a28e14

File tree

7 files changed

+30
-12
lines changed

7 files changed

+30
-12
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ console/atest-desktop/atest.exe
2121
console/atest-desktop/coverage
2222
atest-store-git
2323
.db
24+
.marscode/

console/atest-ui/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

console/atest-ui/src/App.vue

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Guide,
1010
DataAnalysis, Help, Setting
1111
} from '@element-plus/icons-vue'
12-
import { ref, watch } from 'vue'
12+
import { ref, watch, getCurrentInstance} from 'vue'
1313
import { API } from './views/net'
1414
import { Cache } from './views/cache'
1515
import TestingPanel from './views/TestingPanel.vue'
@@ -20,8 +20,12 @@ import SecretManager from './views/SecretManager.vue'
2020
import WelcomePage from './views/WelcomePage.vue'
2121
import DataManager from './views/DataManager.vue'
2222
import { useI18n } from 'vue-i18n'
23+
import ElementPlus from 'element-plus';
24+
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
25+
import enUS from 'element-plus/dist/locale/en.mjs'
2326
2427
const { t, locale: i18nLocale } = useI18n()
28+
const app = getCurrentInstance()?.appContext.app;
2529
2630
import { setAsDarkTheme, getThemes, setTheme, getTheme } from './theme'
2731
@@ -66,19 +70,25 @@ const handleSelect = (key: string) => {
6670
const locale = ref(Cache.GetPreference().language)
6771
i18nLocale.value = locale.value
6872
69-
watch(locale, (e: string) =>{
70-
Cache.WithLocale(e)
71-
i18nLocale.value = e
72-
})
73+
watch(locale, (newLocale: string) => {
74+
updateLocale(newLocale);
75+
});
76+
const updateLocale = (newLocale: string) => {
77+
locale.value = newLocale;
78+
i18nLocale.value = newLocale;
79+
Cache.WithLocale(newLocale);
7380
81+
const elementLocale = newLocale === 'zh-CN' ? zhCn : enUS;
82+
app?.use(ElementPlus, { locale: elementLocale });
83+
};
7484
const handleChangeLan = (command: string) => {
7585
switch (command) {
7686
case "chinese":
77-
locale.value = "zh-CN"
78-
break;
87+
locale.value = 'zh-CN';
88+
break;
7989
case "english":
80-
locale.value = "en-US"
81-
break;
90+
locale.value = 'en-US';
91+
break;
8292
}
8393
};
8494

console/atest-ui/src/locales/zh.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
"codeGenerator": "代码生成",
4040
"testing": "测试",
4141
"history": "测试历史",
42+
"mock": "模拟",
4243
"welcome": "欢迎",
4344
"secrets": "凭据",
4445
"stores": "存储",

console/atest-ui/src/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ app.config.errorHandler = (error) => {
4646
app.use(ElementPlus, {
4747
locale: lang === 'zh' ? zhCn : enUS
4848
})
49-
app.use(i18n)
5049

50+
app.use(i18n)
5151
app.mount('#app')
5252

5353
const dontShowAgain = window.location.search.indexOf('newbie') === -1;

console/atest-ui/src/views/TestSuite.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,8 @@ const renameTestSuite = (name: string) => {
306306
<HistoryInput placeholder="API" v-model="suite.api" group="apiAddress" />
307307
</el-form-item>
308308
<table style="width: 100%">
309-
<tr>
309+
<tbody>
310+
<tr>
310311
<td>
311312
<el-select
312313
v-model="suite.spec.kind"
@@ -329,6 +330,7 @@ const renameTestSuite = (name: string) => {
329330
/>
330331
</td>
331332
</tr>
333+
</tbody>
332334
</table>
333335

334336
<el-collapse>

tools/make/common.mk

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,7 @@ help:
122122
@echo -e "Usage:\n make \033[36m<Target>\033[0m \033[36m<Option>\033[0m\n\nTargets:"
123123
@awk 'BEGIN {FS = ":.*##"; printf ""} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
124124
@echo -e "\n$$USAGE_OPTIONS"
125+
126+
.PHONY: fmt
127+
fmt:
128+
go fmt ./...

0 commit comments

Comments
 (0)