Update app.py
Browse files
app.py
CHANGED
|
@@ -133,8 +133,23 @@ def check_login(user, password):
|
|
| 133 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 134 |
}
|
| 135 |
|
| 136 |
-
# ---
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
# 1. 登入介面
|
| 140 |
with gr.Group(visible=True) as login_row:
|
|
@@ -143,13 +158,13 @@ with gr.Blocks(title="Admin") as demo:
|
|
| 143 |
username_input = gr.Textbox(label="帳號 Username", placeholder="Enter username")
|
| 144 |
password_input = gr.Textbox(label="密碼 Password", type="password", placeholder="Enter password")
|
| 145 |
login_btn = gr.Button("登入 Login", variant="primary")
|
| 146 |
-
# ✅ 修正:移除 style 參數,避免報錯
|
| 147 |
error_msg = gr.Markdown("")
|
| 148 |
|
| 149 |
# 2. 後台介面
|
| 150 |
with gr.Group(visible=False) as admin_row:
|
| 151 |
gr.Markdown("# 🍷 訂位管理後台 (Dashboard)")
|
| 152 |
refresh_btn = gr.Button("🔄 重新整理")
|
|
|
|
| 153 |
booking_table = gr.Dataframe(interactive=False)
|
| 154 |
with gr.Row():
|
| 155 |
id_input = gr.Number(label="訂單 ID", precision=0)
|
|
|
|
| 133 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 134 |
}
|
| 135 |
|
| 136 |
+
# --- 🔥 新增 CSS:強制表格寬度與捲軸 ---
|
| 137 |
+
# 這段 CSS 會讓表格內容不換行,並在手機上出現水平捲軸
|
| 138 |
+
custom_css = """
|
| 139 |
+
table {
|
| 140 |
+
min-width: 1200px !important;
|
| 141 |
+
}
|
| 142 |
+
td, th {
|
| 143 |
+
white-space: nowrap !important;
|
| 144 |
+
padding: 8px !important;
|
| 145 |
+
}
|
| 146 |
+
.table-wrap {
|
| 147 |
+
overflow-x: auto !important;
|
| 148 |
+
}
|
| 149 |
+
"""
|
| 150 |
+
|
| 151 |
+
# --- 介面開始 (加入 css 參數) ---
|
| 152 |
+
with gr.Blocks(title="Admin", css=custom_css) as demo:
|
| 153 |
|
| 154 |
# 1. 登入介面
|
| 155 |
with gr.Group(visible=True) as login_row:
|
|
|
|
| 158 |
username_input = gr.Textbox(label="帳號 Username", placeholder="Enter username")
|
| 159 |
password_input = gr.Textbox(label="密碼 Password", type="password", placeholder="Enter password")
|
| 160 |
login_btn = gr.Button("登入 Login", variant="primary")
|
|
|
|
| 161 |
error_msg = gr.Markdown("")
|
| 162 |
|
| 163 |
# 2. 後台介面
|
| 164 |
with gr.Group(visible=False) as admin_row:
|
| 165 |
gr.Markdown("# 🍷 訂位管理後台 (Dashboard)")
|
| 166 |
refresh_btn = gr.Button("🔄 重新整理")
|
| 167 |
+
# 表格這裡會自動套用上面的 CSS
|
| 168 |
booking_table = gr.Dataframe(interactive=False)
|
| 169 |
with gr.Row():
|
| 170 |
id_input = gr.Number(label="訂單 ID", precision=0)
|