处理message提示
Some checks are pending
Check / lint (push) Waiting to run
Check / typecheck (push) Waiting to run
Check / build (build, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build, 18.x, windows-latest) (push) Waiting to run
Check / build (build:app, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:app, 18.x, windows-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Waiting to run

This commit is contained in:
wwt 2025-03-24 14:55:21 +08:00
parent ed2d6dfbd5
commit 47d5cab23a

View File

@ -40,7 +40,8 @@ const request = new Request({
},
responseInterceptors: async (res) => {
if(res.data.status===1){
message.warning(res.data.msg)
// message.warning(res.data.msg)
messageInstance.warning(res.data.msg)
}
if (res.data.status === 401) {
return getRefreshToken(res);
@ -49,11 +50,14 @@ const request = new Request({
// })
}
if ([200, 201, 204].includes(res.status)) {
if(res.data.code !== 200 && res.data.code!== 0) {
messageInstance.error(res.data.message || 'An error occurred.');
}
return res.config.responseType === 'blob' ? res : res;
} else {
/* message.error(res.data.msg || 'An error occurred.');*/
messageInstance.error(res.data.msg || 'An error occurred.');
return Promise.reject(new Error(res.data.msg || 'An error occurred.'));
messageInstance.error(res.data.message || 'An error occurred.');
return Promise.reject(new Error(res.data.message || 'An error occurred.'));
}
}
}
@ -76,6 +80,7 @@ async function getRefreshToken(response) {
})
return request.request(response.config);
} else {
messageInstance.error(res.message || res.msg);
throw new Error(res.message || res.msg);
}