1
0
mirror of https://github.com/zumbiepig/MineXLauncher.git synced 2025-06-26 10:05:10 +00:00
This commit is contained in:
zumbiepig
2024-08-17 10:43:32 -07:00
parent 33d2f59287
commit b0a03d94c8
49 changed files with 234 additions and 305 deletions

View File

@@ -1,7 +1,5 @@
const CACHE_NAME = 'minexlauncher';
const OFFLINE_URL = '/offline.html';
const ASSETS_TO_CACHE = [
OFFLINE_URL,
const cacheAssets = [
'/offline.html',
'/resources/images/icons/favicon.webp',
'/resources/scripts/google-tag.js',
'/resources/scripts/main.js',
@@ -27,23 +25,9 @@ const ASSETS_TO_CACHE = [
self.addEventListener('install', (event) => {
event.waitUntil(
caches.delete(CACHE_NAME),
caches.open(CACHE_NAME).then(async (cache) => {
return await cache.addAll(ASSETS_TO_CACHE);
})
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keyList) => {
return Promise.all(
keyList.map((key) => {
if (key !== CACHE_NAME) {
return caches.delete(key);
}
})
);
caches.delete('minexlauncher'),
caches.open('minexlauncher').then(async (cache) => {
return await cache.addAll(cacheAssets);
})
);
});
@@ -52,7 +36,7 @@ self.addEventListener('fetch', (event) => {
if (event.request.mode === 'navigate') {
event.respondWith(
fetch(event.request).catch(() => {
return caches.match(OFFLINE_URL);
return caches.match('/offline.html');
})
);
} else {