This commit is contained in:
marzban-dev
2025-03-22 23:43:49 +03:30
parent 852a09c298
commit 2106f3f40b
56 changed files with 198 additions and 161 deletions

Before

Width:  |  Height:  |  Size: 7.9 MiB

After

Width:  |  Height:  |  Size: 7.9 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.1 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 MiB

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 10 KiB

Before

Width:  |  Height:  |  Size: 79 KiB

After

Width:  |  Height:  |  Size: 79 KiB

Before

Width:  |  Height:  |  Size: 10 MiB

After

Width:  |  Height:  |  Size: 10 MiB

Before

Width:  |  Height:  |  Size: 943 KiB

After

Width:  |  Height:  |  Size: 943 KiB

Before

Width:  |  Height:  |  Size: 1.1 MiB

After

Width:  |  Height:  |  Size: 1.1 MiB

Before

Width:  |  Height:  |  Size: 237 KiB

After

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 830 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 366 KiB

+64 -64
View File
@@ -1,64 +1,64 @@
import { precacheAndRoute } from "workbox-precaching";
// Precaching configuration for PWA assets
precacheAndRoute(self.__WB_MANIFEST);
// Version
const VERSION = "1.0.4";
// Service Worker Installation
self.addEventListener("install", (event) => {
self.skipWaiting();
});
// Service Worker Activation
self.addEventListener("activate", (event) => {
event.waitUntil(
(async () => {
const clients = await self.clients.matchAll({ type: "window" });
// Notify all open clients about the version
clients.forEach((client) =>
client.postMessage({ type: "VERSION_CHECK", version: VERSION })
);
self.clients.claim();
console.log("Service Worker Activated (Version: " + VERSION + ")");
})()
);
});
// Push Notification Handler for Django Web Push
self.addEventListener("push", (event) => {
try {
const payload = event.data?.json() || {
title: "New Notification",
body: "You have a new message",
icon: "/logo-192x192.png",
data: { url: "/" },
};
event.waitUntil(
self.registration.showNotification(payload.title, {
body: payload.body,
icon: payload.icon || "/logo-192x192.png",
data: payload.data,
})
);
} catch (error) {
console.error("Push handling failed:", error);
}
});
// Notification Click Handler
self.addEventListener("notificationclick", (event) => {
event.notification.close();
event.waitUntil(clients.openWindow(event.notification.data?.url || "/"));
});
self.addEventListener("message", (event) => {
if (event.data === "SKIP_WAITING") {
self.skipWaiting();
}
});
// import { precacheAndRoute } from "workbox-precaching";
//
// // Precaching configuration for PWA assets
// precacheAndRoute(self.__WB_MANIFEST);
//
// // Version
//
// const VERSION = "1.0.4";
//
// // Service Worker Installation
// self.addEventListener("install", (event) => {
// self.skipWaiting();
// });
//
// // Service Worker Activation
// self.addEventListener("activate", (event) => {
// event.waitUntil(
// (async () => {
// const clients = await self.clients.matchAll({ type: "window" });
//
// // Notify all open clients about the version
// clients.forEach((client) =>
// client.postMessage({ type: "VERSION_CHECK", version: VERSION })
// );
//
// self.clients.claim();
// console.log("Service Worker Activated (Version: " + VERSION + ")");
// })()
// );
// });
//
// // Push Notification Handler for Django Web Push
// self.addEventListener("push", (event) => {
// try {
// const payload = event.data?.json() || {
// title: "New Notification",
// body: "You have a new message",
// icon: "/logo-192x192.png",
// data: { url: "/" },
// };
//
// event.waitUntil(
// self.registration.showNotification(payload.title, {
// body: payload.body,
// icon: payload.icon || "/logo-192x192.png",
// data: payload.data,
// })
// );
// } catch (error) {
// console.error("Push handling failed:", error);
// }
// });
//
// // Notification Click Handler
// self.addEventListener("notificationclick", (event) => {
// event.notification.close();
// event.waitUntil(clients.openWindow(event.notification.data?.url || "/"));
// });
//
// self.addEventListener("message", (event) => {
// if (event.data === "SKIP_WAITING") {
// self.skipWaiting();
// }
// });