Ajoute un rafraîchissement forcé de l'application

This commit is contained in:
2026-04-12 20:21:12 +02:00
parent b2b19f6e8b
commit 22a6fa02fd
5 changed files with 217 additions and 6 deletions

View File

@@ -18,7 +18,45 @@
<link rel="shortcut icon" href="/favicon.png" />
<link rel="apple-touch-icon" href="logo.png" />
<link rel="manifest" href="site.webmanifest" />
<link rel="stylesheet" href="styles.css" />
<script>
(() => {
const assetTokenStorageKey = "chesscubing-arena-asset-token";
const pageUrl = new URL(window.location.href);
const refreshToken = pageUrl.searchParams.get("refresh");
if (refreshToken) {
try {
window.sessionStorage.setItem(assetTokenStorageKey, refreshToken);
} catch {
// Ignore storage failures in restricted browsers.
}
pageUrl.searchParams.delete("refresh");
window.history.replaceState(null, "", pageUrl.toString());
}
let assetToken = "";
try {
assetToken = window.sessionStorage.getItem(assetTokenStorageKey) || "";
} catch {
assetToken = "";
}
window.__CHESSCUBING_ASSET_TOKEN__ = assetToken;
window.__CHESSCUBING_ASSET_URL__ = (path) => {
if (!assetToken) {
return path;
}
const assetUrl = new URL(path, window.location.href);
assetUrl.searchParams.set("v", assetToken);
return `${assetUrl.pathname}${assetUrl.search}${assetUrl.hash}`;
};
const stylesheet = document.createElement("link");
stylesheet.rel = "stylesheet";
stylesheet.href = window.__CHESSCUBING_ASSET_URL__("styles.css");
document.head.append(stylesheet);
})();
</script>
</head>
<body data-page="chrono" class="phase-body">
<main class="phase-shell chrono-stage">
@@ -151,6 +189,11 @@
</div>
</section>
<script type="module" src="app.js"></script>
<script>
const appScript = document.createElement("script");
appScript.type = "module";
appScript.src = window.__CHESSCUBING_ASSET_URL__("app.js");
document.body.append(appScript);
</script>
</body>
</html>