Update app.py
Browse files
app.py
CHANGED
|
@@ -132,57 +132,58 @@ def check_login(user, password):
|
|
| 132 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 133 |
}
|
| 134 |
|
| 135 |
-
# --- 🔥 [
|
| 136 |
custom_css = """
|
| 137 |
-
/* 1. 隱藏外層
|
| 138 |
#booking_table {
|
| 139 |
-
overflow: hidden !important;
|
| 140 |
-
border: none !important;
|
| 141 |
background: transparent !important;
|
|
|
|
|
|
|
| 142 |
}
|
| 143 |
|
| 144 |
-
/* 2.
|
| 145 |
#booking_table .table-wrap,
|
| 146 |
#booking_table div[class*="table"],
|
| 147 |
-
|
| 148 |
overflow-x: auto !important;
|
| 149 |
overflow-y: hidden !important;
|
| 150 |
display: block !important;
|
| 151 |
}
|
| 152 |
|
| 153 |
-
/* 3. 表格
|
| 154 |
table {
|
| 155 |
display: table !important;
|
| 156 |
table-layout: fixed !important;
|
| 157 |
-
width:
|
| 158 |
border-collapse: collapse !important;
|
| 159 |
margin: 0 !important;
|
| 160 |
}
|
| 161 |
|
| 162 |
-
/* 4. 欄位設定 (
|
| 163 |
th, td {
|
| 164 |
display: table-cell !important;
|
| 165 |
-
white-space:
|
| 166 |
-
|
| 167 |
-
|
|
|
|
| 168 |
box-sizing: border-box !important;
|
| 169 |
padding: 8px 10px !important;
|
| 170 |
border: 1px solid #444 !important;
|
| 171 |
font-size: 14px !important;
|
| 172 |
-
|
| 173 |
}
|
| 174 |
|
| 175 |
-
/* 5.
|
| 176 |
-
th:nth-child(1), td:nth-child(1) {
|
| 177 |
-
th:nth-child(2), td:nth-child(2) {
|
| 178 |
-
th:nth-child(3), td:nth-child(3) {
|
| 179 |
-
th:nth-child(4), td:nth-child(4) {
|
| 180 |
-
th:nth-child(5), td:nth-child(5) {
|
| 181 |
-
th:nth-child(6), td:nth-child(6) {
|
| 182 |
-
th:nth-child(7), td:nth-child(7) {
|
| 183 |
-
th:nth-child(8), td:nth-child(8) {
|
| 184 |
-
th:nth-child(9), td:nth-child(9) {
|
| 185 |
-
th:nth-child(10), td:nth-child(10) {
|
| 186 |
"""
|
| 187 |
|
| 188 |
# --- 介面開始 (加入 css 參數) ---
|
|
@@ -202,7 +203,7 @@ with gr.Blocks(title="Admin", css=custom_css) as demo:
|
|
| 202 |
gr.Markdown("# 🍷 訂位管理後台 (Dashboard)")
|
| 203 |
refresh_btn = gr.Button("🔄 重新整理")
|
| 204 |
|
| 205 |
-
#
|
| 206 |
booking_table = gr.Dataframe(interactive=False, elem_id="booking_table")
|
| 207 |
|
| 208 |
with gr.Row():
|
|
|
|
| 132 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 133 |
}
|
| 134 |
|
| 135 |
+
# --- 🔥 [絕對強制 CSS]:死都不換行 + 強制撐開 + 單一捲軸 ---
|
| 136 |
custom_css = """
|
| 137 |
+
/* 1. 隱藏外層多餘捲軸 */
|
| 138 |
#booking_table {
|
|
|
|
|
|
|
| 139 |
background: transparent !important;
|
| 140 |
+
border: none !important;
|
| 141 |
+
padding: 0 !important;
|
| 142 |
}
|
| 143 |
|
| 144 |
+
/* 2. 核心捲動容器:強制顯示水平捲軸 */
|
| 145 |
#booking_table .table-wrap,
|
| 146 |
#booking_table div[class*="table"],
|
| 147 |
+
div[data-testid="dataframe"] > div {
|
| 148 |
overflow-x: auto !important;
|
| 149 |
overflow-y: hidden !important;
|
| 150 |
display: block !important;
|
| 151 |
}
|
| 152 |
|
| 153 |
+
/* 3. 表格設定:max-content 是關鍵,它會強迫表格寬度 = 內容總寬度 */
|
| 154 |
table {
|
| 155 |
display: table !important;
|
| 156 |
table-layout: fixed !important;
|
| 157 |
+
width: max-content !important; /* 👈 這是關鍵:強制撐開,不要擠在螢幕裡 */
|
| 158 |
border-collapse: collapse !important;
|
| 159 |
margin: 0 !important;
|
| 160 |
}
|
| 161 |
|
| 162 |
+
/* 4. 欄位設定:NO WRAPPING (不換行) */
|
| 163 |
th, td {
|
| 164 |
display: table-cell !important;
|
| 165 |
+
white-space: nowrap !important; /* 👈 絕對禁止換行 */
|
| 166 |
+
overflow: hidden !important;
|
| 167 |
+
text-overflow: ellipsis !important;
|
| 168 |
+
|
| 169 |
box-sizing: border-box !important;
|
| 170 |
padding: 8px 10px !important;
|
| 171 |
border: 1px solid #444 !important;
|
| 172 |
font-size: 14px !important;
|
| 173 |
+
vertical-align: middle !important;
|
| 174 |
}
|
| 175 |
|
| 176 |
+
/* 5. 指定欄位寬度 (依照您的需求) */
|
| 177 |
+
th:nth-child(1), td:nth-child(1) { width: 60px !important; } /* ID */
|
| 178 |
+
th:nth-child(2), td:nth-child(2) { width: 170px !important; } /* Date */
|
| 179 |
+
th:nth-child(3), td:nth-child(3) { width: 80px !important; } /* Time */
|
| 180 |
+
th:nth-child(4), td:nth-child(4) { width: 120px !important; } /* Name */
|
| 181 |
+
th:nth-child(5), td:nth-child(5) { width: 120px !important; } /* Tel */
|
| 182 |
+
th:nth-child(6), td:nth-child(6) { width: 250px !important; } /* Email (長) */
|
| 183 |
+
th:nth-child(7), td:nth-child(7) { width: 50px !important; } /* Pax */
|
| 184 |
+
th:nth-child(8), td:nth-child(8) { width: 180px !important; } /* Remarks */
|
| 185 |
+
th:nth-child(9), td:nth-child(9) { width: 12px !important; } /* Status */
|
| 186 |
+
th:nth-child(10), td:nth-child(10) { width: 280px !important; } /* UserID */
|
| 187 |
"""
|
| 188 |
|
| 189 |
# --- 介面開始 (加入 css 參數) ---
|
|
|
|
| 203 |
gr.Markdown("# 🍷 訂位管理後台 (Dashboard)")
|
| 204 |
refresh_btn = gr.Button("🔄 重新整理")
|
| 205 |
|
| 206 |
+
# ✅ 保持 elem_id 以便 CSS 抓取
|
| 207 |
booking_table = gr.Dataframe(interactive=False, elem_id="booking_table")
|
| 208 |
|
| 209 |
with gr.Row():
|