From 55c10650c069694440e393e6d6d3cc5aaab0d5b0 Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Fri, 3 Apr 2020 13:35:10 +0800 Subject: [PATCH] =?UTF-8?q?tab=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BF=AE=E5=A4=8D=EF=BC=88=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=88=96=E9=87=8D=E6=96=B0=E7=99=BB=E5=BD=95=E7=9A=84bug?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QMPlusVuePage/src/store/module/user.js | 1 + .../layout/aside/historyComponent/history.vue | 29 ++++++++++++++----- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/QMPlusVuePage/src/store/module/user.js b/QMPlusVuePage/src/store/module/user.js index 91ec3eba..3200d4a3 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 798bb766..0f800944 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)) } + } }