vue.js used

This commit is contained in:
cpu
2025-05-07 22:17:29 +02:00
parent 049866ecd7
commit 04dd879c24
33 changed files with 4471 additions and 0 deletions

49
public/service-worker.js Normal file
View File

@@ -0,0 +1,49 @@
const CACHE_NAME = 'nexus-timer-cache-v1';
const urlsToCache = [
'/',
'/index.html',
'/manifest.json',
'/favicon.ico',
'/icons/icon-192x192.png',
'/icons/icon-512x512.png',
// Add other static assets here, like JS/CSS bundles if not dynamically named
// Vite typically names bundles with hashes, so caching them directly might be tricky
// For a PWA, focus on caching the app shell and key static assets
];
self.addEventListener('install', event => {
event.waitUntil(
caches.open(CACHE_NAME)
.then(cache => {
console.log('Opened cache');
return cache.addAll(urlsToCache);
})
);
});
self.addEventListener('fetch', event => {
event.respondWith(
caches.match(event.request)
.then(response => {
if (response) {
return response; // Serve from cache
}
return fetch(event.request); // Fetch from network
})
);
});
self.addEventListener('activate', event => {
const cacheWhitelist = [CACHE_NAME];
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames.map(cacheName => {
if (cacheWhitelist.indexOf(cacheName) === -1) {
return caches.delete(cacheName);
}
})
);
})
);
});