DeepLearning101 commited on
Commit
eb8d0e1
·
verified ·
1 Parent(s): 7665778

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -25
app.py CHANGED
@@ -132,57 +132,58 @@ def check_login(user, password):
132
  error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
133
  }
134
 
135
- # --- 🔥 [修復雙重捲軸 CSS]:隱藏外層,只留內層 ---
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
- #booking_table .tbody-wrap {
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: auto !important;
158
  border-collapse: collapse !important;
159
  margin: 0 !important;
160
  }
161
 
162
- /* 4. 欄位設定 (維持您滿意的定寬) */
163
  th, td {
164
  display: table-cell !important;
165
- white-space: normal !important;
166
- word-break: break-word !important;
167
- vertical-align: top !important;
 
168
  box-sizing: border-box !important;
169
  padding: 8px 10px !important;
170
  border: 1px solid #444 !important;
171
  font-size: 14px !important;
172
- line-height: 1.4 !important;
173
  }
174
 
175
- /* 5. 個別欄位寬度 (維持滿意寬度) */
176
- th:nth-child(1), td:nth-child(1) { min-width: 50px !important; width: 50px !important; }
177
- th:nth-child(2), td:nth-child(2) { min-width: 110px !important; width: 110px !important; }
178
- th:nth-child(3), td:nth-child(3) { min-width: 70px !important; width: 70px !important; }
179
- th:nth-child(4), td:nth-child(4) { min-width: 90px !important; width: 90px !important; }
180
- th:nth-child(5), td:nth-child(5) { min-width: 110px !important; width: 110px !important; }
181
- th:nth-child(6), td:nth-child(6) { min-width: 200px !important; width: 200px !important; }
182
- th:nth-child(7), td:nth-child(7) { min-width: 50px !important; width: 50px !important; }
183
- th:nth-child(8), td:nth-child(8) { min-width: 180px !important; width: 180px !important; }
184
- th:nth-child(9), td:nth-child(9) { min-width: 90px !important; width: 90px !important; }
185
- th:nth-child(10), td:nth-child(10) { min-width: 180px !important; width: 180px !important; }
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
- # 🔥🔥🔥 關鍵:加入 elem_id="booking_table" CSS 可以精準到它 🔥🔥🔥
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():