DawnC commited on
Commit
4ba0d95
·
1 Parent(s): b4bec37

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -25
app.py CHANGED
@@ -441,38 +441,28 @@ def show_details_html(choice, previous_output, initial_state):
441
  def main():
442
  with gr.Blocks(css=get_css_styles()) as iface:
443
  # Header HTML
444
-
445
  gr.HTML("""
446
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
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>
477
  <header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
478
  <h1 style='font-size: 2.5em; margin-bottom: 10px; color: #2D3748;'>
 
441
  def main():
442
  with gr.Blocks(css=get_css_styles()) as iface:
443
  # Header HTML
 
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-status-bar-style" content="black">
448
  <meta name="apple-mobile-web-app-title" content="PawMatch AI">
449
+ <link rel="manifest" href="https://dawnc-pawmatchai.hf.space/manifest.json">
450
+ <link rel="apple-touch-icon" href="https://dawnc-pawmatchai.hf.space/assets/icon-192.png">
451
 
452
  <script>
453
+ window.addEventListener('load', async () => {{
454
+ try {{
455
+ if ('serviceWorker' in navigator) {{
456
+ const registration = await navigator.serviceWorker.register(
457
+ 'https://dawnc-pawmatchai.hf.space/service-worker.js',
458
+ {{ scope: '/' }}
459
+ );
460
+ console.log('Service Worker 註冊成功', registration);
461
+ }}
462
+ }} catch (error) {{
463
+ console.error('Service Worker 註冊失敗:', error);
464
+ }}
465
+ }});
 
 
 
 
 
 
 
 
 
466
  </script>
467
  <header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
468
  <h1 style='font-size: 2.5em; margin-bottom: 10px; color: #2D3748;'>