Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -442,35 +442,33 @@ def main():
|
|
442 |
with gr.Blocks(css=get_css_styles()) as iface:
|
443 |
gr.HTML("""
|
444 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
445 |
-
<meta name="apple-mobile-web-app-capable" content="yes">
|
446 |
-
<meta name="apple-mobile-web-app-title" content="PawMatch AI">
|
447 |
""")
|
448 |
|
449 |
-
# 2. 分離 PWA 設定,確保不影響 Gradio 的 SSE 連接
|
450 |
gr.HTML("""
|
451 |
<script>
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
}, 2000); // 給予 Gradio 足夠的初始化時間
|
465 |
});
|
466 |
</script>
|
467 |
""")
|
468 |
-
|
469 |
-
# 3. 確保 manifest 的載入不會干擾到 Gradio
|
470 |
gr.HTML("""
|
471 |
<link rel="manifest" href="manifest.json">
|
472 |
<link rel="apple-touch-icon" href="assets/icon-192.png">
|
|
|
|
|
473 |
""")
|
|
|
474 |
# Header HTML
|
475 |
gr.HTML("""
|
476 |
<header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
|
|
|
442 |
with gr.Blocks(css=get_css_styles()) as iface:
|
443 |
gr.HTML("""
|
444 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
445 |
""")
|
446 |
|
|
|
447 |
gr.HTML("""
|
448 |
<script>
|
449 |
+
// 等待 Gradio 完全初始化完成
|
450 |
+
window.addEventListener('gradio-loaded', function() {
|
451 |
+
// 確保不會干擾到 Gradio 的客戶端程式碼
|
452 |
+
if ('serviceWorker' in navigator) {
|
453 |
+
navigator.serviceWorker.register('service-worker.js')
|
454 |
+
.then(function(registration) {
|
455 |
+
console.log('成功註冊 Service Worker');
|
456 |
+
})
|
457 |
+
.catch(function(error) {
|
458 |
+
console.error('註冊失敗:', error);
|
459 |
+
});
|
460 |
+
}
|
|
|
461 |
});
|
462 |
</script>
|
463 |
""")
|
464 |
+
|
|
|
465 |
gr.HTML("""
|
466 |
<link rel="manifest" href="manifest.json">
|
467 |
<link rel="apple-touch-icon" href="assets/icon-192.png">
|
468 |
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
469 |
+
<meta name="apple-mobile-web-app-title" content="PawMatch AI">
|
470 |
""")
|
471 |
+
|
472 |
# Header HTML
|
473 |
gr.HTML("""
|
474 |
<header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
|