mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-29 22:56:41 +08:00
feat(projects): Prevent repeated pop-ups after login expiration
This commit is contained in:
parent
1a7070f02b
commit
6eb0ab4235
@ -10,6 +10,8 @@ const isHttpProxy = import.meta.env.DEV && import.meta.env.VITE_HTTP_PROXY === '
|
|||||||
const { baseURL, otherBaseURL } = getServiceBaseURL(import.meta.env, isHttpProxy);
|
const { baseURL, otherBaseURL } = getServiceBaseURL(import.meta.env, isHttpProxy);
|
||||||
|
|
||||||
interface InstanceState {
|
interface InstanceState {
|
||||||
|
/** whether the request is logout */
|
||||||
|
isLogout: boolean;
|
||||||
/** whether the request is refreshing token */
|
/** whether the request is refreshing token */
|
||||||
isRefreshingToken: boolean;
|
isRefreshingToken: boolean;
|
||||||
}
|
}
|
||||||
@ -62,18 +64,24 @@ export const request = createFlatRequest<App.Service.Response, InstanceState>(
|
|||||||
// prevent the user from refreshing the page
|
// prevent the user from refreshing the page
|
||||||
window.addEventListener('beforeunload', handleLogout);
|
window.addEventListener('beforeunload', handleLogout);
|
||||||
|
|
||||||
window.$dialog?.error({
|
// prevent repeated pop-ups
|
||||||
title: 'Error',
|
if (!request.state.isLogout) {
|
||||||
content: response.data.msg,
|
request.state.isLogout = true;
|
||||||
positiveText: $t('common.confirm'),
|
window.$dialog?.error({
|
||||||
maskClosable: false,
|
title: 'Error',
|
||||||
onPositiveClick() {
|
content: response.data.msg,
|
||||||
logoutAndCleanup();
|
positiveText: $t('common.confirm'),
|
||||||
},
|
maskClosable: false,
|
||||||
onClose() {
|
onPositiveClick() {
|
||||||
logoutAndCleanup();
|
request.state.isLogout = false;
|
||||||
}
|
logoutAndCleanup();
|
||||||
});
|
},
|
||||||
|
onClose() {
|
||||||
|
request.state.isLogout = false;
|
||||||
|
logoutAndCleanup();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user