app: fix sw registration
parent
efceb7feaf
commit
8d4d2d6240
38
src/App.vue
38
src/App.vue
|
@ -206,6 +206,25 @@ export default defineComponent({
|
|||
}
|
||||
},
|
||||
|
||||
async beforeMount() {
|
||||
if ("serviceWorker" in navigator) {
|
||||
// Use the window load event to keep the page load performant
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const url = generateUrl("/apps/memories/service-worker.js");
|
||||
const registration = await navigator.serviceWorker.register(url, {
|
||||
scope: generateUrl("/apps/memories"),
|
||||
});
|
||||
console.log("SW registered: ", registration);
|
||||
} catch (error) {
|
||||
console.error("SW registration failed: ", error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.debug("Service Worker is not enabled on this browser.");
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
navItemsAll() {
|
||||
return [
|
||||
|
@ -277,25 +296,6 @@ export default defineComponent({
|
|||
];
|
||||
},
|
||||
|
||||
async beforeMount() {
|
||||
if ("serviceWorker" in navigator) {
|
||||
// Use the window load event to keep the page load performant
|
||||
window.addEventListener("load", async () => {
|
||||
try {
|
||||
const url = generateUrl("/apps/memories/service-worker.js");
|
||||
const registration = await navigator.serviceWorker.register(url, {
|
||||
scope: generateUrl("/apps/memories"),
|
||||
});
|
||||
console.log("SW registered: ", registration);
|
||||
} catch (error) {
|
||||
console.error("SW registration failed: ", error);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
console.debug("Service Worker is not enabled on this browser.");
|
||||
}
|
||||
},
|
||||
|
||||
linkClick() {
|
||||
const nav: any = this.$refs.nav;
|
||||
if (globalThis.windowInnerWidth <= 1024) nav?.toggleNavigation(false);
|
||||
|
|
Loading…
Reference in New Issue