Skip to content

Commit

Permalink
更新pwa
Browse files Browse the repository at this point in the history
  • Loading branch information
more-strive committed Nov 30, 2024
1 parent 6b39114 commit d65db3f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions public/sw.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// public/sw.js
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);
})
);
});
});
});

0 comments on commit d65db3f

Please sign in to comment.