Phase 8 Mobil: REST-API, Web-Push, installierbare App (0.25.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m54s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m0s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m54s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m50s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m48s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m38s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m56s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 7m5s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 3m54s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 4m0s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 4m54s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 4m50s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m48s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m38s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m56s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 7m5s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m17s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
232dc5c59c
commit
f11a3e24b3
201 changed files with 3604 additions and 427 deletions
64
public/sw.js
Normal file
64
public/sw.js
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Service Worker von Inhaus: Push-Benachrichtigungen und eine Offline-Seite.
|
||||
* Persönliche Inhalte werden bewusst nicht zwischengespeichert.
|
||||
*/
|
||||
const CACHE = 'inhaus-offline-1';
|
||||
const OFFLINE = '/offline.html';
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(caches.open(CACHE).then((cache) => cache.add(OFFLINE)));
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(
|
||||
caches.keys()
|
||||
.then((keys) => Promise.all(keys.filter((key) => key !== CACHE).map((key) => caches.delete(key))))
|
||||
.then(() => self.clients.claim()),
|
||||
);
|
||||
});
|
||||
|
||||
// Ohne Verbindung: statt Browser-Fehlerseite die eigene Offline-Seite zeigen
|
||||
self.addEventListener('fetch', (event) => {
|
||||
if (event.request.mode !== 'navigate') return;
|
||||
|
||||
event.respondWith(fetch(event.request).catch(() => caches.match(OFFLINE)));
|
||||
});
|
||||
|
||||
self.addEventListener('push', (event) => {
|
||||
let data = {};
|
||||
|
||||
try {
|
||||
data = event.data ? event.data.json() : {};
|
||||
} catch {
|
||||
data = { body: event.data?.text() };
|
||||
}
|
||||
|
||||
event.waitUntil(
|
||||
self.registration.showNotification(data.title || 'Neue Benachrichtigung', {
|
||||
body: data.body || '',
|
||||
icon: data.icon || '/favicon.ico',
|
||||
badge: data.badge || data.icon || '/favicon.ico',
|
||||
tag: data.tag,
|
||||
data: { url: data.url || '/' },
|
||||
lang: 'de',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', (event) => {
|
||||
event.notification.close();
|
||||
const target = new URL(event.notification.data?.url || '/', self.location.origin).href;
|
||||
|
||||
event.waitUntil(
|
||||
self.clients.matchAll({ type: 'window', includeUncontrolled: true }).then((clients) => {
|
||||
const client = clients.find((c) => c.url.startsWith(self.location.origin));
|
||||
|
||||
if (client) {
|
||||
return client.focus().then(() => client.navigate(target));
|
||||
}
|
||||
|
||||
return self.clients.openWindow(target);
|
||||
}),
|
||||
);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue