Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -444,28 +444,26 @@ def main():
|
|
| 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 |
-
#
|
| 450 |
-
gr.HTML("""
|
| 451 |
-
<link rel="manifest" href="./manifest.json">
|
| 452 |
-
<link rel="apple-touch-icon" href="./assets/icon-192.png">
|
| 453 |
-
""")
|
| 454 |
-
|
| 455 |
-
# 第三層:Service Worker 註冊
|
| 456 |
gr.HTML("""
|
| 457 |
<script>
|
| 458 |
-
|
| 459 |
-
|
| 460 |
-
|
|
|
|
|
|
|
| 461 |
.then(function(registration) {
|
| 462 |
-
console.log('
|
| 463 |
})
|
| 464 |
.catch(function(error) {
|
| 465 |
console.log('Service Worker 註冊失敗:', error);
|
| 466 |
});
|
| 467 |
-
}
|
| 468 |
-
}
|
| 469 |
</script>
|
| 470 |
""")
|
| 471 |
# Header 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 |
+
<link rel="manifest" href="manifest.json">
|
| 448 |
+
<link rel="apple-touch-icon" href="assets/icon-192.png">
|
| 449 |
""")
|
| 450 |
|
| 451 |
+
# 使用獨立的 JavaScript 區塊,避免格式化問題
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
gr.HTML("""
|
| 453 |
<script>
|
| 454 |
+
// 確保代碼在頁面載入後執行
|
| 455 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 456 |
+
// 使用標準的 JavaScript 語法
|
| 457 |
+
if ('serviceWorker' in navigator) {
|
| 458 |
+
navigator.serviceWorker.register('service-worker.js')
|
| 459 |
.then(function(registration) {
|
| 460 |
+
console.log('Service Worker 註冊成功');
|
| 461 |
})
|
| 462 |
.catch(function(error) {
|
| 463 |
console.log('Service Worker 註冊失敗:', error);
|
| 464 |
});
|
| 465 |
+
}
|
| 466 |
+
});
|
| 467 |
</script>
|
| 468 |
""")
|
| 469 |
# Header HTML
|