diff --git a/src/service/request/index.ts b/src/service/request/index.ts index 88ae1b91..12ce410c 100644 --- a/src/service/request/index.ts +++ b/src/service/request/index.ts @@ -77,36 +77,34 @@ export const request = createFlatRequest msg !== response.data.msg); - } - }); - request.cancelAllRequest(); + if (window.location.pathname?.startsWith('/login')) { + logoutAndCleanup(); return null; } - logoutAndCleanup(); + request.state.errMsgStack = [...(request.state.errMsgStack || []), response.data.msg]; + // prevent the user from refreshing the page + window.addEventListener('beforeunload', handleLogout); + + window.$dialog?.warning({ + title: '系统提示', + content: '登录状态已过期,您可以继续留在该页面,或者重新登录', + positiveText: '重新登录', + negativeText: '取消', + maskClosable: false, + closeOnEsc: false, + onPositiveClick() { + logoutAndCleanup(); + }, + onClose() { + window.removeEventListener('beforeunload', handleLogout); + request.state.errMsgStack = request.state.errMsgStack.filter(msg => msg !== response.data.msg); + } + }); + request.cancelAllRequest(); return null; } diff --git a/src/views/monitor/online/modules/online-search.vue b/src/views/monitor/online/modules/online-search.vue index 4cbedac1..de013ef3 100644 --- a/src/views/monitor/online/modules/online-search.vue +++ b/src/views/monitor/online/modules/online-search.vue @@ -34,13 +34,13 @@ async function search() { - + - + - +