DawnC commited on
Commit
ae4b3dc
·
1 Parent(s): f560d9c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -29
app.py CHANGED
@@ -441,41 +441,31 @@ def show_details_html(choice, previous_output, initial_state):
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-status-bar-style" content="black">
448
- <link rel="manifest" href="./manifest.json">
449
- <link rel="apple-touch-icon" href="./assets/icon-192.png">
450
- """)
451
-
452
- gr.HTML("""
453
  <script>
454
- // 等待頁面完全載入後再註冊 Service Worker
455
- document.addEventListener('DOMContentLoaded', function() {
456
- // 確認瀏覽器支援 Service Worker
457
- if ('serviceWorker' in navigator) {
458
- // 使用相對路徑註冊 Service Worker
459
- try {
460
- navigator.serviceWorker.register('./service-worker.js', {
461
- scope: './'
462
- }).then(function(registration) {
463
- console.log('Service Worker 註冊成功,範圍:', registration.scope);
464
- }).catch(function(error) {
465
- console.error('Service Worker 註冊失敗:', error.message);
466
- });
467
- } catch(e) {
468
- console.error('Service Worker 註冊時發生錯誤:', e.message);
469
- }
470
- } else {
471
- console.log('此瀏覽器不支援 Service Worker');
472
- }
473
- });
474
  </script>
475
- """)
476
-
477
- # Header HTML
478
- gr.HTML("""
479
  <header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
480
  <h1 style='font-size: 2.5em; margin-bottom: 10px; color: #2D3748;'>
481
  🐾 PawMatch AI
 
441
  def main():
442
  with gr.Blocks(css=get_css_styles()) as iface:
443
 
444
+ # Header HTML
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="https://dawnc-pawmatchai.hf.space/manifest.json">
451
+ <link rel="apple-touch-icon" href="https://dawnc-pawmatchai.hf.space/assets/icon-192.png">
452
+
 
453
  <script>
454
+ window.addEventListener('load', async () => {{
455
+ try {{
456
+ if ('serviceWorker' in navigator) {{
457
+ const registration = await navigator.serviceWorker.register(
458
+ 'https://dawnc-pawmatchai.hf.space/service-worker.js',
459
+ {{ scope: '/' }}
460
+ );
461
+ console.log('Service Worker 註冊成功', registration);
462
+ }}
463
+ }} catch (error) {{
464
+ console.error('Service Worker 註冊失敗:', error);
465
+ }}
466
+ }});
 
 
 
 
 
 
 
467
  </script>
468
+
 
 
 
469
  <header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
470
  <h1 style='font-size: 2.5em; margin-bottom: 10px; color: #2D3748;'>
471
  🐾 PawMatch AI