DawnC commited on
Commit
a7bc3f9
·
1 Parent(s): bc353ab

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -19
app.py CHANGED
@@ -439,31 +439,29 @@ 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
- # 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="manifest.json">
450
- <link rel="apple-touch-icon" href="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
- '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;'>
469
  🐾 PawMatch AI
 
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
  <meta name="apple-mobile-web-app-capable" content="yes">
446
+ """)
447
+
448
+ # 第二步:加入 manifest
449
+ gr.HTML("""
450
  <link rel="manifest" href="manifest.json">
451
+ """)
452
+
453
+ # 第三步:最後加入 Service Worker
454
+ gr.HTML(f"""
455
  <script>
456
+ if ('serviceWorker' in navigator) {{
457
+ navigator.serviceWorker.register('service-worker.js')
458
+ .then(registration => console.log('成功'))
459
+ .catch(error => console.error('失敗:', error));
460
+ }}
 
 
 
 
 
 
 
 
461
  </script>
462
+ """)
463
+ # Header HTML
464
+ gr.HTML("""
465
  <header style='text-align: center; padding: 20px; margin-bottom: 20px;'>
466
  <h1 style='font-size: 2.5em; margin-bottom: 10px; color: #2D3748;'>
467
  🐾 PawMatch AI