feat: migrar backend unificado a Go 1.27 + SPA Vite embebido
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,37 @@
|
||||
// Service worker del panel de cliente: solo notificaciones push.
|
||||
// Sin estrategias de cache — el panel siempre va a red.
|
||||
|
||||
self.addEventListener("push", (event) => {
|
||||
let data = {};
|
||||
try {
|
||||
data = event.data ? event.data.json() : {};
|
||||
} catch {
|
||||
data = {};
|
||||
}
|
||||
const titulo = (data && data.titulo) || "Cotizador — Uriel Jareth Consulting";
|
||||
const cuerpo = (data && data.cuerpo) || "";
|
||||
const url = (data && data.url) || "/cliente/pagos";
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(titulo, {
|
||||
body: cuerpo,
|
||||
icon: "/favicon.ico",
|
||||
data: { url },
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("notificationclick", (event) => {
|
||||
const data = event.notification.data || {};
|
||||
const url = data.url || "/cliente/pagos";
|
||||
event.notification.close();
|
||||
event.waitUntil(
|
||||
self.clients
|
||||
.matchAll({ type: "window", includeUncontrolled: true })
|
||||
.then((cs) => {
|
||||
const existing = cs.find((c) => "focus" in c);
|
||||
return existing
|
||||
? existing.navigate(url).then(() => existing.focus())
|
||||
: self.clients.openWindow(url);
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user