- public/manifest.webmanifest (standalone, tr, kisayollar) + 192/512 ve maskable ikonlar + apple-touch-icon; index.html PWA meta etiketleri - public/sw.js: /assets cache-first (hash'li adlar), kabuk network-first, /api ASLA onbellekten (eski ihale gosterilmesin); surum degisince temizlik - main.jsx: SW yalniz uretimde kaydedilir (dev'de HMR ile cakismasin) - Mobil PWA sayfasindaki "Cihaza Yukle" dugmesi sahteydi (setInstalled(true)); artik beforeinstallprompt ile gercek kurulum, standalone algilama, iOS/ Android/masaustu yol tarifi - Kucuk ekranda sol filtre paneli listeyi 72 satir asagi itiyordu: lg altinda "Filtreler" dugmesiyle acilan cekmece; sag panel xl altinda gizli Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
29 lines
1.5 KiB
JavaScript
29 lines
1.5 KiB
JavaScript
/* İhaleist service worker — uygulama kabuğu çevrimdışı açılır, API her zaman ağdan.
|
||
Sürüm değişince eski önbellek temizlenir (build her deploy'da yeni asset adı üretir). */
|
||
const SURUM = 'ihaleist-v1';
|
||
const KABUK = ['/', '/manifest.webmanifest', '/icons/icon-192.png', '/icons/icon-512.png'];
|
||
|
||
self.addEventListener('install', (e) => {
|
||
e.waitUntil(caches.open(SURUM).then((c) => c.addAll(KABUK)).then(() => self.skipWaiting()));
|
||
});
|
||
self.addEventListener('activate', (e) => {
|
||
e.waitUntil(caches.keys().then((ks) => Promise.all(ks.filter((k) => k !== SURUM).map((k) => caches.delete(k)))).then(() => self.clients.claim()));
|
||
});
|
||
self.addEventListener('fetch', (e) => {
|
||
const url = new URL(e.request.url);
|
||
if (e.request.method !== 'GET' || url.origin !== self.location.origin) return;
|
||
// API: yalnız ağ — önbellekten eski ihale gösterme
|
||
if (url.pathname.startsWith('/api/')) return;
|
||
// Hash'li build varlıkları: cache-first (değişmez adlar)
|
||
if (url.pathname.startsWith('/assets/')) {
|
||
e.respondWith(caches.match(e.request).then((hit) => hit || fetch(e.request).then((r) => {
|
||
const kopya = r.clone(); caches.open(SURUM).then((c) => c.put(e.request, kopya)); return r;
|
||
})));
|
||
return;
|
||
}
|
||
// Kabuk / sayfa: network-first, ağ yoksa önbellekten index
|
||
e.respondWith(fetch(e.request).then((r) => {
|
||
const kopya = r.clone(); caches.open(SURUM).then((c) => c.put(e.request, kopya)); return r;
|
||
}).catch(() => caches.match(e.request).then((hit) => hit || caches.match('/'))));
|
||
});
|