diff --git a/QMPlusVuePage/src/store/module/user.js b/QMPlusVuePage/src/store/module/user.js index 91ec3eba621058c26b0041dd87ab63f4bd3aa504..3200d4a31d988eabf5a90474d82a9382925abdf6 100644 --- a/QMPlusVuePage/src/store/module/user.js +++ b/QMPlusVuePage/src/store/module/user.js @@ -31,6 +31,7 @@ export const user = { state.token = "" state.expiresAt = "" router.push({ name: 'login', replace: true }) + sessionStorage.clear() window.location.reload() }, ResetUserInfo(state, userInfo = {}) { diff --git a/QMPlusVuePage/src/view/layout/aside/historyComponent/history.vue b/QMPlusVuePage/src/view/layout/aside/historyComponent/history.vue index 798bb7665f9582d0888b9efa1085a7c43fd5273a..0f80094449e61cb5e9651a0d8d01c0510d1fe60b 100644 --- a/QMPlusVuePage/src/view/layout/aside/historyComponent/history.vue +++ b/QMPlusVuePage/src/view/layout/aside/historyComponent/history.vue @@ -16,18 +16,32 @@ export default { name:"HistoryComponent", data(){ return{ - historys:[ + historys:[], + activeValue:"dashbord" + } + }, + created(){ + const initHistorys = [ { name:"dashbord", meta:{ title:"仪表盘" } } - ], - activeValue:"dashbord" - } + ] + this.historys = JSON.parse(sessionStorage.getItem("historys")) || initHistorys + this.setTab(this.$route) }, methods:{ + setTab(route){ + if(!this.historys.some(item=>item.name==route.name)){ + const obj = {} + obj.name = route.name + obj.meta = route.meta + this.historys.push(obj) + } + this.activeValue = this.$route.name + }, changeTab(tab){ this.$router.push({name:tab.name}) }, @@ -50,11 +64,10 @@ export default { watch:{ $route( to ){ this.historys = this.historys.filter(item=>!item.meta.hidden) - if(!this.historys.some(item=>item.name==to.name)){ - this.historys.push(to) - } - this.activeValue = to.name + this.setTab(to) + sessionStorage.setItem("historys",JSON.stringify(this.historys)) } + } }