语言切换

This commit is contained in:
2023-11-27 10:48:26 +08:00
parent 059b4d35be
commit 2bc55bdf66
15 changed files with 427 additions and 143 deletions

View File

@@ -100,16 +100,16 @@ const router = new VueRouter({
]
})
router.beforeEach((to, from, next) => {
if (!localStorage.getItem('locale')) {
let lang = navigator.language
if (lang === 'zh' || lang === 'zh-CN') {
localStorage.setItem('locale', 'zh-CN')
} else {
localStorage.setItem('locale', 'en-US')
}
}
next()
})
// router.beforeEach((to, from, next) => {
// if (!localStorage.getItem('locale')) {
// let lang = navigator.language
// if (lang === 'zh' || lang === 'zh-CN') {
// localStorage.setItem('locale', 'zh-CN')
// } else {
// localStorage.setItem('locale', 'en-US')
// }
// }
// next()
// })
export default router