Browse Source

修复退出/token失效后,返回登录页面未清空整站临时存储数据bug

daxiongYang 7 years ago
parent
commit
b3f96f54f1
2 changed files with 6 additions and 3 deletions
  1. 3 1
      src/utils/httpRequest.js
  2. 3 2
      src/views/main-navbar.vue

+ 3 - 1
src/utils/httpRequest.js

28
http.interceptors.response.use(response => {
28
http.interceptors.response.use(response => {
29
  if (response.data && response.data.code === 401) { // 401, token失效
29
  if (response.data && response.data.code === 401) { // 401, token失效
30
    Vue.cookie.delete('token')
30
    Vue.cookie.delete('token')
31
    router.push({ name: 'login' })
31
    router.push({ name: 'login' }, () => {
32
      location.reload() // 刷新页面, 清空整站临时存储数据
33
    })
32
  }
34
  }
33
  return response
35
  return response
34
}, error => {
36
}, error => {

+ 3 - 2
src/views/main-navbar.vue

101
            data: this.$http.adornData()
101
            data: this.$http.adornData()
102
          }).then(({data}) => {
102
          }).then(({data}) => {
103
            if (data && data.code === 0) {
103
            if (data && data.code === 0) {
104
              this.mainTabs = []
105
              this.$cookie.delete('token')
104
              this.$cookie.delete('token')
106
              this.$router.replace({ name: 'login' })
105
              this.$router.push({ name: 'login' }, () => {
106
                location.reload() // 刷新页面, 清空整站临时存储数据
107
              })
107
            }
108
            }
108
          })
109
          })
109
        }).catch(() => {})
110
        }).catch(() => {})