diff --git a/src/App.vue b/src/App.vue index e8613efb..f24eebf0 100644 --- a/src/App.vue +++ b/src/App.vue @@ -34,11 +34,12 @@ - - - - - + + + + + + diff --git a/src/components/TheServiceWorker.vue b/src/components/TheServiceWorker.vue new file mode 100644 index 00000000..2012f9e0 --- /dev/null +++ b/src/components/TheServiceWorker.vue @@ -0,0 +1,60 @@ + + diff --git a/src/locales/de.json b/src/locales/de.json index 0cb6b751..d7add2bd 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -30,6 +30,11 @@ "NoEmptyAllowedError": "Feld darf nicht leer sein!" }, "Printers": "Drucker", + "TheServiceWorker": { + "DescriptionNeedUpdate": "Der lokale Cache ist veraltet und muss aktualisiert werden. Bitte klicke auf den Button unten, um den Cache zu aktualisieren.", + "TitleNeedUpdate": "PWA benötigt ein Update", + "Update": "aktualisieren" + }, "ThrottledStates": { "DescriptionCurrentlyThrottled": "rPi ARM-Kern(e) sind derzeit gedrosselt.", "DescriptionFrequencyCapped": "rPi ARM max Frequenz ist derzeit auf 1,2 GHz begrenzt.", diff --git a/src/locales/en.json b/src/locales/en.json index e07c66cc..fc30f5c3 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -30,6 +30,11 @@ "NoEmptyAllowedError": "Input must not be empty!" }, "Printers": "Printers", + "TheServiceWorker": { + "DescriptionNeedUpdate": "The local cache is outdated and needs to be updated. Please click on the button below to update the cache.", + "TitleNeedUpdate": "PWA needs update", + "Update": "update" + }, "ThrottledStates": { "DescriptionCurrentlyThrottled": "rPi ARM core(s) are currently throttled down.", "DescriptionFrequencyCapped": "rPi ARM max frequency is currently limited to 1.2 GHz.", diff --git a/src/main.ts b/src/main.ts index 82509ec7..ccc1c4d8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -9,12 +9,6 @@ import i18n from '@/plugins/i18n' import store from '@/store' import router from '@/plugins/router' import { WebSocketPlugin } from '@/plugins/webSocketClient' -import { registerSW } from 'virtual:pwa-register' - -// noinspection JSUnusedGlobalSymbols -registerSW({ - onOfflineReady() {}, -}) Vue.config.productionTip = false diff --git a/vite.config.ts b/vite.config.ts index 1f7c4d34..fe8ee8e9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -40,9 +40,23 @@ const PWAConfig: Partial = { }, ], }, + workbox: { + globPatterns: ['**/*.{js,css,html,woff,woff2,png,svg}'], + navigateFallbackDenylist: [/^\/(access|api|printer|server|websocket)/, /^\/webcam[2-4]?/], + runtimeCaching: [ + { + urlPattern: (options) => options.url.pathname.startsWith('/config.json'), + handler: 'StaleWhileRevalidate', + options: { + cacheName: 'config.json', + }, + }, + ], + }, /* enable sw on development */ devOptions: { enabled: true, + type: 'module', }, }