mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(projects): 修复登录过期不弹窗问题
This commit is contained in:
@ -77,14 +77,15 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
|
||||
// when the backend response code is in `modalLogoutCodes`, it means the user will be logged out by displaying a modal
|
||||
const modalLogoutCodes = import.meta.env.VITE_SERVICE_MODAL_LOGOUT_CODES?.split(',') || [];
|
||||
if (modalLogoutCodes.includes(responseCode) && isLogin) {
|
||||
const isExist = request.state.errMsgStack.includes(response.data.msg);
|
||||
const isExist = request.state.errMsgStack && request.state.errMsgStack.includes(response.data.msg);
|
||||
if (isExist) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!window.location.pathname?.startsWith('/login')) {
|
||||
if (window.location.pathname?.startsWith('/login')) {
|
||||
logoutAndCleanup();
|
||||
return null;
|
||||
}
|
||||
request.state.errMsgStack = [...(request.state.errMsgStack || []), response.data.msg];
|
||||
|
||||
// prevent the user from refreshing the page
|
||||
window.addEventListener('beforeunload', handleLogout);
|
||||
|
||||
@ -106,9 +107,6 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
|
||||
request.cancelAllRequest();
|
||||
return null;
|
||||
}
|
||||
logoutAndCleanup();
|
||||
return null;
|
||||
}
|
||||
|
||||
// when the backend response code is in `expiredTokenCodes`, it means the token is expired, and refresh token
|
||||
// the api `refreshToken` can not return error code in `expiredTokenCodes`, otherwise it will be a dead loop, should return `logoutCodes` or `modalLogoutCodes`
|
||||
|
||||
Reference in New Issue
Block a user