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);
|
||||
|
||||
interface InstanceState {
|
||||
/** whether the request is logout */
|
||||
isLogout: boolean;
|
||||
/** whether the request is refreshing token */
|
||||
isRefreshingToken: boolean;
|
||||
}
|
||||
@ -62,18 +64,24 @@ export const request = createFlatRequest<App.Service.Response, InstanceState>(
|
||||
// prevent the user from refreshing the page
|
||||
window.addEventListener('beforeunload', handleLogout);
|
||||
|
||||
// prevent repeated pop-ups
|
||||
if (!request.state.isLogout) {
|
||||
request.state.isLogout = true;
|
||||
window.$dialog?.error({
|
||||
title: 'Error',
|
||||
content: response.data.msg,
|
||||
positiveText: $t('common.confirm'),
|
||||
maskClosable: false,
|
||||
onPositiveClick() {
|
||||
request.state.isLogout = false;
|
||||
logoutAndCleanup();
|
||||
},
|
||||
onClose() {
|
||||
request.state.isLogout = false;
|
||||
logoutAndCleanup();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user