Update app.py
Browse files
app.py
CHANGED
|
@@ -13,6 +13,7 @@ SUPABASE_URL = os.getenv("SUPABASE_URL")
|
|
| 13 |
SUPABASE_KEY = os.getenv("SUPABASE_KEY")
|
| 14 |
GAS_MAIL_URL = os.getenv("GAS_MAIL_URL")
|
| 15 |
LINE_ACCESS_TOKEN = os.getenv("LINE_ACCESS_TOKEN")
|
|
|
|
| 16 |
PUBLIC_SPACE_URL = "https://deeplearning101-ciecietaipei.hf.space"
|
| 17 |
|
| 18 |
# 取得帳密
|
|
@@ -131,30 +132,39 @@ def check_login(user, password):
|
|
| 131 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 132 |
}
|
| 133 |
|
| 134 |
-
# --- 🔥 [
|
| 135 |
custom_css = """
|
| 136 |
-
/* 1. 外層容器
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
overflow-x: auto !important;
|
|
|
|
| 139 |
display: block !important;
|
| 140 |
}
|
| 141 |
|
| 142 |
-
/*
|
| 143 |
table {
|
| 144 |
display: table !important;
|
| 145 |
-
table-layout: fixed !important;
|
| 146 |
width: auto !important;
|
| 147 |
border-collapse: collapse !important;
|
| 148 |
margin: 0 !important;
|
| 149 |
}
|
| 150 |
|
| 151 |
-
/*
|
| 152 |
th, td {
|
| 153 |
display: table-cell !important;
|
| 154 |
-
white-space: normal !important;
|
| 155 |
-
word-break: break-word !important;
|
| 156 |
-
vertical-align: top !important;
|
| 157 |
-
|
| 158 |
box-sizing: border-box !important;
|
| 159 |
padding: 8px 10px !important;
|
| 160 |
border: 1px solid #444 !important;
|
|
@@ -162,38 +172,17 @@ th, td {
|
|
| 162 |
line-height: 1.4 !important;
|
| 163 |
}
|
| 164 |
|
| 165 |
-
/*
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
th:nth-child(
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
th:nth-child(
|
| 172 |
-
|
| 173 |
-
/* #3 time: 時間 (19:30) */
|
| 174 |
-
th:nth-child(3), td:nth-child(3) { min-width: 80px !important; width: 80px !important; }
|
| 175 |
-
|
| 176 |
-
/* #4 name: 姓名 */
|
| 177 |
-
th:nth-child(4), td:nth-child(4) { min-width: 120px !important; width: 120px !important; }
|
| 178 |
-
|
| 179 |
-
/* #5 tel: 電話 */
|
| 180 |
-
th:nth-child(5), td:nth-child(5) { min-width: 120px !important; width: 120px !important; }
|
| 181 |
-
|
| 182 |
-
/* #6 email: 電子信箱 (很長,給寬一點) */
|
| 183 |
-
th:nth-child(6), td:nth-child(6) { min-width: 250px !important; width: 250px !important; }
|
| 184 |
-
|
| 185 |
-
/* #7 pax: 人數 (短) */
|
| 186 |
th:nth-child(7), td:nth-child(7) { min-width: 50px !important; width: 50px !important; }
|
| 187 |
-
|
| 188 |
-
/* #8 remarks: 備註 (文字多,給寬一點) */
|
| 189 |
th:nth-child(8), td:nth-child(8) { min-width: 180px !important; width: 180px !important; }
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
th:nth-child(9), td:nth-child(9) { min-width: 120px !important; width: 120px !important; }
|
| 193 |
-
|
| 194 |
-
/* #10 user_id: 亂碼 (非常長,給寬一點,反正會換行) */
|
| 195 |
-
th:nth-child(10), td:nth-child(10) { min-width: 280px !important; width: 320px !important; }
|
| 196 |
-
|
| 197 |
"""
|
| 198 |
|
| 199 |
# --- 介面開始 (加入 css 參數) ---
|
|
@@ -212,8 +201,10 @@ with gr.Blocks(title="Admin", css=custom_css) as demo:
|
|
| 212 |
with gr.Group(visible=False) as admin_row:
|
| 213 |
gr.Markdown("# 🍷 訂位管理後台 (Dashboard)")
|
| 214 |
refresh_btn = gr.Button("🔄 重新整理")
|
| 215 |
-
|
| 216 |
-
|
|
|
|
|
|
|
| 217 |
with gr.Row():
|
| 218 |
id_input = gr.Number(label="訂單 ID", precision=0)
|
| 219 |
action_btn = gr.Button("📧 發送確認信 (Hybrid)", variant="primary")
|
|
|
|
| 13 |
SUPABASE_KEY = os.getenv("SUPABASE_KEY")
|
| 14 |
GAS_MAIL_URL = os.getenv("GAS_MAIL_URL")
|
| 15 |
LINE_ACCESS_TOKEN = os.getenv("LINE_ACCESS_TOKEN")
|
| 16 |
+
# ⚠️ 請確認這是您 Space A 的正確網址 (結尾不要有斜線)
|
| 17 |
PUBLIC_SPACE_URL = "https://deeplearning101-ciecietaipei.hf.space"
|
| 18 |
|
| 19 |
# 取得帳密
|
|
|
|
| 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;
|
|
|
|
| 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 參數) ---
|
|
|
|
| 201 |
with gr.Group(visible=False) as admin_row:
|
| 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():
|
| 209 |
id_input = gr.Number(label="訂單 ID", precision=0)
|
| 210 |
action_btn = gr.Button("📧 發送確認信 (Hybrid)", variant="primary")
|