提交 55c10650 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

tab历史记录细节修复(刷新或重新登录的bug)

上级 510b750e
......@@ -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 = {}) {
......
......@@ -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))
}
}
}
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册