This commit is contained in:
parent
551fe07d0e
commit
3cd8752fe1
1 changed files with 15 additions and 12 deletions
|
@ -1,6 +1,8 @@
|
||||||
<script>
|
<script>
|
||||||
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
|
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
|
||||||
|
import { onMount } from 'svelte';
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
if ('serviceWorker' in navigator) {
|
if ('serviceWorker' in navigator) {
|
||||||
addEventListener('load', function () {
|
addEventListener('load', function () {
|
||||||
navigator.serviceWorker.register('../sw.ts');
|
navigator.serviceWorker.register('../sw.ts');
|
||||||
|
@ -8,13 +10,14 @@
|
||||||
|
|
||||||
navigator.serviceWorker.addEventListener('message', (event) => {
|
navigator.serviceWorker.addEventListener('message', (event) => {
|
||||||
console.log(`The service worker sent me a message: ${event.data}`);
|
console.log(`The service worker sent me a message: ${event.data}`);
|
||||||
alert("You can use the app offline");
|
alert('You can use the app offline');
|
||||||
});
|
});
|
||||||
|
|
||||||
navigator.serviceWorker.ready.then((registration) => {
|
navigator.serviceWorker.ready.then((registration) => {
|
||||||
console.log("registered service worker")
|
console.log('registered service worker');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
|
|
Loading…
Reference in a new issue