fix(worker): 修复寄卖页分片加载失败导致的白屏
- 新增全局/页面级错误边界,页面渲染异常不再整页白屏 - 监听 vite:preloadError,部署后旧分片加载失败自动刷新一次 - 修复长会话 setTimeout 2^31 溢出导致立即登出 - 寄卖页资料接口失败给出重试态,不再误报未开通
This commit is contained in:
@@ -67,6 +67,11 @@ import {
|
||||
shouldPrependAdminWorkOrder,
|
||||
} from '@/utils/admin-realtime-work-orders'
|
||||
import { useRealtimeEvents, type RealtimeEvent } from '@/hooks/useRealtimeEvents'
|
||||
import {
|
||||
hasRemainingTimerDelay,
|
||||
MAX_TIMER_DELAY_MS,
|
||||
resolveTimerChunkDelay,
|
||||
} from '@/utils/session-expiry-timer'
|
||||
import dayjs from '@/lib/dayjs'
|
||||
|
||||
const SIDEBAR_COLLAPSED_KEY = 'react-admin-sidebar-collapsed'
|
||||
@@ -132,9 +137,21 @@ export default function AdminLayout() {
|
||||
useEffect(() => {
|
||||
const delay = getAdminSessionExpiryDelay(expiresAt)
|
||||
if (delay === null) return
|
||||
const timer = window.setTimeout(() => {
|
||||
expireAdminSession()
|
||||
}, delay)
|
||||
|
||||
// 同 WorkerLayout:超过 2^31-1 毫秒的延迟会溢出成立即触发,长会话必须分段等待。
|
||||
let remaining = delay
|
||||
let timer = 0
|
||||
const armTimer = () => {
|
||||
timer = window.setTimeout(() => {
|
||||
if (hasRemainingTimerDelay(remaining)) {
|
||||
remaining -= MAX_TIMER_DELAY_MS
|
||||
armTimer()
|
||||
return
|
||||
}
|
||||
expireAdminSession()
|
||||
}, resolveTimerChunkDelay(remaining))
|
||||
}
|
||||
armTimer()
|
||||
return () => window.clearTimeout(timer)
|
||||
}, [expiresAt])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user