move serviceworker registration to separate module
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7cf2ffce2d
commit
8f25a874cb
@ -47,28 +47,11 @@
|
|||||||
import { OpenAPI, AuthService } from "@odit/lfk-client-js";
|
import { OpenAPI, AuthService } from "@odit/lfk-client-js";
|
||||||
import UserDetail from "./components/UserDetail.svelte";
|
import UserDetail from "./components/UserDetail.svelte";
|
||||||
OpenAPI.BASE = config.baseurl;
|
OpenAPI.BASE = config.baseurl;
|
||||||
|
import { register as registerSW } from "./swmodule";
|
||||||
store.init();
|
store.init();
|
||||||
|
// registerSW();
|
||||||
if ("serviceWorker" in navigator) {
|
|
||||||
window.addEventListener("load", () => {
|
|
||||||
navigator.serviceWorker.register("/sw.js").then(
|
|
||||||
(registration) => {
|
|
||||||
// console.log(`sw successful with scope: ${registration.scope}`);
|
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
// console.log(`sw failed: ${err}`);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
|
||||||
.bg-gray-900 {
|
|
||||||
background-color: #121317;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<Route>
|
<Route>
|
||||||
{#if $router.path === '/forgot_password'}
|
{#if $router.path === '/forgot_password'}
|
||||||
<Route path="/forgot_password">
|
<Route path="/forgot_password">
|
||||||
|
14
src/swmodule.js
Normal file
14
src/swmodule.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export const register = () => {
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
navigator.serviceWorker.register('/sw.js').then(
|
||||||
|
(registration) => {
|
||||||
|
// console.log(`sw successful with scope: ${registration.scope}`);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
// console.log(`sw failed: ${err}`);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user