Weise dem Web-App-Manifest den richtigen MIME-Typ zu und registriere einen Service Worker, damit Browser und Handy die Installation anbieten.
Deploy Development / deploy (push) Successful in 30s
Test Suite / pytest-backend (push) Successful in 1m40s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 9s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-17 21:51:22 +02:00
1 parent 339238ce21
commit db4063296b
5 files changed
+83

No files matched your search

+2
View File
@@ -4,8 +4,10 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" />
<meta name="theme-color" content="#085041" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Tsumugu" />
<meta name="apple-mobile-web-app-status-bar-style" content="default" />
<title>Tsumugu</title>
<link rel="icon" href="/brand/favicons-v2/favicon.ico" sizes="any" />
<link rel="icon" href="/brand/favicons-v2/favicon-48.png" sizes="48x48" type="image/png" />
+10
View File
@@ -36,6 +36,16 @@ server {
proxy_read_timeout 30s;
}
# .webmanifest ist in den Standard-MIME-Typen dieses Nginx nicht enthalten.
# octet-stream plus nosniff lässt den Browser das Manifest verwerfen,
# dann fehlt das Installationsangebot.
location = /manifest.webmanifest {
types {
application/manifest+json webmanifest;
}
default_type application/manifest+json;
}
location / {
try_files $uri $uri/ /index.html;
}
+1
View File
@@ -2,6 +2,7 @@
"name": "Tsumugu",
"short_name": "Tsumugu",
"description": "Unterlagen im Zusammenhang ordnen und wiederfinden.",
"id": "/",
"start_url": "/",
"scope": "/",
"display": "standalone",
+60
View File
@@ -0,0 +1,60 @@
const CACHE = "tsumugu-shell-v1";
self.addEventListener("install", (event) => {
event.waitUntil(
caches
.open(CACHE)
.then((cache) => cache.add("/"))
.then(() => 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()),
);
});
self.addEventListener("fetch", (event) => {
const request = event.request;
if (request.method !== "GET" || request.headers.has("range")) return;
const url = new URL(request.url);
if (url.origin !== self.location.origin) return;
if (url.pathname.startsWith("/api/") || url.pathname.startsWith("/health")) return;
if (url.pathname === "/sw.js" || url.pathname === "/manifest.webmanifest") return;
if (request.mode === "navigate") {
event.respondWith(networkFirstNavigation(request));
return;
}
if (url.pathname.startsWith("/assets/")) {
event.respondWith(cacheFirst(request));
}
});
async function networkFirstNavigation(request) {
const cache = await caches.open(CACHE);
try {
const response = await fetch(request);
if (response.ok && response.type === "basic") await cache.put("/", response.clone());
return response;
} catch (error) {
const cached = await cache.match("/");
if (cached) return cached;
throw error;
}
}
async function cacheFirst(request) {
const cache = await caches.open(CACHE);
const cached = await cache.match(request);
if (cached) return cached;
const response = await fetch(request);
if (response.ok && response.type === "basic") await cache.put(request, response.clone());
return response;
}
+10
View File
@@ -11,3 +11,13 @@ createRoot(document.getElementById("root")).render(
</BrowserRouter>
</React.StrictMode>,
);
if (import.meta.env.PROD && "serviceWorker" in navigator) {
const register = () => {
navigator.serviceWorker.register("/sw.js").catch((error) => {
console.error("Service Worker nicht registriert", error);
});
};
if (document.readyState === "complete") register();
else window.addEventListener("load", register);
}