style:token设置
Showing
1 changed file
with
3 additions
and
3 deletions
1 | /* | 1 | /* |
2 | * @Description: 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器 | 2 | * @Description: 此文件主要创建 axios 实例,然后添加请求拦截器和响应拦截器 |
3 | * @Autor: renchao | 3 | * @Autor: renchao |
4 | * @LastEditTime: 2023-05-31 15:30:02 | 4 | * @LastEditTime: 2023-06-01 09:20:24 |
5 | */ | 5 | */ |
6 | import axios from 'axios' | 6 | import axios from 'axios' |
7 | import { Message } from 'element-ui' | 7 | import { Message } from 'element-ui' |
... | @@ -38,7 +38,7 @@ service.interceptors.request.use( | ... | @@ -38,7 +38,7 @@ service.interceptors.request.use( |
38 | return Promise.reject(error); | 38 | return Promise.reject(error); |
39 | } | 39 | } |
40 | ) | 40 | ) |
41 | 41 | window.__isNeedLogin = true | |
42 | // response interceptor | 42 | // response interceptor |
43 | service.interceptors.response.use( | 43 | service.interceptors.response.use( |
44 | response => { | 44 | response => { |
... | @@ -60,7 +60,7 @@ service.interceptors.response.use( | ... | @@ -60,7 +60,7 @@ service.interceptors.response.use( |
60 | //todo: 需要解决 一个页面多个请求,刷新后此处会触发多次 | 60 | //todo: 需要解决 一个页面多个请求,刷新后此处会触发多次 |
61 | if (window.__isNeedLogin) { | 61 | if (window.__isNeedLogin) { |
62 | window.__isNeedLogin = false | 62 | window.__isNeedLogin = false |
63 | this.$message.error('token失效,请重新登录'); | 63 | Message.error('token失效,请重新登录'); |
64 | let locationUrl = window.location.protocol + '//' + window.location.host + window.location.pathname; | 64 | let locationUrl = window.location.protocol + '//' + window.location.host + window.location.pathname; |
65 | localStorage.removeItem('token') | 65 | localStorage.removeItem('token') |
66 | if (window._config.casEnable) { | 66 | if (window._config.casEnable) { | ... | ... |
-
Please register or sign in to post a comment