fix: fix PWA

This commit is contained in:
2026-05-18 14:21:32 +02:00
parent c175da58dc
commit 4f53aefb6e
2 changed files with 13 additions and 0 deletions

View File

@ -7,8 +7,16 @@
<meta name="theme-color" content="#0f172a" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<link rel="manifest" href="/manifest.webmanifest" />
%sveltekit.head%
<script src="/registerSW.js"></script>
<script>
window.__installPrompt = null;
window.addEventListener('beforeinstallprompt', function(e) {
e.preventDefault();
window.__installPrompt = e;
});
</script>
</head>
<body data-sveltekit-preload-data="hover" class="bg-slate-900 text-slate-100">
<div style="display: contents">%sveltekit.body%</div>

View File

@ -123,6 +123,11 @@
if (evt.type === "containers.updated") load();
if (evt.type === "agent.connected" || evt.type === "agent.disconnected") load();
});
// Récupère le prompt capturé tôt dans app.html avant que onMount soit prêt
if ((window as any).__installPrompt) {
installPrompt = (window as any).__installPrompt;
(window as any).__installPrompt = null;
}
window.addEventListener("beforeinstallprompt", onBeforeInstallPrompt);
window.addEventListener("appinstalled", onAppInstalled);
});