Browse Source

Revert "token超时处理"

This reverts commit 8ebf83f2214543097ca752242db911eb9706cfcf.
daxiongYang 7 years ago
parent
commit
949e76ef8a
2 changed files with 5 additions and 4 deletions
  1. 3 3
      src/api/request.js
  2. 2 1
      src/views/layout/index.vue

+ 3 - 3
src/api/request.js

16
  config.headers['token'] = Vue.cookie.get('token')
16
  config.headers['token'] = Vue.cookie.get('token')
17
  return config
17
  return config
18
}, error => {
18
}, error => {
19
  Promise.reject(error)
19
  return Promise.reject(error)
20
})
20
})
21
21
22
// response拦截器
22
// response拦截器
23
service.interceptors.response.use(response => {
23
service.interceptors.response.use(response => {
24
  if (response.data && response.data.code === 401) { // 401, token失效
24
  if (response.data && response.data.code === 401) { // 401, token失效
25
    Vue.cookie.delete('token')
25
    router.push({ name: 'login' })
26
    router.push({ name: 'login' })
26
  }
27
  }
27
  return response
28
  return response
28
},
29
error => {
29
}, error => {
30
  return Promise.reject(error)
30
  return Promise.reject(error)
31
})
31
})
32
32

+ 2 - 1
src/views/layout/index.vue

61
        API.user.info().then(({data}) => {
61
        API.user.info().then(({data}) => {
62
          if (data && data.code === 0) {
62
          if (data && data.code === 0) {
63
            this.loading = false
63
            this.loading = false
64
            this.DELETE_CONTENT_TABS([])
64
            this.UPDATE_USER_ID({ id: data.user.userId })
65
            this.UPDATE_USER_ID({ id: data.user.userId })
65
            this.UPDATE_USER_NAME({ name: data.user.username })
66
            this.UPDATE_USER_NAME({ name: data.user.username })
66
          }
67
          }
67
        })
68
        })
68
      },
69
      },
69
      ...mapMutations(['UPDATE_DOCUMENT_CLIENT_HEIGHT', 'UPDATE_USER_ID', 'UPDATE_USER_NAME'])
70
      ...mapMutations(['UPDATE_DOCUMENT_CLIENT_HEIGHT', 'UPDATE_USER_ID', 'UPDATE_USER_NAME', 'DELETE_CONTENT_TABS'])
70
    }
71
    }
71
  }
72
  }
72
</script>
73
</script>