mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-11-30 03:07:36 +08:00
Improve example lang. (#990)
This commit is contained in:
parent
63d68f8f0e
commit
b215f71d2e
@ -200,6 +200,7 @@
|
||||
methods: {
|
||||
switchLang(targetLang) {
|
||||
if (this.lang === targetLang) return;
|
||||
localStorage.setItem('ELEMENT_LANGUAGE', targetLang);
|
||||
this.$router.push(this.$route.path.replace(this.lang, targetLang));
|
||||
}
|
||||
},
|
||||
|
@ -85,12 +85,18 @@ langs.forEach(lang => {
|
||||
route = route.concat(generateMiscRoutes(lang.lang));
|
||||
});
|
||||
|
||||
let userLanguage = localStorage.getItem('ELEMENT_LANGUAGE') || window.navigator.language;
|
||||
let defaultPath = '/en-US';
|
||||
if (userLanguage.indexOf('zh-') !== -1) {
|
||||
defaultPath = '/zh-CN';
|
||||
}
|
||||
|
||||
route = route.concat([{
|
||||
path: '/',
|
||||
redirect: '/zh-CN'
|
||||
redirect: defaultPath
|
||||
}, {
|
||||
path: '*',
|
||||
redirect: '/zh-CN'
|
||||
redirect: defaultPath
|
||||
}]);
|
||||
|
||||
export default route;
|
||||
|
Loading…
Reference in New Issue
Block a user