Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
c3fde1e875
@ -120,7 +120,7 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
||||
options.loading && closeLoading(options) // 关闭loading
|
||||
|
||||
if (response.config.responseType == 'json') {
|
||||
if (response.data && response.data.code == 401) {
|
||||
if (response.data && response.data.code != 200) {
|
||||
if (response.data.code == 409) {
|
||||
if (!window.tokenRefreshing) {
|
||||
window.tokenRefreshing = true
|
||||
@ -162,12 +162,12 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
||||
// router.push({ path: response.data.data.routePath ?? '', name: response.data.data.routeName ?? '' })
|
||||
// }
|
||||
|
||||
// if (response.data.code == 401) {
|
||||
let routerPath = adminBaseRoute.path
|
||||
adminInfo.removeToken()
|
||||
routerPath += '/login'
|
||||
router.push({ path: routerPath })
|
||||
// }
|
||||
if (response.data.code == 401) {
|
||||
let routerPath = adminBaseRoute.path
|
||||
adminInfo.removeToken()
|
||||
routerPath += '/login'
|
||||
router.push({ path: routerPath })
|
||||
}
|
||||
// code不等于1, 页面then内的具体逻辑就不执行了
|
||||
return Promise.reject(response.data)
|
||||
} else if (options.showSuccessMessage && response.data && response.data.code == 200) {
|
||||
@ -184,6 +184,12 @@ function createAxios<Data = any, T = ApiPromise<Data>>(axiosConfig: AxiosRequest
|
||||
error.config && removePending(error.config)
|
||||
options.loading && closeLoading(options) // 关闭loading
|
||||
options.showErrorMessage && httpErrorStatusHandle(error) // 处理错误状态码
|
||||
if (error.response.status == 401) {
|
||||
let routerPath = adminBaseRoute.path
|
||||
adminInfo.removeToken()
|
||||
routerPath += '/login'
|
||||
router.push({ path: routerPath })
|
||||
}
|
||||
return Promise.reject(error) // 错误继续返回给到具体页面
|
||||
}
|
||||
)
|
||||
@ -209,7 +215,7 @@ function httpErrorStatusHandle(error: any) {
|
||||
message = i18n.global.t('axios.Incorrect parameter!')
|
||||
break
|
||||
case 401:
|
||||
message = i18n.global.t('axios.You do not have permission to operate!')
|
||||
message = '用户登录信息过期,请重新登录!'
|
||||
break
|
||||
case 403:
|
||||
message = i18n.global.t('axios.You do not have permission to operate!')
|
||||
|
Loading…
Reference in New Issue
Block a user