mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 03:09:14 +08:00
24 lines
589 B
JavaScript
24 lines
589 B
JavaScript
|
self.addEventListener("install", (e) => {
|
||
|
self.skipWaiting()
|
||
|
})
|
||
|
self.addEventListener("activate", (e) => {
|
||
|
self.registration
|
||
|
.unregister()
|
||
|
.then(() => self.clients.matchAll())
|
||
|
.then((clients) => {
|
||
|
clients.forEach((client) => {
|
||
|
if (client instanceof WindowClient) client.navigate(client.url)
|
||
|
})
|
||
|
return Promise.resolve()
|
||
|
})
|
||
|
.then(() => {
|
||
|
self.caches.keys().then((cacheNames) => {
|
||
|
Promise.all(
|
||
|
cacheNames.map((cacheName) => {
|
||
|
return self.caches.delete(cacheName)
|
||
|
}),
|
||
|
)
|
||
|
})
|
||
|
})
|
||
|
})
|