Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -445,26 +445,32 @@ def main():
|
|
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 |
-
<link rel="manifest" href="
|
449 |
-
<link rel="apple-touch-icon" href="
|
450 |
""")
|
451 |
-
|
452 |
gr.HTML("""
|
453 |
<script>
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
468 |
</script>
|
469 |
""")
|
470 |
|
|
|
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 |
+
<link rel="manifest" href="./manifest.json">
|
449 |
+
<link rel="apple-touch-icon" href="./assets/icon-192.png">
|
450 |
""")
|
451 |
+
|
452 |
gr.HTML("""
|
453 |
<script>
|
454 |
+
// 等待頁面完全載入後再註冊 Service Worker
|
455 |
+
document.addEventListener('DOMContentLoaded', function() {
|
456 |
+
// 確認瀏覽器支援 Service Worker
|
457 |
+
if ('serviceWorker' in navigator) {
|
458 |
+
// 使用相對路徑註冊 Service Worker
|
459 |
+
try {
|
460 |
+
navigator.serviceWorker.register('./service-worker.js', {
|
461 |
+
scope: './'
|
462 |
+
}).then(function(registration) {
|
463 |
+
console.log('Service Worker 註冊成功,範圍:', registration.scope);
|
464 |
+
}).catch(function(error) {
|
465 |
+
console.error('Service Worker 註冊失敗:', error.message);
|
466 |
+
});
|
467 |
+
} catch(e) {
|
468 |
+
console.error('Service Worker 註冊時發生錯誤:', e.message);
|
469 |
+
}
|
470 |
+
} else {
|
471 |
+
console.log('此瀏覽器不支援 Service Worker');
|
472 |
+
}
|
473 |
+
});
|
474 |
</script>
|
475 |
""")
|
476 |
|