修复冻结用户强制下线

This commit is contained in:
yml2213
2026-08-18 20:02:21 +08:00
parent 0bc6cf9f46
commit c91423a19b
16 changed files with 297 additions and 19 deletions
@@ -1,5 +1,6 @@
import { onBeforeUnmount, ref, type Ref } from 'vue'
import { refreshAccessToken } from '@/shared/api/client'
import axios from 'axios'
import { redirectToLogin, refreshAccessToken } from '@/shared/api/client'
import { getAccessToken, type AuthScope } from '@/shared/utils/authStorage'
export interface SSEMessage {
@@ -93,8 +94,11 @@ export function useChatSSE(scope: AuthScope, endpoint: string) {
if (!stopped) {
reconnectTimer = setTimeout(connect, reconnectDelay)
}
} catch {
} catch (error) {
closeSource()
if (axios.isAxiosError(error) && error.response?.status === 401) {
redirectToLogin(scope)
}
} finally {
refreshing = false
}
+1 -1
View File
@@ -174,7 +174,7 @@ function getRequestScope(url = ''): AuthScope {
return url.startsWith('/admin') ? 'admin' : 'user'
}
function redirectToLogin(scope: AuthScope) {
export function redirectToLogin(scope: AuthScope) {
clearAuthStorage(scope)
const currentPath = window.location.pathname + window.location.search
const loginPath = getLoginPath(scope, currentPath)