mirror of
https://github.com/louislam/uptime-kuma.git
synced 2026-03-03 03:07:02 +00:00
fix: Clear 2.1.0 frontend PWA cache (#6933)
Co-authored-by: Louis Lam <louislam@users.noreply.github.com>
This commit is contained in:
@@ -1,3 +1,20 @@
|
|||||||
|
self.addEventListener("install", function (event) {
|
||||||
|
self.skipWaiting();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Clear old caches from vite-plugin-pwa
|
||||||
|
self.addEventListener("activate", function (event) {
|
||||||
|
event.waitUntil(
|
||||||
|
(async function () {
|
||||||
|
const cacheNames = await caches.keys();
|
||||||
|
for (const cacheName of cacheNames) {
|
||||||
|
await caches.delete(cacheName);
|
||||||
|
}
|
||||||
|
await self.clients.claim();
|
||||||
|
})()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
// Receive push notifications
|
// Receive push notifications
|
||||||
self.addEventListener("push", function (event) {
|
self.addEventListener("push", function (event) {
|
||||||
if (self.Notification?.permission !== "granted") {
|
if (self.Notification?.permission !== "granted") {
|
||||||
@@ -44,8 +44,10 @@ app.component("FontAwesomeIcon", FontAwesomeIcon);
|
|||||||
|
|
||||||
app.mount("#app");
|
app.mount("#app");
|
||||||
|
|
||||||
|
// Service Worker
|
||||||
|
// Mainly for Webpush notification
|
||||||
if ("serviceWorker" in navigator) {
|
if ("serviceWorker" in navigator) {
|
||||||
navigator.serviceWorker.register("/sw.js", { scope: "/" }).catch((error) => {
|
navigator.serviceWorker.register("/serviceWorker.js", { scope: "/" }).catch((error) => {
|
||||||
console.error("Service worker registration failed:", error);
|
console.error("Service worker registration failed:", error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user