feat: add PWA support with service worker, manifest, and auto-scan configuration for offline capability and mobile installation

Add manifest.json with app metadata, theme colors, and icon configuration for installable PWA. Add service worker (sw.js) with shell caching strategy for offline support - caches static assets on install, cleans old caches on activate, and implements network-first fetch with cache fallback for non-API requests.

Update index.html with PWA meta tags (theme-color, mobile
This commit is contained in:
2026-08-13 22:03:53 +02:00
parent 0d48c9eef2
commit f63ba5381b
3 changed files with 43 additions and 1 deletions
+20
View File
@@ -0,0 +1,20 @@
const CACHE_NAME = 'media-dashboard-shell-v1';
const SHELL = ['/static/media-mark.svg', '/static/manifest.json'];
self.addEventListener('install', event => {
event.waitUntil(caches.open(CACHE_NAME).then(cache => cache.addAll(SHELL)));
self.skipWaiting();
});
self.addEventListener('activate', event => {
event.waitUntil(caches.keys().then(keys => Promise.all(keys.filter(key => key !== CACHE_NAME).map(key => caches.delete(key)))));
self.clients.claim();
});
self.addEventListener('fetch', event => {
const request = event.request;
if (request.method !== 'GET') return;
const url = new URL(request.url);
if (url.pathname.startsWith('/api/')) return;
event.respondWith(fetch(request).catch(() => caches.match(request).then(response => response || caches.match('/static/manifest.json'))));
});