Commit c345fdcd authored by jingnan's avatar jingnan 👀

同一账号连续登录时缓存历史页签数据

parent 0eb7a711
...@@ -166,6 +166,8 @@ const actions = { ...@@ -166,6 +166,8 @@ const actions = {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
// resetRouter() 考虑退出后 重新登录 不清路由 // resetRouter() 考虑退出后 重新登录 不清路由
logout({ token: localStorage.getItem('token') }, !!flag).then(response => { logout({ token: localStorage.getItem('token') }, !!flag).then(response => {
// 将当前登录用户的id保存到本地,下次登录时,判断是否为同一个用户,如果不是,则不用缓存历史页签
localStorage.setItem('previousUserId', localStorage.getItem('userId'))
removeToken() removeToken()
commit('SET_TOKEN', '') commit('SET_TOKEN', '')
console.log('退出成功') console.log('退出成功')
......
...@@ -194,7 +194,12 @@ export default { ...@@ -194,7 +194,12 @@ export default {
} else { } else {
localStorage.removeItem('loginInfo') localStorage.removeItem('loginInfo')
} }
this.$store.dispatch('tagsView/delAllVisitedViews', params) // 判断上次登录用户与此次是否一致,不一致则清除上次历史页签
const previousUserId = localStorage.getItem('previousUserId')
const userId = localStorage.getItem('userId')
if (previousUserId && previousUserId !== userId) {
this.$store.dispatch('tagsView/delAllVisitedViews', params)
}
this.$store.dispatch('tagsView/delAllCachedViews', params) this.$store.dispatch('tagsView/delAllCachedViews', params)
this.$store.dispatch('permission/clearPermissionList') this.$store.dispatch('permission/clearPermissionList')
// this.$router.push({ path: this.redirect || '/' }) // this.$router.push({ path: this.redirect || '/' })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment