修改token超时后判断
This commit is contained in:
@@ -64,7 +64,6 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
|
||||
if (
|
||||
!(
|
||||
config.url == '/system-boot/file/upload' ||
|
||||
|
||||
config.url == '/harmonic-boot/grid/getAssessOverview' ||
|
||||
config.url == '/system-boot/file/getFileVO' ||
|
||||
config.url == '/harmonic-boot/gridDiagram/getGridDiagramAreaData'
|
||||
@@ -89,6 +88,9 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
|
||||
config.headers.Authorization = 'Basic bmpjbnRlc3Q6bmpjbnBxcw=='
|
||||
}
|
||||
}
|
||||
if (config.url == '/user-boot/user/generateSm2Key' || config.url == '/pqs-auth/oauth/token') {
|
||||
config.headers.Authorization = 'Basic bmpjbnRlc3Q6bmpjbnBxcw=='
|
||||
}
|
||||
|
||||
return config
|
||||
},
|
||||
@@ -120,12 +122,13 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
|
||||
} else if (response.data.code == 'A0202') {
|
||||
if (!window.tokenRefreshing) {
|
||||
window.tokenRefreshing = true
|
||||
|
||||
return refreshToken()
|
||||
.then(res => {
|
||||
adminInfo.setToken(res.data.token, 'auth')
|
||||
response.headers.Authorization = `${res.data.token}`
|
||||
window.requests.forEach(cb => cb(res.data.token))
|
||||
adminInfo.setToken(res.data.access_token, 'auth')
|
||||
window.requests.forEach(cb => cb(res.data.access_token))
|
||||
window.requests = []
|
||||
|
||||
return Axios(response.config)
|
||||
})
|
||||
.catch(err => {
|
||||
@@ -147,10 +150,10 @@ function createAxios<Data = any, T = ApiPromise<Data>>(
|
||||
}
|
||||
} else if (response.data.code == 'A0024') {
|
||||
// // 登录失效
|
||||
// ElNotification({
|
||||
// type: 'error',
|
||||
// message: response.data.message
|
||||
// })
|
||||
ElNotification({
|
||||
type: 'error',
|
||||
message: response.data.message
|
||||
})
|
||||
adminInfo.removeToken()
|
||||
router.push({ name: 'login' })
|
||||
return Promise.reject(response.data)
|
||||
|
||||
Reference in New Issue
Block a user