Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -447,21 +447,30 @@ def main():
|
|
447 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
448 |
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
449 |
<meta name="apple-mobile-web-app-title" content="PawMatch AI">
|
450 |
-
<link rel="manifest" href="
|
451 |
-
<link rel="apple-touch-icon" href="
|
452 |
|
453 |
<script>
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
465 |
}
|
466 |
});
|
467 |
</script>
|
|
|
447 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
448 |
<meta name="apple-mobile-web-app-status-bar-style" content="black">
|
449 |
<meta name="apple-mobile-web-app-title" content="PawMatch AI">
|
450 |
+
<link rel="manifest" href="manifest.json">
|
451 |
+
<link rel="apple-touch-icon" href="assets/icon-192.png">
|
452 |
|
453 |
<script>
|
454 |
+
// 等待所有資源載入完成
|
455 |
+
window.addEventListener('load', function() {
|
456 |
+
// 檢查瀏覽器是否支援 Service Worker
|
457 |
+
if ('serviceWorker' in navigator) {
|
458 |
+
// 使用 async/await 處理 Promise
|
459 |
+
(async () => {
|
460 |
+
try {
|
461 |
+
// 嘗試註冊 Service Worker
|
462 |
+
const registration = await navigator.serviceWorker.register('service-worker.js');
|
463 |
+
console.log('Service Worker 註冊成功!', registration.scope);
|
464 |
+
} catch (error) {
|
465 |
+
// 如果發生錯誤,記錄詳細資訊
|
466 |
+
console.error('Service Worker 註冊失敗:', error);
|
467 |
+
// 顯示更多診斷資訊
|
468 |
+
console.log('當前網址:', window.location.href);
|
469 |
+
console.log('Service Worker 支援狀態:', 'serviceWorker' in navigator);
|
470 |
+
}
|
471 |
+
})();
|
472 |
+
} else {
|
473 |
+
console.log('此瀏覽器不支援 Service Worker');
|
474 |
}
|
475 |
});
|
476 |
</script>
|