mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-09 06:35:03 +03:00
fix: recover panel navigation after stale chunk failures (#6679)
Fixes #6673 Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,32 @@ import { ThemeProvider } from '@/hooks/useTheme';
|
||||
import { QueryProvider } from '@/api/QueryProvider';
|
||||
import { router } from '@/routes';
|
||||
|
||||
// A stale tab keeps this entry's old chunk URLs after a deploy. Reload once per
|
||||
// panel base path and entry URL; the same bundle must not loop on a real outage.
|
||||
const chunkRecoveryKey = `xui:chunk-recovery:${window.X_UI_BASE_PATH || '/'}:${import.meta.url}`;
|
||||
let chunkRecoveryCommitted = false;
|
||||
|
||||
window.addEventListener('vite:preloadError', (event) => {
|
||||
if (chunkRecoveryCommitted) return;
|
||||
chunkRecoveryCommitted = true;
|
||||
let shouldReload = false;
|
||||
try {
|
||||
if (sessionStorage.getItem(chunkRecoveryKey) == null) {
|
||||
sessionStorage.setItem(chunkRecoveryKey, '1');
|
||||
shouldReload = true;
|
||||
}
|
||||
} catch {
|
||||
chunkRecoveryCommitted = false;
|
||||
return;
|
||||
}
|
||||
if (!shouldReload) {
|
||||
chunkRecoveryCommitted = false;
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
location.reload();
|
||||
});
|
||||
|
||||
setupHttp();
|
||||
|
||||
const messageContainer = document.getElementById('message');
|
||||
|
||||
Reference in New Issue
Block a user