Skip to content

Commit

Permalink
更新sw.js
Browse files Browse the repository at this point in the history
  • Loading branch information
more-strive committed Nov 29, 2024
1 parent 006d077 commit 6b39114
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ dist/*
dev-dist/*
types/auto-imports.d.ts
types/components.d.ts
pnpm-lock.yaml
24 changes: 24 additions & 0 deletions public/dev-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);
})
);
});
});
});
3 changes: 0 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
"tests/**/*.ts",
"tests/**/*.tsx",
],
"files": [
"node_modules/vite-plugin-pwa/client.d.ts"
],
"exclude": [
"node_modules"
],
Expand Down

0 comments on commit 6b39114

Please sign in to comment.