Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -439,33 +439,33 @@ def show_details_html(choice, previous_output, initial_state):
|
|
439 |
return format_hint_html(error_msg), gr.update(visible=True), initial_state
|
440 |
|
441 |
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 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
// 首先檢查 Gradio 是否正確載入
|
451 |
-
window.addEventListener('DOMContentLoaded', function() {
|
452 |
-
console.log('Gradio 初始化開始');
|
453 |
-
});
|
454 |
-
</script>
|
455 |
-
""")
|
456 |
-
|
457 |
-
# 3. 只有在確認 Gradio 正常後,才添加 PWA 功能
|
458 |
-
gr.HTML("""
|
459 |
<script>
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
</script>
|
470 |
""")
|
471 |
|
|
|
439 |
return format_hint_html(error_msg), gr.update(visible=True), initial_state
|
440 |
|
441 |
def main():
|
442 |
+
with gr.Blocks(css=get_css_styles()) as iface:
|
443 |
+
|
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 |
+
(function() {
|
453 |
+
// 等待 DOM 完全載入
|
454 |
+
document.addEventListener('DOMContentLoaded', function() {
|
455 |
+
// 延遲 Service Worker 註冊,等待 Gradio 完成初始化
|
456 |
+
setTimeout(function() {
|
457 |
+
if ('serviceWorker' in navigator) {
|
458 |
+
navigator.serviceWorker.register('service-worker.js')
|
459 |
+
.then(function(registration) {
|
460 |
+
console.log('Service Worker 註冊成功:', registration.scope);
|
461 |
+
})
|
462 |
+
.catch(function(error) {
|
463 |
+
console.error('Service Worker 註冊失敗:', error);
|
464 |
+
});
|
465 |
+
}
|
466 |
+
}, 2000);
|
467 |
+
});
|
468 |
+
})();
|
469 |
</script>
|
470 |
""")
|
471 |
|