Spaces:
Sleeping
Sleeping
Update pages/index.tsx
Browse files- pages/index.tsx +13 -0
pages/index.tsx
CHANGED
|
@@ -40,6 +40,19 @@ export default function Index() {
|
|
| 40 |
fetcher,
|
| 41 |
{ refreshInterval: 5000 }
|
| 42 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
useEffect(() => {
|
| 45 |
if (typeof window !== "undefined") {
|
|
|
|
| 40 |
fetcher,
|
| 41 |
{ refreshInterval: 5000 }
|
| 42 |
)
|
| 43 |
+
// ✅ PWA: Register Service Worker
|
| 44 |
+
useEffect(() => {
|
| 45 |
+
if (typeof window !== "undefined" && "serviceWorker" in navigator) {
|
| 46 |
+
navigator.serviceWorker
|
| 47 |
+
.register("/sw.js")
|
| 48 |
+
.then(() => {
|
| 49 |
+
console.log("Service Worker registered")
|
| 50 |
+
})
|
| 51 |
+
.catch(() => {
|
| 52 |
+
// silent fail (HF / first load)
|
| 53 |
+
})
|
| 54 |
+
}
|
| 55 |
+
}, [])
|
| 56 |
|
| 57 |
useEffect(() => {
|
| 58 |
if (typeof window !== "undefined") {
|