Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -439,58 +439,58 @@ def show_details_html(choice, previous_output, initial_state):
|
|
| 439 |
|
| 440 |
|
| 441 |
def get_pwa_html():
|
| 442 |
-
|
| 443 |
-
|
| 444 |
-
|
| 445 |
-
"
|
| 446 |
-
"
|
| 447 |
-
"
|
| 448 |
-
"
|
| 449 |
-
"
|
| 450 |
-
"
|
| 451 |
-
|
| 452 |
-
|
| 453 |
-
|
| 454 |
-
|
| 455 |
-
|
| 456 |
-
|
| 457 |
-
|
| 458 |
|
| 459 |
-
|
|
|
|
| 460 |
<!DOCTYPE html>
|
| 461 |
<meta charset="UTF-8">
|
| 462 |
-
<meta name="viewport" content="width=device-width, initial-scale=1.0
|
| 463 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
| 464 |
-
<meta name="apple-mobile-web-app-status-bar-style" content="default">
|
| 465 |
<meta name="theme-color" content="#4299e1">
|
|
|
|
| 466 |
|
| 467 |
-
|
| 468 |
-
|
| 469 |
-
</script>
|
| 470 |
-
|
| 471 |
<script>
|
| 472 |
-
|
| 473 |
-
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
|
| 477 |
-
|
| 478 |
-
|
| 479 |
-
|
| 480 |
-
document.head.appendChild(manifestLink);
|
| 481 |
-
}} catch (error) {{
|
| 482 |
-
console.error('Manifest registration error:', error);
|
| 483 |
-
}}
|
| 484 |
-
}});
|
| 485 |
</script>
|
|
|
|
| 486 |
|
|
|
|
|
|
|
| 487 |
<style>
|
| 488 |
-
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
|
|
|
|
| 492 |
</style>
|
| 493 |
-
|
|
|
|
|
|
|
| 494 |
|
| 495 |
def main():
|
| 496 |
with gr.Blocks(css=get_css_styles()) as iface:
|
|
|
|
| 439 |
|
| 440 |
|
| 441 |
def get_pwa_html():
|
| 442 |
+
# 先定義基本的 manifest 內容,使用最簡單的字串連接方式
|
| 443 |
+
manifest = (
|
| 444 |
+
'{'
|
| 445 |
+
'"name": "PawMatch AI",'
|
| 446 |
+
'"short_name": "PawMatch",'
|
| 447 |
+
'"start_url": "/index.html",'
|
| 448 |
+
'"display": "standalone",'
|
| 449 |
+
'"background_color": "#ffffff",'
|
| 450 |
+
'"theme_color": "#4299e1",'
|
| 451 |
+
'"icons": [{'
|
| 452 |
+
' "src": "/icon-192.png",'
|
| 453 |
+
' "sizes": "192x192",'
|
| 454 |
+
' "type": "image/png"'
|
| 455 |
+
'}]'
|
| 456 |
+
'}'
|
| 457 |
+
)
|
| 458 |
|
| 459 |
+
# 構建 HTML,避免使用複雜的格式化
|
| 460 |
+
html = '''
|
| 461 |
<!DOCTYPE html>
|
| 462 |
<meta charset="UTF-8">
|
| 463 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 464 |
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
|
|
| 465 |
<meta name="theme-color" content="#4299e1">
|
| 466 |
+
'''
|
| 467 |
|
| 468 |
+
# 添加 manifest 相關代碼
|
| 469 |
+
html += f'''
|
|
|
|
|
|
|
| 470 |
<script>
|
| 471 |
+
window.addEventListener('load', function() {{
|
| 472 |
+
var manifest = {manifest};
|
| 473 |
+
var blob = new Blob([JSON.stringify(manifest)], {{type: 'application/json'}});
|
| 474 |
+
var link = document.createElement('link');
|
| 475 |
+
link.rel = 'manifest';
|
| 476 |
+
link.href = URL.createObjectURL(blob);
|
| 477 |
+
document.head.appendChild(link);
|
| 478 |
+
}});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 479 |
</script>
|
| 480 |
+
'''
|
| 481 |
|
| 482 |
+
# 添加基本樣式
|
| 483 |
+
html += '''
|
| 484 |
<style>
|
| 485 |
+
body {
|
| 486 |
+
margin: 0;
|
| 487 |
+
padding: 0;
|
| 488 |
+
-webkit-overflow-scrolling: touch;
|
| 489 |
+
}
|
| 490 |
</style>
|
| 491 |
+
'''
|
| 492 |
+
|
| 493 |
+
return html
|
| 494 |
|
| 495 |
def main():
|
| 496 |
with gr.Blocks(css=get_css_styles()) as iface:
|