fix: 处理config为空时的token刷新异常
This commit is contained in:
@@ -61,6 +61,8 @@ export interface DictItem {
|
|||||||
status: number;
|
status: number;
|
||||||
/** 排序 */
|
/** 排序 */
|
||||||
sort?: number;
|
sort?: number;
|
||||||
|
/** 标签类型(后端返回的原始码) */
|
||||||
|
tagType?: unknown;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 字典项表单对象 */
|
/** 字典项表单对象 */
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ http.interceptors.request.use(
|
|||||||
|
|
||||||
// 响应拦截器
|
// 响应拦截器
|
||||||
http.interceptors.response.use(
|
http.interceptors.response.use(
|
||||||
(response: AxiosResponse<ApiResponse>) => {
|
(response: AxiosResponse<ApiResponse>): any => {
|
||||||
const { responseType } = response.config;
|
const { responseType } = response.config;
|
||||||
|
|
||||||
// 二进制数据直接返回
|
// 二进制数据直接返回
|
||||||
@@ -64,8 +64,8 @@ http.interceptors.response.use(
|
|||||||
|
|
||||||
// Token 过期:尝试刷新 token 后自动重试一次
|
// Token 过期:尝试刷新 token 后自动重试一次
|
||||||
if (code === ApiCodeEnum.ACCESS_TOKEN_INVALID) {
|
if (code === ApiCodeEnum.ACCESS_TOKEN_INVALID) {
|
||||||
// 已重试过,直接跳登录
|
// config 不存在时无法重试,直接跳登录
|
||||||
if (retriedConfigs.has(config)) {
|
if (!config || retriedConfigs.has(config)) {
|
||||||
await redirectToLogin("登录已过期,请重新登录");
|
await redirectToLogin("登录已过期,请重新登录");
|
||||||
return Promise.reject(new Error("Token Invalid"));
|
return Promise.reject(new Error("Token Invalid"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user