Фикс ошибок

This commit is contained in:
2026-08-01 03:39:07 -07:00
parent bff945e701
commit 12f6384856
5 changed files with 114 additions and 22 deletions

View File

@@ -2,6 +2,42 @@ import { createRoot } from 'react-dom/client'
import { BrowserRouter } from 'react-router-dom'
import App from './App.tsx'
const PRELOAD_RELOAD_KEY = 'rosetta:preload-reload-at'
const PRELOAD_RELOAD_COOLDOWN = 10_000
if (import.meta.env.PROD) {
window.addEventListener('vite:preloadError', (event) => {
let lastReload = 0
try {
lastReload = Number(window.sessionStorage.getItem(PRELOAD_RELOAD_KEY) || 0)
} catch {
// Storage can be unavailable in restricted browser modes.
}
if (Date.now() - lastReload < PRELOAD_RELOAD_COOLDOWN) {
return
}
event.preventDefault()
try {
window.sessionStorage.setItem(PRELOAD_RELOAD_KEY, String(Date.now()))
} catch {
// Reload recovery still works when storage is unavailable.
}
window.location.reload()
})
window.setTimeout(() => {
try {
window.sessionStorage.removeItem(PRELOAD_RELOAD_KEY)
} catch {
// Nothing to clear when storage is unavailable.
}
}, PRELOAD_RELOAD_COOLDOWN)
}
createRoot(document.getElementById('root')!).render(
<BrowserRouter>