Update app.py
Browse files
app.py
CHANGED
|
@@ -13,10 +13,9 @@ 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 |
-
# ⚠️ 請確認這是您 Space A 的正確網址 (結尾不要有斜線)
|
| 17 |
PUBLIC_SPACE_URL = "https://deeplearning101-ciecietaipei.hf.space"
|
| 18 |
|
| 19 |
-
# 取得帳密
|
| 20 |
REAL_ADMIN_USER = os.getenv("ADMIN_USER") or "Deep Learning 101"
|
| 21 |
REAL_ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD") or "2016-11-11"
|
| 22 |
|
|
@@ -119,7 +118,7 @@ def send_confirmation_hybrid(booking_id):
|
|
| 119 |
return log_msg
|
| 120 |
except Exception as e: return f"❌ Error: {str(e)}"
|
| 121 |
|
| 122 |
-
# --- 登入邏輯
|
| 123 |
def check_login(user, password):
|
| 124 |
if user == REAL_ADMIN_USER and password == REAL_ADMIN_PASSWORD:
|
| 125 |
return {
|
|
@@ -128,49 +127,59 @@ def check_login(user, password):
|
|
| 128 |
error_msg: ""
|
| 129 |
}
|
| 130 |
else:
|
| 131 |
-
# ✅ 使用 HTML span 標籤來顯示紅色,而不是在 gr.Markdown 用 style 參數
|
| 132 |
return {
|
| 133 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 134 |
}
|
| 135 |
|
| 136 |
-
# --- 🔥 [
|
| 137 |
custom_css = """
|
| 138 |
-
/* 1.
|
| 139 |
-
div[
|
| 140 |
overflow-x: auto !important;
|
| 141 |
-
max-width: 100vw !important; /* 確保容器本身不超過螢幕寬 */
|
| 142 |
display: block !important;
|
| 143 |
}
|
| 144 |
-
|
| 145 |
-
/* 2. 表格本體:
|
| 146 |
-
min-width: max-content 是關鍵!
|
| 147 |
-
它告訴瀏覽器:表格的最小寬度 = 內容完全展開後的總長度。
|
| 148 |
-
這會迫使外層容器產生捲軸,而不是壓縮表格。
|
| 149 |
-
*/
|
| 150 |
table {
|
| 151 |
-
|
| 152 |
-
|
|
|
|
| 153 |
border-collapse: collapse !important;
|
|
|
|
| 154 |
}
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
white-space:
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
/* 移除寬度限制,讓內容自己決定要多寬 */
|
| 163 |
-
max-width: none !important;
|
| 164 |
-
width: auto !important;
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
white-space: nowrap !important;
|
| 172 |
-
overflow: visible !important;
|
| 173 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
"""
|
| 175 |
|
| 176 |
# --- 介面開始 (加入 css 參數) ---
|
|
|
|
| 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 |
+
# 取得帳密
|
| 19 |
REAL_ADMIN_USER = os.getenv("ADMIN_USER") or "Deep Learning 101"
|
| 20 |
REAL_ADMIN_PASSWORD = os.getenv("ADMIN_PASSWORD") or "2016-11-11"
|
| 21 |
|
|
|
|
| 118 |
return log_msg
|
| 119 |
except Exception as e: return f"❌ Error: {str(e)}"
|
| 120 |
|
| 121 |
+
# --- 登入邏輯 ---
|
| 122 |
def check_login(user, password):
|
| 123 |
if user == REAL_ADMIN_USER and password == REAL_ADMIN_PASSWORD:
|
| 124 |
return {
|
|
|
|
| 127 |
error_msg: ""
|
| 128 |
}
|
| 129 |
else:
|
|
|
|
| 130 |
return {
|
| 131 |
error_msg: "<span style='color: red'>❌ 帳號或密碼錯誤</span>"
|
| 132 |
}
|
| 133 |
|
| 134 |
+
# --- 🔥 [客製化 CSS]:針對每個欄位設定寬度 + 允許換行 ---
|
| 135 |
custom_css = """
|
| 136 |
+
/* 1. 外層容器:允許左右滑動 */
|
| 137 |
+
.table-wrap, .wrap, .svelte-12cmxck, div[id^="dataframe"] {
|
| 138 |
overflow-x: auto !important;
|
|
|
|
| 139 |
display: block !important;
|
| 140 |
}
|
| 141 |
+
/* 2. 表格本體 */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
table {
|
| 143 |
+
display: table !important;
|
| 144 |
+
table-layout: fixed !important; /* ⚠️ 關鍵:固定布局,強制生效我們設定的寬度 */
|
| 145 |
+
width: auto !important;
|
| 146 |
border-collapse: collapse !important;
|
| 147 |
+
margin: 0 !important;
|
| 148 |
}
|
| 149 |
+
/* 3. 通用儲存格設定 */
|
| 150 |
+
th, td {
|
| 151 |
+
display: table-cell !important;
|
| 152 |
+
white-space: normal !important; /* ✅ 允許換行 */
|
| 153 |
+
word-break: break-word !important; /* ✅ 長單字(如User ID)強制換行 */
|
| 154 |
+
vertical-align: top !important; /* 對齊上方,換行後比較好看 */
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
+
box-sizing: border-box !important;
|
| 157 |
+
padding: 8px 10px !important;
|
| 158 |
+
border: 1px solid #444 !important;
|
| 159 |
+
font-size: 14px !important;
|
| 160 |
+
line-height: 1.4 !important;
|
|
|
|
|
|
|
| 161 |
}
|
| 162 |
+
/* 4. 🔥【個別欄位寬度設定】(依照您的欄位順序 1~10) */
|
| 163 |
+
/* #1 id: 短數字 */
|
| 164 |
+
th:nth-child(1), td:nth-child(1) { min-width: 60px !important; width: 60px !important; }
|
| 165 |
+
/* #2 date: 日期 (2026-01-23) */
|
| 166 |
+
th:nth-child(2), td:nth-child(2) { min-width: 170px !important; width: 170px !important; }
|
| 167 |
+
/* #3 time: 時間 (19:30) */
|
| 168 |
+
th:nth-child(3), td:nth-child(3) { min-width: 80px !important; width: 80px !important; }
|
| 169 |
+
/* #4 name: 姓名 */
|
| 170 |
+
th:nth-child(4), td:nth-child(4) { min-width: 120px !important; width: 120px !important; }
|
| 171 |
+
/* #5 tel: 電話 */
|
| 172 |
+
th:nth-child(5), td:nth-child(5) { min-width: 120px !important; width: 120px !important; }
|
| 173 |
+
/* #6 email: 電子信箱 (很長,給寬一點) */
|
| 174 |
+
th:nth-child(6), td:nth-child(6) { min-width: 250px !important; width: 250px !important; }
|
| 175 |
+
/* #7 pax: 人數 (短) */
|
| 176 |
+
th:nth-child(7), td:nth-child(7) { min-width: 50px !important; width: 50px !important; }
|
| 177 |
+
/* #8 remarks: 備註 (文字多,給寬一點) */
|
| 178 |
+
th:nth-child(8), td:nth-child(8) { min-width: 180px !important; width: 180px !important; }
|
| 179 |
+
/* #9 status: 狀態 */
|
| 180 |
+
th:nth-child(9), td:nth-child(9) { min-width: 120px !important; width: 120px !important; }
|
| 181 |
+
/* #10 user_id: 亂碼 (非常長,給寬一點,反正會換行) */
|
| 182 |
+
th:nth-child(10), td:nth-child(10) { min-width: 280px !important; width: 320px !important; }
|
| 183 |
"""
|
| 184 |
|
| 185 |
# --- 介面開始 (加入 css 參數) ---
|