Skip to content

Commit

Permalink
docs: unregister service worker
Browse files Browse the repository at this point in the history
  • Loading branch information
fengyuanchen committed Jun 28, 2024
1 parent 3aa7ff4 commit 236d155
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docs/public/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "Cropper.js",
"short_name": "Cropper.js",
"description": "JavaScript image cropper.",
"start_url": "/cropperjs/v2/index.html",
"display": "standalone",
"background_color": "#fff",
"theme_color": "#39f"
}
13 changes: 13 additions & 0 deletions docs/public/service-worker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
if ('serviceWorker' in navigator) {
self.addEventListener('install', () => {
self.skipWaiting();
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys()
.then((keys) => Promise.all(keys.map((key) => caches.delete(key))))
.then(() => navigator.serviceWorker.getRegistrations())
.then((registrations) => Promise.all(registrations.map((registration) => registration.unregister())))
);
});
}

0 comments on commit 236d155

Please sign in to comment.