mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-23 23:39:47 +08:00
fix(projects): 修复登录过期事件监听未被重置
This commit is contained in:
@ -77,7 +77,7 @@ 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
|
// 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(',') || [];
|
const modalLogoutCodes = import.meta.env.VITE_SERVICE_MODAL_LOGOUT_CODES?.split(',') || [];
|
||||||
if (modalLogoutCodes.includes(responseCode) && isLogin) {
|
if (modalLogoutCodes.includes(responseCode) && isLogin) {
|
||||||
const isExist = request.state.errMsgStack && request.state.errMsgStack.includes(response.data.msg);
|
const isExist = request.state.errMsgStack?.includes(response.data.msg);
|
||||||
if (isExist) {
|
if (isExist) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -85,23 +85,24 @@ export const request = createFlatRequest<App.Service.Response, RequestInstanceSt
|
|||||||
logoutAndCleanup();
|
logoutAndCleanup();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
request.state.errMsgStack = [...(request.state.errMsgStack || []), response.data.msg];
|
request.state.errMsgStack = [...(request.state.errMsgStack || []), response.data.msg];
|
||||||
// prevent the user from refreshing the page
|
|
||||||
window.addEventListener('beforeunload', handleLogout);
|
|
||||||
|
|
||||||
window.$dialog?.warning({
|
window.$dialog?.warning({
|
||||||
title: '系统提示',
|
title: '系统提示',
|
||||||
content: '登录状态已过期,您可以继续留在该页面,或者重新登录',
|
content: '登录状态已过期,请重新登录',
|
||||||
positiveText: '重新登录',
|
positiveText: '重新登录',
|
||||||
negativeText: '取消',
|
|
||||||
maskClosable: false,
|
maskClosable: false,
|
||||||
closeOnEsc: false,
|
closeOnEsc: false,
|
||||||
|
onAfterEnter() {
|
||||||
|
// prevent the user from refreshing the page
|
||||||
|
window.addEventListener('beforeunload', handleLogout);
|
||||||
|
},
|
||||||
onPositiveClick() {
|
onPositiveClick() {
|
||||||
logoutAndCleanup();
|
logoutAndCleanup();
|
||||||
},
|
},
|
||||||
onClose() {
|
onClose() {
|
||||||
window.removeEventListener('beforeunload', handleLogout);
|
logoutAndCleanup();
|
||||||
request.state.errMsgStack = request.state.errMsgStack.filter(msg => msg !== response.data.msg);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
request.cancelAllRequest();
|
request.cancelAllRequest();
|
||||||
|
Reference in New Issue
Block a user