修复:部署无法到达已打开的页面(新增构建版本标记 + 陈旧页面自动重载) (#39)

This commit is contained in:
shanzhaikabi authored and GitHub committed 2026-10-04 14:19:53 +08:00
1 parent 9d404199df
commit e90e7a30fc
8 files changed
+450 -10

No files matched your search

+13
View File
@@ -45,6 +45,7 @@ import { GuideHost } from './ui/guide.js';
import { installDeviceSupport } from './ui/device.js';
import { LoadoutHost } from './screens/loadout.js';
import { installLoadoutSync } from './ui/loadoutSync.js';
import { startBuildGuard } from './ui/buildGuard.js';
const RESTORE_GRACE_MS = 1500;
const JOIN_DELAY_MS = 350;
@@ -351,6 +352,18 @@ async function boot() {
setTimeout(() => splash.remove(), 300);
}
globalThis.__SP__ = { store, net, data, version: 1 };
// A page keeps the modules it imported at load time for its whole lifetime, so a deploy cannot reach an open tab
// (ui/buildGuard.js): watch `/healthz.build`. Outside a match the page reloads itself; during a match the guard says
// so instead (the connection banner offers 刷新页面) and reloads once the match — settlement screen included — is over,
// so a running game is never thrown away.
try {
startBuildGuard({
inMatch: () => selectRoute(store.get()) === 'game',
onStale: ({ waiting }) => { if (waiting) store.patch('ui', { buildStale: true }); },
});
} catch (err) {
console.warn('[app] build guard failed to start', err);
}
}
boot().catch((err) => {