feat(ui): installierbare PWA mit Manifest und Symbolen, ohne Service Worker (#1062)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-16 22:59:15 +01:00
parent 05bb6c242b
commit 25398a6f9a
7 changed files with 117 additions and 1 deletions

View File

@ -142,6 +142,10 @@ pub fn routes() -> Router<Arc<AppState>> {
.route("/ui/app.js", get(app_js))
.route("/ui/app.css", get(app_css))
.route("/ui/favicon.svg", get(favicon))
// PWA (→ #1062): Manifest und Symbole sind ohne Anmeldung lesbar, enthalten
// nur Name und Farben. Einen Service Worker gibt es bewusst nicht.
.route("/ui/manifest.webmanifest", get(manifest))
.route("/ui/icons/{name}", get(icon))
}
// --- Sitzungen ---------------------------------------------------------------
@ -411,6 +415,10 @@ fn head(title: &str) -> String {
"<!doctype html><html lang=\"de\"><head><meta charset=\"utf-8\">\
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\
<title>{} · neXus</title><link rel=\"icon\" type=\"image/svg+xml\" href=\"/ui/favicon.svg\">\
<link rel=\"manifest\" href=\"/ui/manifest.webmanifest\">\
<link rel=\"apple-touch-icon\" href=\"/ui/icons/icon-192.png\">\
<meta name=\"theme-color\" content=\"#0f1115\" media=\"(prefers-color-scheme: dark)\">\
<meta name=\"theme-color\" content=\"#f6f3ef\" media=\"(prefers-color-scheme: light)\">\
<link rel=\"stylesheet\" href=\"/ui/app.css\"></head>",
esc(title)
)
@ -1131,6 +1139,50 @@ async fn favicon() -> Response {
.unwrap_or_default()
}
/// Web-App-Manifest: macht die Oberfläche installierbar. Nur öffentliche Angaben.
const MANIFEST: &str = r##"{
"name": "neXus",
"short_name": "neXus",
"description": "AI Gateway für srv04: Verwaltung und Chat",
"lang": "de",
"start_url": "/ui",
"scope": "/ui",
"display": "standalone",
"background_color": "#0f1115",
"theme_color": "#0f1115",
"icons": [
{"src": "/ui/favicon.svg", "sizes": "any", "type": "image/svg+xml", "purpose": "any"},
{"src": "/ui/icons/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any"},
{"src": "/ui/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any"},
{"src": "/ui/icons/icon-maskable-512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable"}
]
}
"##;
const ICON_192: &[u8] = include_bytes!("ui/icons/icon-192.png");
const ICON_512: &[u8] = include_bytes!("ui/icons/icon-512.png");
const ICON_MASKABLE_512: &[u8] = include_bytes!("ui/icons/icon-maskable-512.png");
async fn manifest() -> Response {
secure(Response::builder())
.header(CONTENT_TYPE, "application/manifest+json")
.body(Body::from(MANIFEST))
.unwrap_or_default()
}
async fn icon(axum::extract::Path(name): axum::extract::Path<String>) -> Response {
let bytes = match name.as_str() {
"icon-192.png" => ICON_192,
"icon-512.png" => ICON_512,
"icon-maskable-512.png" => ICON_MASKABLE_512,
_ => return refused(StatusCode::NOT_FOUND, "Unbekanntes Symbol."),
};
secure(Response::builder())
.header(CONTENT_TYPE, "image/png")
.body(Body::from(bytes))
.unwrap_or_default()
}
async fn app_css() -> Response {
secure(Response::builder())
.header(CONTENT_TYPE, "text/css; charset=utf-8")

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB