Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -444,48 +444,26 @@ def main():
|
|
444 |
|
445 |
gr.HTML("""
|
446 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
447 |
-
<meta name="theme-color" content="#4299e1">
|
448 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
449 |
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
450 |
<meta name="apple-mobile-web-app-title" content="PawMatch AI">
|
451 |
-
<link rel="manifest" href="manifest.json">
|
452 |
-
<link rel="apple-touch-icon" href="assets/icon-192.png">
|
453 |
|
454 |
<script>
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
console.log('ServiceWorker 註冊成功!範圍是:', registration.scope);
|
464 |
-
|
465 |
-
// 監聽 Service Worker 狀態變化
|
466 |
-
registration.addEventListener('updatefound', () => {
|
467 |
-
const newWorker = registration.installing;
|
468 |
-
console.log('發現新的 Service Worker');
|
469 |
-
|
470 |
-
newWorker.addEventListener('statechange', () => {
|
471 |
-
console.log('Service Worker 狀態:', newWorker.state);
|
472 |
-
});
|
473 |
-
});
|
474 |
-
|
475 |
-
} catch (error) {
|
476 |
-
console.error('ServiceWorker 註冊失敗:', error);
|
477 |
}
|
478 |
-
})
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
console.log('應用程式已連線');
|
483 |
-
});
|
484 |
-
|
485 |
-
window.addEventListener('offline', () => {
|
486 |
-
console.log('應用程式已離線');
|
487 |
-
});
|
488 |
-
}
|
489 |
</script>
|
490 |
<header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
|
491 |
<h1 style='font-size: 2.5em; margin-bottom: 10px; color: #2D3748;'>
|
|
|
444 |
|
445 |
gr.HTML("""
|
446 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
447 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
448 |
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
449 |
<meta name="apple-mobile-web-app-title" content="PawMatch AI">
|
450 |
+
<link rel="manifest" href="./manifest.json">
|
451 |
+
<link rel="apple-touch-icon" href="./assets/icon-192.png">
|
452 |
|
453 |
<script>
|
454 |
+
window.addEventListener('load', async () => {
|
455 |
+
try {
|
456 |
+
if ('serviceWorker' in navigator) {
|
457 |
+
const registration = await navigator.serviceWorker.register(
|
458 |
+
'./service-worker.js',
|
459 |
+
{ scope: './' }
|
460 |
+
);
|
461 |
+
console.log('Service Worker 註冊成功:', registration);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
462 |
}
|
463 |
+
} catch (error) {
|
464 |
+
console.error('Service Worker 註冊失敗:', error);
|
465 |
+
}
|
466 |
+
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
467 |
</script>
|
468 |
<header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
|
469 |
<h1 style='font-size: 2.5em; margin-bottom: 10px; color: #2D3748;'>
|