feat: 完整的登录页

1.增加校验
2.增加对整个网页的enter监听
3.语言切换功能升级,浏览器记录了所有用户的语言选择
This commit is contained in:
陈劲松
2020-02-19 15:16:38 +08:00
parent 7b49a41d4e
commit 8c0dd042d5
3 changed files with 111 additions and 34 deletions

View File

@@ -129,7 +129,7 @@
data() {
return {
username: sessionStorage.getItem("nz-username"),
language: localStorage.getItem("nz-language"),
language: '',
assetData: [],
activeIndex:'',
activeItemIndex:'',
@@ -350,8 +350,9 @@
})
},
changeLocal(lang) {
if (lang != localStorage.getItem("nz-language")) {
localStorage.setItem("nz-language", lang);
if (lang != localStorage.getItem("nz-language-" + this.username)) {
localStorage.setItem("nz-language-" + this.username, lang);
this.$i18n.locale = lang;
window.location.reload();
}
},
@@ -412,25 +413,35 @@
}
})
},
refreshLang() {
this.language = localStorage.getItem("nz-language-" + this.username);
this.$i18n.locale = this.language;
}
},
created() {
if (!localStorage.getItem("nz-language")) {
/*if (!localStorage.getItem("nz-language")) {
localStorage.setItem("nz-language", "en");
}
this.language = localStorage.getItem("nz-language");
}*/
this.getUserData();
},
mounted() {
this.getUserData();
this.getAssetData();
this.getProjectList();
this.refreshLang();
// 刷新后有高亮
let activePath = this.$route.path.slice(1);
this.activeIndex = activePath;
bus.$on("menu-change", (menu) => {
console.info(menu);
this.activeIndex = menu;
});
bus.$on('login', () => {
this.username = sessionStorage.getItem("nz-username");
this.refreshLang();
/*this.$nextTick(function(){
window.location.reload();
});*/
});
},
computed: {
projectListReloadWatch() {
@@ -441,7 +452,7 @@
},
getAssetDcData() {
return this.$store.state.assetData;
}
},
},
watch: {
getAssetDcData: {