diff options
| author | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-08-22 19:21:12 +0900 |
|---|---|---|
| committer | yyamashita <yyamashita@hetzner.yyamashita.com> | 2026-08-22 19:21:12 +0900 |
| commit | 7c80f5ce7e44b95d16e19de40de0f8079377c6b9 (patch) | |
| tree | ad189b750361af8c7cb040b56f42df5d4e5a89ee /public | |
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'public')
| -rw-r--r-- | public/icons/icon-192.png | bin | 0 -> 1099 bytes | |||
| -rw-r--r-- | public/icons/icon-512.png | bin | 0 -> 3683 bytes | |||
| -rw-r--r-- | public/manifest.json | 13 | ||||
| -rw-r--r-- | public/sw.js | 26 |
4 files changed, 39 insertions, 0 deletions
diff --git a/public/icons/icon-192.png b/public/icons/icon-192.png Binary files differnew file mode 100644 index 0000000..75d6fc6 --- /dev/null +++ b/public/icons/icon-192.png diff --git a/public/icons/icon-512.png b/public/icons/icon-512.png Binary files differnew file mode 100644 index 0000000..a9b3d12 --- /dev/null +++ b/public/icons/icon-512.png diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..0829b4a --- /dev/null +++ b/public/manifest.json @@ -0,0 +1,13 @@ +{ + "name": "Todo", + "short_name": "Todo", + "description": "個人用タスク管理", + "start_url": "/", + "display": "standalone", + "background_color": "#111827", + "theme_color": "#6c63ff", + "icons": [ + { "src": "/icons/icon-192.png", "sizes": "192x192", "type": "image/png", "purpose": "any maskable" }, + { "src": "/icons/icon-512.png", "sizes": "512x512", "type": "image/png", "purpose": "any maskable" } + ] +} diff --git a/public/sw.js b/public/sw.js new file mode 100644 index 0000000..f4e6631 --- /dev/null +++ b/public/sw.js @@ -0,0 +1,26 @@ +const CACHE = "todo-v1"; +const PRECACHE = ["/manifest.json", "/icons/icon-192.png", "/icons/icon-512.png"]; + +self.addEventListener("install", (e) => { + e.waitUntil(caches.open(CACHE).then((c) => c.addAll(PRECACHE))); + self.skipWaiting(); +}); + +self.addEventListener("activate", (e) => { + e.waitUntil( + caches.keys().then((keys) => Promise.all(keys.filter((k) => k !== CACHE).map((k) => caches.delete(k)))) + ); + self.clients.claim(); +}); + +self.addEventListener("fetch", (e) => { + const url = new URL(e.request.url); + if (url.pathname.startsWith("/icons/") || url.pathname === "/manifest.json") { + e.respondWith(caches.match(e.request).then((r) => r || fetch(e.request))); + return; + } + // Network-first for everything else (SSR pages, API) + e.respondWith( + fetch(e.request).catch(() => caches.match(e.request)) + ); +}); |
