- web/public/manifest.json with display=standalone, theme_color=#faff69, 192+512 icons - web/public/sw.js with app-shell cache strategy (API calls network-only) - web/public/icons/icon-192.png and icon-512.png generated via gen-icons.cjs - web/scripts/gen-icons.cjs pure-Node.js PNG icon generator (black canvas, volt H monogram) - web/src/hooks/usePWA.ts registers service worker on app load - web/index.html: added theme-color meta tag - web/src/App.tsx: calls usePWA() hook
18 lines
483 B
TypeScript
18 lines
483 B
TypeScript
import { useEffect } from 'react'
|
|
|
|
export function usePWA() {
|
|
useEffect(() => {
|
|
if ('serviceWorker' in navigator) {
|
|
window.addEventListener('load', () => {
|
|
navigator.serviceWorker
|
|
.register('/sw.js')
|
|
.then((reg) => {
|
|
console.log('[PWA] Service worker registered:', reg.scope)
|
|
})
|
|
.catch((err) => {
|
|
console.warn('[PWA] Service worker registration failed:', err)
|
|
})
|
|
})
|
|
}
|
|
}, [])
|
|
}
|