Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -444,28 +444,37 @@ def main():
|
|
444 |
gr.HTML("""
|
445 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
446 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
|
447 |
<meta name="apple-mobile-web-app-title" content="PawMatch AI">
|
|
|
|
|
|
|
448 |
<link rel="manifest" href="manifest.json">
|
449 |
<link rel="apple-touch-icon" href="assets/icon-192.png">
|
450 |
|
|
|
451 |
<script>
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
}
|
466 |
-
}
|
467 |
-
|
468 |
-
|
|
|
|
|
|
|
|
|
469 |
</script>
|
470 |
""")
|
471 |
|
|
|
444 |
gr.HTML("""
|
445 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
446 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
447 |
+
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
448 |
<meta name="apple-mobile-web-app-title" content="PawMatch AI">
|
449 |
+
<meta name="theme-color" content="#4299e1">
|
450 |
+
|
451 |
+
<!-- PWA 必要檔案的連結,使用相對路徑 -->
|
452 |
<link rel="manifest" href="manifest.json">
|
453 |
<link rel="apple-touch-icon" href="assets/icon-192.png">
|
454 |
|
455 |
+
<!-- Service Worker 註冊程序 -->
|
456 |
<script>
|
457 |
+
// 等待頁面完全載入後再註冊 Service Worker
|
458 |
+
document.addEventListener('DOMContentLoaded', function() {
|
459 |
+
// 確保我們不是在 iframe 中執行
|
460 |
+
if (window.self === window.top) {
|
461 |
+
// 確認瀏覽器支援 Service Worker
|
462 |
+
if ('serviceWorker' in navigator) {
|
463 |
+
// 使用相對路徑註冊 Service Worker
|
464 |
+
navigator.serviceWorker.register('service-worker.js')
|
465 |
+
.then(function(registration) {
|
466 |
+
console.log('Service Worker 註冊成功,範圍:', registration.scope);
|
467 |
+
})
|
468 |
+
.catch(function(error) {
|
469 |
+
console.log('Service Worker 註冊失敗:', error);
|
470 |
+
});
|
471 |
+
} else {
|
472 |
+
console.log('此瀏覽器不支援 Service Worker');
|
473 |
+
}
|
474 |
+
} else {
|
475 |
+
console.log('在 iframe 中執行,跳過 Service Worker 註冊');
|
476 |
+
}
|
477 |
+
});
|
478 |
</script>
|
479 |
""")
|
480 |
|