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 API_CACHE_NAME = 'erp-api-v1';
|
||||||
const WRITE_QUEUE_DB_NAME = 'erp-write-queue-db';
|
const WRITE_QUEUE_DB_NAME = 'erp-write-queue-db';
|
||||||
const WRITE_QUEUE_STORE = 'requests';
|
const WRITE_QUEUE_STORE = 'requests';
|
||||||
const WRITE_QUEUE_SYNC_TAG = 'erp-write-queue-sync';
|
const WRITE_QUEUE_SYNC_TAG = 'erp-write-queue-sync';
|
||||||
const OFFLINE_URL = '/offline.html';
|
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 = [
|
const API_CACHE_BLOCKLIST = [
|
||||||
'/api/token/',
|
'/api/token/',
|
||||||
@@ -143,9 +143,27 @@ async function replayQueuedRequests() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.addEventListener('install', (event) => {
|
self.addEventListener('install', (event) => {
|
||||||
event.waitUntil(
|
self.addEventListener('install', (event) => {
|
||||||
caches.open(CACHE_NAME).then((cache) => cache.addAll(PRECACHE_URLS))
|
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();
|
self.skipWaiting();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user