chore: refreshToken

pull/48/MERGE
xingyu 2024-11-17 00:46:29 +08:00
parent f6d9d1baa8
commit 30f9f11bb7
2 changed files with 11 additions and 12 deletions

View File

@ -89,22 +89,21 @@ function createRequestClient(baseURL: string) {
return responseData;
}
// const { isReturnNativeResponse, isTransformResponse } = config;
// // 是否返回原生响应头 比如:需要获取响应头时使用该属性
// if (isReturnNativeResponse) {
// return response;
// }
// // 不进行任何处理,直接返回,用于页面代码可能需要直接获取codedatamessage这些信息时开启
// if (!isTransformResponse) {
// return response.data;
// }
const { code, data: result } = responseData;
if (responseData && Reflect.has(responseData, 'code') && code === 0) {
return result;
}
throw Object.assign({}, response, { response });
switch (code) {
case 401: {
response.status = 401;
throw Object.assign({}, response, { response });
}
default: {
response.status = code;
throw Object.assign({}, response, { response });
}
}
},
});

View File

@ -11,6 +11,6 @@ export const overridesPreferences = defineOverridesPreferences({
/** 后端路由模式 */
accessMode: 'backend',
name: import.meta.env.VITE_APP_TITLE,
enableRefreshToken: false,
enableRefreshToken: true,
},
});