diff --git a/frontend/public/manifest-1.json b/frontend/public/manifest-1.json new file mode 100644 index 0000000..0c8eb72 --- /dev/null +++ b/frontend/public/manifest-1.json @@ -0,0 +1,14 @@ +{ + "name": "Dicken Dock", + "short_name": "DickenDock", + "description": "Dein modulares Tool-Dashboard", + "start_url": "/", + "display": "standalone", + "orientation": "portrait", + "background_color": "#0d0d0f", + "theme_color": "#0d0d0f", + "icons": [ + { "src": "/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any" }, + { "src": "/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" } + ] +} diff --git a/frontend/public/sw-1.js b/frontend/public/sw-1.js new file mode 100644 index 0000000..7e549c7 --- /dev/null +++ b/frontend/public/sw-1.js @@ -0,0 +1,34 @@ +const CACHE = 'dickendock-v1'; +const ASSETS = ['/', '/index.html']; + +self.addEventListener('install', e => { + e.waitUntil( + caches.open(CACHE).then(c => c.addAll(ASSETS)).then(() => self.skipWaiting()) + ); +}); + +self.addEventListener('activate', e => { + e.waitUntil( + caches.keys().then(keys => + Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k))) + ).then(() => self.clients.claim()) + ); +}); + +self.addEventListener('fetch', e => { + // API-Anfragen immer live holen + if (e.request.url.includes('/api/')) { + e.respondWith(fetch(e.request).catch(() => new Response('Offline', { status: 503 }))); + return; + } + // Alles andere: Cache first, dann Network + e.respondWith( + caches.match(e.request).then(cached => { + const network = fetch(e.request).then(res => { + if (res.ok) caches.open(CACHE).then(c => c.put(e.request, res.clone())); + return res; + }); + return cached || network; + }) + ); +});