PWA: Manifest, Service Worker, Icons und Offline-Seite

This commit is contained in:
OpenCode 2026-11-13 00:46:02 +01:00
parent ec88c8ebac
commit 67a1614081
19 changed files with 472 additions and 5 deletions

View file

@ -778,6 +778,18 @@ a .ico, button .ico { pointer-events: none; }
.error-card h1 { margin-bottom: 8px; }
.error-card p { color: var(--muted); margin-bottom: 18px; }
/* --------------------------------------------------------------- PWA */
@supports (padding: env(safe-area-inset-top)) {
.topbar { padding-top: env(safe-area-inset-top); }
.page { padding-bottom: max(48px, calc(48px + env(safe-area-inset-bottom))); }
.auth-panel { padding-bottom: max(clamp(22px, 4vw, 56px), calc(22px + env(safe-area-inset-bottom))); }
}
@media (display-mode: standalone) {
.footer { padding-bottom: calc(30px + env(safe-area-inset-bottom)); }
.auth-foot { bottom: calc(22px + env(safe-area-inset-bottom)); }
}
/* --------------------------------------------------------------- Responsive */
@media (max-width: 1240px) {
.dash-grid { grid-template-columns: 1fr; }

View file

@ -3,7 +3,48 @@
'use strict';
const csrf = document.querySelector('meta[name="csrf-token"]')?.content || '';
const swMeta = document.querySelector('meta[name="sw-url"]');
let toastTimer = 0;
let installPrompt = null;
/* --------------------------------------------------------------- PWA */
const registerServiceWorker = () => {
if (!('serviceWorker' in navigator) || !swMeta) return;
navigator.serviceWorker.register(swMeta.content).catch(() => {
/* Installation ist optional; die App funktioniert auch ohne SW. */
});
};
if (document.readyState === 'complete') {
registerServiceWorker();
} else {
window.addEventListener('load', registerServiceWorker, { once: true });
}
window.addEventListener('beforeinstallprompt', (event) => {
event.preventDefault();
installPrompt = event;
document.querySelectorAll('[data-install-app]').forEach((button) => { button.hidden = false; });
});
window.addEventListener('appinstalled', () => {
installPrompt = null;
document.querySelectorAll('[data-install-app]').forEach((button) => { button.hidden = true; });
toast('Die App wurde installiert.');
});
document.addEventListener('click', async (event) => {
const button = event.target.closest('[data-install-app]');
if (!button || !installPrompt) return;
const prompt = installPrompt;
installPrompt = null;
button.hidden = true;
try {
prompt.prompt();
await prompt.userChoice;
} catch (error) {
/* Der Browser kann die Installation trotzdem abgelehnt haben. */
}
});
const toast = (message, isError = false) => {
const el = document.getElementById('toast');

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -0,0 +1,47 @@
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
<rect width="512" height="512" fill="#196abc"/>
<g transform="translate(256 256) scale(0.72)" fill="none" stroke="#ffffff" stroke-width="22" stroke-linecap="round" stroke-linejoin="round">
<g transform="rotate(0)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(60)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(120)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(180)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(240)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(300)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

47
web/assets/icons/icon.svg Normal file
View file

@ -0,0 +1,47 @@
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
<rect width="512" height="512" rx="112" fill="#196abc"/>
<g transform="translate(256 256)" fill="none" stroke="#ffffff" stroke-width="22" stroke-linecap="round" stroke-linejoin="round">
<g transform="rotate(0)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(60)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(120)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(180)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(240)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
<g transform="rotate(300)">
<path d="M0 -158 L0 0"/>
<path d="M0 -92 L-42 -134"/>
<path d="M0 -92 L42 -134"/>
<path d="M0 -136 L-30 -166"/>
<path d="M0 -136 L30 -166"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB