Spaces:
Running
Running
feat: Attempt to adapt layout for Hugging Face Spaces
Browse files- app.py +12 -3
- ui/theme.py +3 -0
app.py
CHANGED
|
@@ -209,7 +209,16 @@ class LifeFlowAI:
|
|
| 209 |
# ================= Main UI Builder =================
|
| 210 |
|
| 211 |
def build_interface(self):
|
| 212 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
gr.HTML(get_enhanced_css())
|
| 214 |
|
| 215 |
session_state = gr.State(UserSession().to_dict())
|
|
@@ -366,7 +375,7 @@ class LifeFlowAI:
|
|
| 366 |
def main():
|
| 367 |
app = LifeFlowAI()
|
| 368 |
demo = app.build_interface()
|
| 369 |
-
demo.launch(server_name="0.0.0.0", server_port=
|
| 370 |
-
|
| 371 |
if __name__ == "__main__":
|
| 372 |
main()
|
|
|
|
| 209 |
# ================= Main UI Builder =================
|
| 210 |
|
| 211 |
def build_interface(self):
|
| 212 |
+
container_css = """
|
| 213 |
+
.gradio-container {
|
| 214 |
+
max-width: 100% !important;
|
| 215 |
+
padding: 0;
|
| 216 |
+
height: 100vh !important; /* 1. 關鍵:鎖定高度為視窗大小 */
|
| 217 |
+
overflow-y: auto !important; /* 2. 關鍵:內容過長時,在內部產生捲軸 */
|
| 218 |
+
}
|
| 219 |
+
"""
|
| 220 |
+
|
| 221 |
+
with gr.Blocks(title="LifeFlow AI", css=container_css) as demo:
|
| 222 |
gr.HTML(get_enhanced_css())
|
| 223 |
|
| 224 |
session_state = gr.State(UserSession().to_dict())
|
|
|
|
| 375 |
def main():
|
| 376 |
app = LifeFlowAI()
|
| 377 |
demo = app.build_interface()
|
| 378 |
+
demo.launch(server_name="0.0.0.0", server_port=8080, share=True, show_error=True)
|
| 379 |
+
#7860
|
| 380 |
if __name__ == "__main__":
|
| 381 |
main()
|
ui/theme.py
CHANGED
|
@@ -29,6 +29,9 @@ def get_enhanced_css() -> str:
|
|
| 29 |
body, .gradio-container {
|
| 30 |
font-family: var(--font-main) !important;
|
| 31 |
background: #f8fafc !important;
|
|
|
|
|
|
|
|
|
|
| 32 |
}
|
| 33 |
|
| 34 |
* { box-sizing: border-box; }
|
|
|
|
| 29 |
body, .gradio-container {
|
| 30 |
font-family: var(--font-main) !important;
|
| 31 |
background: #f8fafc !important;
|
| 32 |
+
/* ⭐ 新增以下兩行:強制鎖定高度,解決 HF Space 捲動問題 ⭐ */
|
| 33 |
+
height: 100vh !important; /* 高度限制為視窗大小 */
|
| 34 |
+
overflow-y: auto !important; /* 超出範圍時,在內部產生捲軸 */
|
| 35 |
}
|
| 36 |
|
| 37 |
* { box-sizing: border-box; }
|