now it is PWA

This commit is contained in:
2026-08-05 13:15:07 +03:00
parent 3f6996b8e7
commit b0d121a2ef
7 changed files with 81 additions and 6 deletions
+35
View File
@@ -0,0 +1,35 @@
const CACHE = 'otaman-v1';
const URLS = [
'index.html',
'style.css',
'sim.png',
'icon-192.png',
'icon-512.png',
'manifest.json',
'des-bundle.js',
];
self.addEventListener('install', e => {
e.waitUntil(
caches.open(CACHE).then(c => c.addAll(URLS))
);
self.skipWaiting();
});
self.addEventListener('activate', e => {
e.waitUntil(
caches.keys().then(keys =>
Promise.all(keys.filter(k => k !== CACHE).map(k => caches.delete(k)))
)
);
});
self.addEventListener('fetch', e => {
e.respondWith(
caches.match(e.request).then(r => r || fetch(e.request).then(res => {
const clone = res.clone();
caches.open(CACHE).then(c => c.put(e.request, clone));
return res;
}))
);
});