fixing clients

new frontend
This commit is contained in:
stefan
2025-09-26 13:14:00 +02:00
parent 94a76e4484
commit 97d0af1b07
11 changed files with 389 additions and 53 deletions
+9 -3
View File
@@ -4,12 +4,18 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Meldestelle</title>
<meta name="theme-color" content="#0f172a">
<link type="text/css" rel="stylesheet" href="styles.css">
<!-- <script src="web-app.js"></script>-->
<link rel="manifest" href="manifest.webmanifest">
</head>
<body>
<div id="ComposeTarget"></div>
<!--<script src="skiko.js"></script>-->
<!--<script src="Meldestelle-client.js"></script>-->
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('/sw.js').catch(console.error);
});
}
</script>
</body>
</html>
@@ -0,0 +1,13 @@
{
"name": "Meldestelle",
"short_name": "Melde",
"start_url": "/",
"scope": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#0f172a",
"icons": [
{ "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png" },
{ "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png" }
]
}
+49
View File
@@ -0,0 +1,49 @@
const CACHE_NAME = 'meldestelle-cache-v1';
const PRECACHE_URLS = [
'/',
'/index.html',
'/styles.css'
];
self.addEventListener('install', (event) => {
event.waitUntil(
caches.open(CACHE_NAME)
.then((cache) => cache.addAll(PRECACHE_URLS))
.then(() => self.skipWaiting())
);
});
self.addEventListener('activate', (event) => {
event.waitUntil(
caches.keys().then((keys) => Promise.all(
keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k))
)).then(() => self.clients.claim())
);
});
self.addEventListener('fetch', (event) => {
const req = event.request;
if (req.mode === 'navigate') {
// Network-first for navigation
event.respondWith(
fetch(req).then((resp) => {
const copy = resp.clone();
caches.open(CACHE_NAME).then((cache) => cache.put('/', copy));
return resp;
}).catch(() => caches.match('/index.html'))
);
return;
}
// Cache-first for static assets
event.respondWith(
caches.match(req).then((cached) => {
if (cached) return cached;
return fetch(req).then((resp) => {
const copy = resp.clone();
caches.open(CACHE_NAME).then((cache) => cache.put(req, copy));
return resp;
});
})
);
});