Add PWA support: manifest, service worker, icons

This commit is contained in:
Andre
2026-02-27 09:55:21 +01:00
parent 5a035134b2
commit bf0e3a9038
13 changed files with 207 additions and 9 deletions
+43
View File
@@ -0,0 +1,43 @@
const CACHE_NAME = 'nadiri-timer-v1';
const urlsToCache = [
'/',
'/index.html',
'/manifest.json',
'/logo.png',
'/vite.svg'
];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => {
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request)
.then((response) => {
if (response) {
return response;
}
return fetch(event.request);
})
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName !== CACHE_NAME) {
return caches.delete(cacheName);
}
})
);
})
);
});