manifest manifest.webmanifest
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
const CACHE_NAME = 'erp-shell-v2';
|
||||
const CACHE_NAME = 'erp-shell-v3';
|
||||
const API_CACHE_NAME = 'erp-api-v1';
|
||||
const WRITE_QUEUE_DB_NAME = 'erp-write-queue-db';
|
||||
const WRITE_QUEUE_STORE = 'requests';
|
||||
const WRITE_QUEUE_SYNC_TAG = 'erp-write-queue-sync';
|
||||
const OFFLINE_URL = '/offline.html';
|
||||
const PRECACHE_URLS = ['/', '/index.html', '/manifest.webmanifest', '/pwa-icon.svg', OFFLINE_URL];
|
||||
const PRECACHE_URLS = ['/', '/manifest.webmanifest', '/pwa-icon.svg', OFFLINE_URL];
|
||||
|
||||
const API_CACHE_BLOCKLIST = [
|
||||
'/api/token/',
|
||||
@@ -143,9 +143,27 @@ async function replayQueuedRequests() {
|
||||
}
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_URLS))
|
||||
self.addEventListener('install', (event) => {
|
||||
async function precacheShell() {
|
||||
const cache = await caches.open(CACHE_NAME);
|
||||
await Promise.all(
|
||||
PRECACHE_URLS.map(async (url) => {
|
||||
try {
|
||||
const response = await fetch(url, { cache: 'reload' });
|
||||
if (!response || !response.ok) {
|
||||
console.warn('Skipping precache for non-OK response:', url, response && response.status);
|
||||
return;
|
||||
}
|
||||
await cache.put(url, response);
|
||||
} catch (error) {
|
||||
console.warn('Skipping precache for failed request:', url, error);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(precacheShell());
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user