From 30ab96442fae4d2b4a521c0fdf16b0dcfe6e2a33 Mon Sep 17 00:00:00 2001 From: ru44 <18311071+ru44@users.noreply.github.com> Date: Thu, 29 Oct 2026 11:18:26 +0300 Subject: [PATCH] =?UTF-8?q?=D8=A5=D8=B5=D9=84=D8=A7=D8=AD:=20=D8=A7=D9=84?= =?UTF-8?q?=D8=B1=D9=88=D8=A7=D8=A8=D8=B7=20=D9=84=D8=A7=20=D8=AA=D8=B3?= =?UTF-8?q?=D8=AA=D8=AC=D9=8A=D8=A8=20=D8=A8=D8=B9=D8=AF=20=D9=83=D9=84=20?= =?UTF-8?q?=D9=86=D8=B4=D8=B1.=20=D9=83=D9=84=20=D9=86=D8=B4=D8=B1=20?= =?UTF-8?q?=D9=8A=D8=BA=D9=8A=D9=91=D8=B1=20=D8=A3=D8=B3=D9=85=D8=A7=D8=A1?= =?UTF-8?q?=20=D9=85=D9=84=D9=81=D8=A7=D8=AA=20=D8=A7=D9=84=D8=B5=D9=81?= =?UTF-8?q?=D8=AD=D8=A7=D8=AA=D8=8C=20=D9=81=D8=A7=D9=84=D8=AA=D8=A8=D9=88?= =?UTF-8?q?=D9=8A=D8=A8=20=D8=A7=D9=84=D8=B0=D9=8A=20=D9=85=D8=A7=20=D8=B2?= =?UTF-8?q?=D8=A7=D9=84=20=D9=8A=D8=AD=D9=85=D9=84=20index.html=20=D8=A7?= =?UTF-8?q?=D9=84=D9=82=D8=AF=D9=8A=D9=85=20(=D9=81=D9=8F=D8=AA=D8=AD=20?= =?UTF-8?q?=D9=82=D8=A8=D9=84=20=D8=A7=D9=84=D9=86=D8=B4=D8=B1=D8=8C=20?= =?UTF-8?q?=D8=A3=D9=88=20=D8=AC=D8=A7=D8=A1=20=D9=85=D9=86=20=D8=B0=D8=A7?= =?UTF-8?q?=D9=83=D8=B1=D8=A9=20GitHub=20Pages=20=D9=84=D8=B9=D8=B4=D8=B1?= =?UTF-8?q?=20=D8=AF=D9=82=D8=A7=D8=A6=D9=82)=20=D9=8A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MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/main.ts b/src/main.ts index 31b81ae9..466d3b95 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,6 +7,25 @@ import { router } from './router' createApp(App).use(createPinia()).use(router).mount('#app') +// Every deploy renames the hashed chunks. A tab that still holds the previous index.html (opened before +// the deploy, or served from the 10-minute GitHub Pages cache) then asks for files that no longer exist, +// and every link seems dead. Reload once onto the new build; the guard stops a loop if the reload still +// lands on the old page. +const STALE_CHUNK = /dynamically imported module|Importing a module script failed|Failed to fetch/ +function reloadForNewBuild() { + const last = Number(sessionStorage.getItem('viz-reload') ?? 0) + if (Date.now() - last < 30_000) return + sessionStorage.setItem('viz-reload', String(Date.now())) + location.reload() +} +window.addEventListener('vite:preloadError', (e) => { + e.preventDefault() + reloadForNewBuild() +}) +router.onError((err) => { + if (STALE_CHUNK.test(String((err as Error)?.message))) reloadForNewBuild() +}) + // Offline support: register the service worker in production builds only. if ('serviceWorker' in navigator && import.meta.env.PROD) { window.addEventListener('load', () => navigator.serviceWorker.register('sw.js').catch(() => {}))