feat: add sw
This commit is contained in:
parent
291463061c
commit
0ea1cfc8cc
@ -1,10 +1,11 @@
|
|||||||
(async function () {
|
(async function () {
|
||||||
|
console.log("Registering service worker...");
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
try {
|
try {
|
||||||
const registration = await navigator.serviceWorker.register(
|
const registration = await navigator.serviceWorker.register(
|
||||||
"sw.js",
|
"sw.js",
|
||||||
{
|
{
|
||||||
scope: "./",
|
scope: window.location.path,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (registration.installing) {
|
if (registration.installing) {
|
||||||
@ -14,6 +15,7 @@
|
|||||||
} else if (registration.active) {
|
} else if (registration.active) {
|
||||||
console.log("Service worker active");
|
console.log("Service worker active");
|
||||||
}
|
}
|
||||||
|
console.log(registration);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Registration failed with ${error}`);
|
console.error(`Registration failed with ${error}`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user