diff --git a/src/App.vue b/src/App.vue index 9a752b77..8ba24320 100644 --- a/src/App.vue +++ b/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);