Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -438,31 +438,45 @@ def show_details_html(choice, previous_output, initial_state):
|
|
438 |
print(error_msg)
|
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 |
|
444 |
-
gr.HTML(
|
445 |
-
<meta charset="UTF-8">
|
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="theme-color" content="#4299e1">
|
450 |
-
<link rel="manifest" href="/manifest.json">
|
451 |
-
<link rel="apple-touch-icon" href="/assets/icon-192.png">
|
452 |
-
<script>
|
453 |
-
if ('serviceWorker' in navigator) {
|
454 |
-
window.addEventListener('load', () => {
|
455 |
-
navigator.serviceWorker.register('/service-worker.js')
|
456 |
-
.then((registration) => {
|
457 |
-
console.log('ServiceWorker 註冊成功');
|
458 |
-
})
|
459 |
-
.catch((error) => {
|
460 |
-
console.error('ServiceWorker 註冊失敗:', error);
|
461 |
-
});
|
462 |
-
});
|
463 |
-
}
|
464 |
-
</script>
|
465 |
-
""")
|
466 |
|
467 |
# Header HTML
|
468 |
gr.HTML("""
|
|
|
438 |
print(error_msg)
|
439 |
return format_hint_html(error_msg), gr.update(visible=True), initial_state
|
440 |
|
441 |
+
|
442 |
+
def get_pwa_html():
|
443 |
+
return """
|
444 |
+
<!DOCTYPE html>
|
445 |
+
<meta charset="UTF-8">
|
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="theme-color" content="#4299e1">
|
450 |
+
<link rel="manifest" href="manifest.json">
|
451 |
+
<link rel="apple-touch-icon" href="assets/icon-192.png">
|
452 |
+
|
453 |
+
<script>
|
454 |
+
// 簡化的 Service Worker 註冊
|
455 |
+
document.addEventListener('DOMContentLoaded', function() {
|
456 |
+
if ('serviceWorker' in navigator) {
|
457 |
+
const swURL = new URL(
|
458 |
+
'service-worker.js',
|
459 |
+
window.location.origin + window.location.pathname
|
460 |
+
).href;
|
461 |
+
|
462 |
+
navigator.serviceWorker.register(swURL)
|
463 |
+
.then(function(registration) {
|
464 |
+
console.log('Service Worker 註冊成功,範圍:',
|
465 |
+
registration.scope);
|
466 |
+
})
|
467 |
+
.catch(function(error) {
|
468 |
+
console.log('Service Worker 註冊過程中發生錯誤:',
|
469 |
+
error.message);
|
470 |
+
});
|
471 |
+
}
|
472 |
+
});
|
473 |
+
</script>
|
474 |
+
"""
|
475 |
+
|
476 |
def main():
|
477 |
with gr.Blocks(css=get_css_styles()) as iface:
|
478 |
|
479 |
+
gr.HTML(get_pwa_html())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
|
481 |
# Header HTML
|
482 |
gr.HTML("""
|