Skip to content

Commit 24b0b3f

Browse files
fix: switching between zh and en bug (#720)
* fix:switching between zh and en bug * Update common.mk --------- Co-authored-by: Rick <[email protected]>
1 parent 9e5fdd8 commit 24b0b3f

File tree

6 files changed

+25
-11
lines changed

6 files changed

+25
-11
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'
@@ -21,8 +21,12 @@ import WelcomePage from './views/WelcomePage.vue'
2121
import DataManager from './views/DataManager.vue'
2222
import MagicKey from './components/MagicKey.vue'
2323
import { useI18n } from 'vue-i18n'
24+
import ElementPlus from 'element-plus';
25+
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
26+
import enUS from 'element-plus/dist/locale/en.mjs'
2427
2528
const { t, locale: i18nLocale } = useI18n()
29+
const app = getCurrentInstance()?.appContext.app;
2630
2731
import { setAsDarkTheme, getThemes, setTheme, getTheme } from './theme'
2832
@@ -67,19 +71,25 @@ const handleSelect = (key: string) => {
6771
const locale = ref(Cache.GetPreference().language)
6872
i18nLocale.value = locale.value
6973
70-
watch(locale, (e: string) =>{
71-
Cache.WithLocale(e)
72-
i18nLocale.value = e
73-
})
74+
watch(locale, (newLocale: string) => {
75+
updateLocale(newLocale);
76+
});
77+
const updateLocale = (newLocale: string) => {
78+
locale.value = newLocale;
79+
i18nLocale.value = newLocale;
80+
Cache.WithLocale(newLocale);
7481
82+
const elementLocale = newLocale === 'zh-CN' ? zhCn : enUS;
83+
app?.use(ElementPlus, { locale: elementLocale });
84+
};
7585
const handleChangeLan = (command: string) => {
7686
switch (command) {
7787
case "chinese":
78-
locale.value = "zh-CN"
79-
break;
88+
locale.value = 'zh-CN';
89+
break;
8090
case "english":
81-
locale.value = "en-US"
82-
break;
91+
locale.value = 'en-US';
92+
break;
8393
}
8494
};
8595

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"codeGenerator": "代码生成",
4343
"testing": "测试",
4444
"history": "测试历史",
45+
"mock": "模拟",
4546
"welcome": "欢迎",
4647
"secrets": "凭据",
4748
"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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ const renameTestSuite = (name: string) => {
314314
<HistoryInput placeholder="API" v-model="suite.api" group="apiAddress" />
315315
</el-form-item>
316316
<table class="full-width">
317+
<tbody>
317318
<tr>
318319
<td>
319320
<el-select
@@ -337,6 +338,7 @@ const renameTestSuite = (name: string) => {
337338
/>
338339
</td>
339340
</tr>
341+
</tbody>
340342
</table>
341343

342344
<el-collapse>

0 commit comments

Comments
 (0)