Fix some bugs

Fix some bugs
This commit is contained in:
umbor
2023-06-11 14:24:17 +08:00
parent 1974f586d1
commit 4ae0bcec65
3 changed files with 8 additions and 6 deletions

View File

@@ -23,7 +23,7 @@
"naive-ui": "^2.34.4",
"pinia": "^2.1.3",
"vue": "^3.3.4",
"vue-i18n": "^9.3.0-beta.19",
"vue-i18n": "^9.2.2",
"vue-router": "^4.2.1"
},
"devDependencies": {

View File

@@ -68,12 +68,14 @@ onUnmounted(() => {
function changeLocale(){
if(localStorage.getItem('lang') === 'zh-CN'){
locale.value = 'en-US';
localStorage.setItem('lang', locale.value);
let newLang = 'en-US';
locale.value = newLang;
localStorage.setItem('lang', newLang);
location.reload();
} else {
locale.value = 'zh-CN';
localStorage.setItem('lang', locale.value);
let newLang = 'zh-CN';
locale.value = newLang;
localStorage.setItem('lang', newLang);
location.reload();
}
}

View File

@@ -4,7 +4,7 @@ import messages from '@intlify/unplugin-vue-i18n/messages'
//Default language is the same as last setting (undefined is browser language)
let lang = localStorage.getItem('lang');
if(lang === null){
const navLang = navigator.language || navigator.userLanguage;
const navLang = navigator.language;
let localLang = navLang || false;
lang = localLang || 'en-US';
}