feat: implement PWA, manifest, service worker and offline indicator

This commit is contained in:
2025-12-17 23:15:51 +01:00
parent 5807d949ef
commit 19689ffd2f
71 changed files with 1573 additions and 112 deletions

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

BIN
public/icon-192.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

BIN
public/icon-512.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 428 KiB

38
public/sw.js Normal file
View File

@@ -0,0 +1,38 @@
const CACHE_NAME = 'whisky-vault-v1';
const ASSETS_TO_CACHE = [
'/',
'/manifest.json',
'/icon-192.png',
'/icon-512.png',
'/favicon.ico',
];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME).then((cache) => {
return cache.addAll(ASSETS_TO_CACHE);
})
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((cacheNames) => {
return Promise.all(
cacheNames.map((cacheName) => {
if (cacheName !== CACHE_NAME) {
return caches.delete(cacheName);
}
})
);
})
);
});
self.addEventListener('fetch', (event) => {
event.respondWith(
caches.match(event.request).then((response) => {
return response || fetch(event.request);
})
);
});