Revert "clear sw cache"

This reverts commit 88728db722.
This commit is contained in:
fly_mc 2024-10-30 21:28:16 +08:00
parent 42b9efd118
commit f4a4acf467

View file

@ -12,29 +12,8 @@ import { createEmptyNotification, createNotification } from '@/scripts/create-no
import { swLang } from '@/scripts/lang.js';
import * as swos from '@/scripts/operations.js';
const CACHE_NAME = `pari-cache-${_VERSION_}`;
const urlsToCache = [
'/manifest.json',
'/assets',
'/emoji',
'/twemoji',
'/fluent-emoji',
'/vite',
'/identicon',
'/proxy'
];
globalThis.addEventListener('install', async (event) => {
event.waitUntil(
caches.keys().then(cacheNames => {
return Promise.all(
cacheNames
.filter(name => name.startsWith('pari-cache-'))
.map(name => caches.delete(name))
);
})
);
await globalThis.skipWaiting();
globalThis.addEventListener('install', () => {
// ev.waitUntil(globalThis.skipWaiting());
});
globalThis.addEventListener('activate', ev => {
@ -42,10 +21,10 @@ globalThis.addEventListener('activate', ev => {
caches.keys()
.then(cacheNames => Promise.all(
cacheNames
.filter(name => name.startsWith('pari-cache-') || urlsToCache.some(url => name.includes(url)))
.map(name => caches.delete(name))
.filter((v) => v !== swLang.cacheName)
.map(name => caches.delete(name)),
))
.then(() => globalThis.clients.claim())
.then(() => globalThis.clients.claim()),
);
});