This commit is contained in:
parent
c5cca78b1c
commit
551fe07d0e
4 changed files with 21 additions and 9 deletions
|
@ -1,8 +1,23 @@
|
||||||
<script>
|
<script>
|
||||||
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
|
import BottomAppBar from '$lib/components/BottomAppBar.svelte';
|
||||||
|
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
addEventListener('load', function () {
|
||||||
|
navigator.serviceWorker.register('../sw.ts');
|
||||||
|
});
|
||||||
|
|
||||||
|
navigator.serviceWorker.addEventListener('message', (event) => {
|
||||||
|
console.log(`The service worker sent me a message: ${event.data}`);
|
||||||
|
alert("You can use the app offline");
|
||||||
|
});
|
||||||
|
|
||||||
|
navigator.serviceWorker.ready.then((registration) => {
|
||||||
|
console.log("registered service worker")
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<slot></slot>
|
<slot />
|
||||||
<footer>
|
<footer>
|
||||||
<BottomAppBar />
|
<BottomAppBar />
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
@ -2,13 +2,6 @@
|
||||||
import Header from '$lib/components/Header.svelte';
|
import Header from '$lib/components/Header.svelte';
|
||||||
import Tabs from '$lib/components/Tabs.svelte';
|
import Tabs from '$lib/components/Tabs.svelte';
|
||||||
import MapTab from '$lib/components/tabs/MapTab.svelte';
|
import MapTab from '$lib/components/tabs/MapTab.svelte';
|
||||||
import { onMount } from 'svelte';
|
|
||||||
|
|
||||||
let syncWorker: Worker | undefined = undefined;
|
|
||||||
|
|
||||||
let latitude;
|
|
||||||
let longitude;
|
|
||||||
let accuracy;
|
|
||||||
|
|
||||||
export let data;
|
export let data;
|
||||||
let divider;
|
let divider;
|
||||||
|
|
|
@ -32,6 +32,7 @@ self.addEventListener('activate', (event) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
event.waitUntil(deleteOldCaches());
|
event.waitUntil(deleteOldCaches());
|
||||||
|
postMessage("completed");
|
||||||
});
|
});
|
||||||
|
|
||||||
self.addEventListener('fetch', (event) => {
|
self.addEventListener('fetch', (event) => {
|
||||||
|
|
|
@ -8,6 +8,9 @@ const config = {
|
||||||
files: {
|
files: {
|
||||||
serviceWorker: 'src/sw.ts',
|
serviceWorker: 'src/sw.ts',
|
||||||
},
|
},
|
||||||
|
serviceWorker: {
|
||||||
|
register: false,
|
||||||
|
},
|
||||||
adapter: adapter({
|
adapter: adapter({
|
||||||
fallback: null,
|
fallback: null,
|
||||||
precompress: true,
|
precompress: true,
|
||||||
|
|
Loading…
Reference in a new issue