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'
1313import { API } from ' ./views/net'
1414import { Cache } from ' ./views/cache'
1515import TestingPanel from ' ./views/TestingPanel.vue'
@@ -20,8 +20,12 @@ import SecretManager from './views/SecretManager.vue'
2020import WelcomePage from ' ./views/WelcomePage.vue'
2121import DataManager from ' ./views/DataManager.vue'
2222import { 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
2427const { t, locale : i18nLocale } = useI18n ()
28+ const app = getCurrentInstance ()?.appContext .app ;
2529
2630import { setAsDarkTheme , getThemes , setTheme , getTheme } from ' ./theme'
2731
@@ -66,19 +70,25 @@ const handleSelect = (key: string) => {
6670const locale = ref (Cache .GetPreference ().language )
6771i18nLocale .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+ };
7484const 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
0 commit comments