|
|
@@ -63,7 +63,9 @@ export default function createRequestClient(options?: SimpleAlovaOptions) {
|
|
|
if (response.status > 400) {
|
|
|
const message = response.statusText;
|
|
|
// eslint-disable-next-line no-throw-literal
|
|
|
- throw { message };
|
|
|
+ throw response.status === 401
|
|
|
+ ? { code: 401, message: message || 'Unauthorized' }
|
|
|
+ : { message };
|
|
|
}
|
|
|
|
|
|
/* prettier-ignore */
|
|
|
@@ -102,12 +104,11 @@ export default function createRequestClient(options?: SimpleAlovaOptions) {
|
|
|
tokenAuthentication: createServerTokenAuthentication({
|
|
|
refreshTokenOnSuccess: {
|
|
|
async isExpired(response) {
|
|
|
- return response.status === 401;
|
|
|
+ // 无 refreshToken 时不走刷新逻辑,避免 401 被反复重试
|
|
|
+ return response.status === 401 && !!store.refreshToken;
|
|
|
},
|
|
|
async handler(response) {
|
|
|
- if (store.refreshToken) {
|
|
|
- console.log(response);
|
|
|
- }
|
|
|
+ console.log(response);
|
|
|
},
|
|
|
metaMatches: {
|
|
|
authRole: 'refreshToken',
|