File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed
Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ export default {
1919 confirm : "确定" ,
2020 language : "语言" ,
2121 repo : "GitHub 仓库" ,
22- toogleTheme : ' 切换主题' ,
22+ toogleTheme : " 切换主题" ,
2323 copy : "复制" ,
2424 undo : "撤销" ,
2525 } ,
@@ -75,7 +75,7 @@ export default {
7575 confirm : "Confirm" ,
7676 language : "Language" ,
7777 repo : "GitHub Repo" ,
78- toogleTheme : ' Toggle Theme' ,
78+ toogleTheme : " Toggle Theme" ,
7979 copy : "Copy" ,
8080 undo : "Undo" ,
8181 } ,
Original file line number Diff line number Diff line change 4646</template >
4747
4848<script setup lang="ts">
49- import { ref , watchEffect } from " vue" ;
49+ import { onMounted , watch } from " vue" ;
5050import { useI18n } from " vue-i18n" ;
5151
5252const { locale, t } = useI18n ();
53+ onMounted (() => {
54+ const localLocale = localStorage .getItem (" lang" );
55+ const lang = localLocale ?? navigator .language ;
56+ if (lang .startsWith (" zh" )) locale .value = " zh-CN" ;
57+ if (lang .startsWith (" en" )) locale .value = " en-US" ;
58+ document .documentElement .setAttribute (" lang" , locale .value );
59+ watch (locale , () => {
60+ document .documentElement .setAttribute (" lang" , locale .value );
61+ localStorage .setItem (" lang" , locale .value );
62+ });
63+ });
5364
5465import SIconLanguage from " @/ui/icons/language.vue" ;
5566import SIconGtihub from " @/ui/icons/github.vue" ;
5667import SIconAutoTheme from " @/ui/icons/autotheme.vue" ;
5768
58- const lang = ref (" " );
59-
60- watchEffect (() => console .log (lang .value ));
61-
6269function openGithub() {
6370 window .open (" https://github.com/Linho1219/function-plot-GUI" );
6471}
You can’t perform that action at this time.
0 commit comments