KTVManager_UI/static/service-worker.js

48 lines
1.1 KiB
JavaScript
Raw Normal View History

2025-07-17 10:32:06 +01:00
const CACHE_NAME = 'ktvmanager-cache-v1';
const urlsToCache = [
'/',
'/static/styles.css',
'/static/favicon.ico',
'/static/favicon-96x96.png',
'/static/favicon.svg',
'/static/apple-touch-icon.png',
'/static/web-app-manifest-192x192.png',
'/static/web-app-manifest-512x512.png',
'/static/site.webmanifest'
];
self.addEventListener('install', function(event) {
event.waitUntil(
caches.open(CACHE_NAME)
.then(function(cache) {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
2025-07-17 15:41:16 +01:00
self.addEventListener('push', function(event) {
const data = event.data.json();
const options = {
body: data.body,
icon: '/static/web-app-manifest-192x192.png',
badge: '/static/favicon-96x96.png'
};
event.waitUntil(
self.registration.showNotification(data.title, options)
);
});
2025-07-15 10:37:34 +01:00
self.addEventListener('fetch', function(event) {
2025-07-17 10:32:06 +01:00
event.respondWith(
caches.match(event.request)
.then(function(response) {
if (response) {
return response;
}
return fetch(event.request);
}
)
);
2024-11-07 18:06:18 +00:00
});