修复冻结用户强制下线
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user