From 2a28e14e19ffaa543b85602c611e046253a76d01 Mon Sep 17 00:00:00 2001 From: user-xixiboliya Date: Sun, 22 Jun 2025 09:45:43 +0800 Subject: [PATCH 1/4] fix:switching between zh and en bug --- .gitignore | 1 + console/atest-ui/package-lock.json | 2 +- console/atest-ui/src/App.vue | 28 ++++++++++++++++-------- console/atest-ui/src/locales/zh.json | 1 + console/atest-ui/src/main.ts | 2 +- console/atest-ui/src/views/TestSuite.vue | 4 +++- tools/make/common.mk | 4 ++++ 7 files changed, 30 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 88cc3940..4ec45982 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ console/atest-desktop/atest.exe console/atest-desktop/coverage atest-store-git .db +.marscode/ \ No newline at end of file diff --git a/console/atest-ui/package-lock.json b/console/atest-ui/package-lock.json index 7413e53a..cac19501 100644 --- a/console/atest-ui/package-lock.json +++ b/console/atest-ui/package-lock.json @@ -21440,4 +21440,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/console/atest-ui/src/App.vue b/console/atest-ui/src/App.vue index 6b14bc17..304a37cd 100644 --- a/console/atest-ui/src/App.vue +++ b/console/atest-ui/src/App.vue @@ -9,7 +9,7 @@ import { Guide, DataAnalysis, Help, Setting } from '@element-plus/icons-vue' -import { ref, watch } from 'vue' +import { ref, watch, getCurrentInstance} from 'vue' import { API } from './views/net' import { Cache } from './views/cache' import TestingPanel from './views/TestingPanel.vue' @@ -20,8 +20,12 @@ import SecretManager from './views/SecretManager.vue' import WelcomePage from './views/WelcomePage.vue' import DataManager from './views/DataManager.vue' import { useI18n } from 'vue-i18n' +import ElementPlus from 'element-plus'; +import zhCn from 'element-plus/dist/locale/zh-cn.mjs' +import enUS from 'element-plus/dist/locale/en.mjs' const { t, locale: i18nLocale } = useI18n() +const app = getCurrentInstance()?.appContext.app; import { setAsDarkTheme, getThemes, setTheme, getTheme } from './theme' @@ -66,19 +70,25 @@ const handleSelect = (key: string) => { const locale = ref(Cache.GetPreference().language) i18nLocale.value = locale.value -watch(locale, (e: string) =>{ - Cache.WithLocale(e) - i18nLocale.value = e -}) +watch(locale, (newLocale: string) => { + updateLocale(newLocale); +}); +const updateLocale = (newLocale: string) => { + locale.value = newLocale; + i18nLocale.value = newLocale; + Cache.WithLocale(newLocale); + const elementLocale = newLocale === 'zh-CN' ? zhCn : enUS; + app?.use(ElementPlus, { locale: elementLocale }); +}; const handleChangeLan = (command: string) => { switch (command) { case "chinese": - locale.value = "zh-CN" - break; + locale.value = 'zh-CN'; + break; case "english": - locale.value = "en-US" - break; + locale.value = 'en-US'; + break; } }; diff --git a/console/atest-ui/src/locales/zh.json b/console/atest-ui/src/locales/zh.json index cb867d7a..604e0e4e 100644 --- a/console/atest-ui/src/locales/zh.json +++ b/console/atest-ui/src/locales/zh.json @@ -39,6 +39,7 @@ "codeGenerator": "代码生成", "testing": "测试", "history": "测试历史", + "mock": "模拟", "welcome": "欢迎", "secrets": "凭据", "stores": "存储", diff --git a/console/atest-ui/src/main.ts b/console/atest-ui/src/main.ts index 10e444e4..233bf633 100644 --- a/console/atest-ui/src/main.ts +++ b/console/atest-ui/src/main.ts @@ -46,8 +46,8 @@ app.config.errorHandler = (error) => { app.use(ElementPlus, { locale: lang === 'zh' ? zhCn : enUS }) -app.use(i18n) +app.use(i18n) app.mount('#app') const dontShowAgain = window.location.search.indexOf('newbie') === -1; diff --git a/console/atest-ui/src/views/TestSuite.vue b/console/atest-ui/src/views/TestSuite.vue index 32510338..b8bf238d 100644 --- a/console/atest-ui/src/views/TestSuite.vue +++ b/console/atest-ui/src/views/TestSuite.vue @@ -306,7 +306,8 @@ const renameTestSuite = (name: string) => { - + + +
{ />
diff --git a/tools/make/common.mk b/tools/make/common.mk index c9a19e3d..7ae165a8 100644 --- a/tools/make/common.mk +++ b/tools/make/common.mk @@ -122,3 +122,7 @@ help: @echo -e "Usage:\n make \033[36m\033[0m \033[36m