mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-10-01 11:47:46 +02:00
+22
-10
@@ -28,18 +28,30 @@
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
|
||||
<!-- Service Worker Registration -->
|
||||
<!-- Service Worker Registration (skip on SpoolBuddy kiosk) -->
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js')
|
||||
.then((registration) => {
|
||||
console.log('SW registered:', registration.scope);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('SW registration failed:', error);
|
||||
});
|
||||
});
|
||||
if (location.pathname.startsWith('/spoolbuddy')) {
|
||||
// Kiosk mode — nuke SW and all caches, then reload once to get clean state
|
||||
navigator.serviceWorker.getRegistrations().then((regs) => {
|
||||
if (regs.length > 0) {
|
||||
Promise.all([
|
||||
...regs.map((r) => r.unregister()),
|
||||
caches.keys().then((names) => Promise.all(names.map((n) => caches.delete(n)))),
|
||||
]).then(() => location.reload());
|
||||
}
|
||||
});
|
||||
} else {
|
||||
window.addEventListener('load', () => {
|
||||
navigator.serviceWorker.register('/sw.js')
|
||||
.then((registration) => {
|
||||
console.log('SW registered:', registration.scope);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log('SW registration failed:', error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user