SSE鉴权失效停止重连清理会话跳登录并降噪4xx错误日志

This commit is contained in:
yml2213
2026-08-23 11:01:41 +08:00
parent 8e49b7d047
commit 70b31f4874
4 changed files with 32 additions and 9 deletions
+6 -6
View File
@@ -87,6 +87,11 @@ export default function AdminLayout() {
url: '/api/v1/admin/realtime',
token: getAdminToken(),
onEvent: (event) => applyAdminRealtimeEvent(event, queryClient),
// 会话过期时清登录态回登录页,避免 SSE 带着失效 token 无限重连刷 401。
onAuthExpired: () => {
clearAdminSession()
void navigate('/admin/login', { replace: true, state: { from: location } })
},
})
const menuItems = useMemo<MenuProps['items']>(() => {
@@ -541,12 +546,7 @@ function isRecord(value: unknown): value is Record<string, unknown> {
}
type NotificationAlertKind =
| 'withdraw'
| 'recharge'
| 'acceptance'
| 'material'
| 'reminder'
| 'default'
'withdraw' | 'recharge' | 'acceptance' | 'material' | 'reminder' | 'default'
function playNotificationSound(kind: NotificationAlertKind) {
try {