Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,59 +3,57 @@ import gradio as gr
|
|
| 3 |
from core.visits import get_and_update_visits
|
| 4 |
from ui.layouts import create_ui
|
| 5 |
|
| 6 |
-
# ---
|
| 7 |
professional_theme = gr.themes.Soft(
|
| 8 |
-
#
|
| 9 |
font=gr.themes.GoogleFont("Noto Sans TC"),
|
| 10 |
|
| 11 |
-
#
|
| 12 |
primary_hue=gr.themes.colors.teal,
|
| 13 |
secondary_hue=gr.themes.colors.cyan,
|
| 14 |
neutral_hue="slate",
|
| 15 |
|
| 16 |
-
#
|
| 17 |
radius_size=gr.themes.sizes.radius_md,
|
| 18 |
spacing_size=gr.themes.sizes.spacing_md,
|
| 19 |
|
| 20 |
).set(
|
| 21 |
-
# ===
|
| 22 |
body_background_fill="#f8f9fa",
|
| 23 |
panel_background_fill="#f8f9fa",
|
| 24 |
|
| 25 |
-
# ===
|
| 26 |
block_background_fill="white",
|
| 27 |
block_border_width="0px",
|
| 28 |
block_border_color="transparent",
|
| 29 |
block_radius="16px",
|
| 30 |
block_shadow="0 4px 10px rgba(0, 0, 0, 0.08)",
|
| 31 |
|
| 32 |
-
# ===
|
| 33 |
button_secondary_background_fill="transparent",
|
| 34 |
button_secondary_background_fill_hover="rgba(0, 0, 0, 0.05)",
|
| 35 |
button_secondary_text_color="#6c757d",
|
| 36 |
button_secondary_text_color_hover="#005f73",
|
| 37 |
-
# ✨ CORRECTED: Removed invalid 'button_secondary_radius' argument
|
| 38 |
|
| 39 |
-
# ===
|
| 40 |
button_primary_background_fill="#005f73",
|
| 41 |
button_primary_background_fill_hover="#0a9396",
|
| 42 |
button_primary_text_color="white",
|
| 43 |
-
# ❌ Removed unsupported: button_primary_radius
|
| 44 |
|
| 45 |
-
# ===
|
| 46 |
input_background_fill="white",
|
| 47 |
input_border_color="#dee2e6",
|
| 48 |
input_shadow="0 1px 3px rgba(0, 0, 0, 0.08)",
|
| 49 |
input_border_width="1.5px",
|
| 50 |
input_radius="8px",
|
| 51 |
|
| 52 |
-
# ---
|
| 53 |
link_text_color="#0a9396",
|
| 54 |
link_text_color_hover="#005f73",
|
| 55 |
)
|
| 56 |
|
| 57 |
|
| 58 |
-
# ---
|
| 59 |
try:
|
| 60 |
count = get_and_update_visits()
|
| 61 |
visit_count_html = f"🚀 **總載入次數:** {count}"
|
|
@@ -64,9 +62,10 @@ except Exception as e:
|
|
| 64 |
visit_count_html = "🚀 **總載入次數:** N/A"
|
| 65 |
print(f"Could not update visit count: {e}")
|
| 66 |
|
| 67 |
-
# ---
|
| 68 |
demo = create_ui(visit_count_html, theme=professional_theme)
|
| 69 |
|
| 70 |
-
# ---
|
| 71 |
if __name__ == "__main__":
|
| 72 |
-
demo.launch()
|
|
|
|
|
|
| 3 |
from core.visits import get_and_update_visits
|
| 4 |
from ui.layouts import create_ui
|
| 5 |
|
| 6 |
+
# --- 最終版專業佈景主題 ---
|
| 7 |
professional_theme = gr.themes.Soft(
|
| 8 |
+
# 設定字體
|
| 9 |
font=gr.themes.GoogleFont("Noto Sans TC"),
|
| 10 |
|
| 11 |
+
# 設定色調
|
| 12 |
primary_hue=gr.themes.colors.teal,
|
| 13 |
secondary_hue=gr.themes.colors.cyan,
|
| 14 |
neutral_hue="slate",
|
| 15 |
|
| 16 |
+
# 設定元件圓角與間距
|
| 17 |
radius_size=gr.themes.sizes.radius_md,
|
| 18 |
spacing_size=gr.themes.sizes.spacing_md,
|
| 19 |
|
| 20 |
).set(
|
| 21 |
+
# === 全局佈局 ===
|
| 22 |
body_background_fill="#f8f9fa",
|
| 23 |
panel_background_fill="#f8f9fa",
|
| 24 |
|
| 25 |
+
# === 卡片/區塊樣式 ===
|
| 26 |
block_background_fill="white",
|
| 27 |
block_border_width="0px",
|
| 28 |
block_border_color="transparent",
|
| 29 |
block_radius="16px",
|
| 30 |
block_shadow="0 4px 10px rgba(0, 0, 0, 0.08)",
|
| 31 |
|
| 32 |
+
# === 未選中分頁 (次要按鈕) 樣式 ===
|
| 33 |
button_secondary_background_fill="transparent",
|
| 34 |
button_secondary_background_fill_hover="rgba(0, 0, 0, 0.05)",
|
| 35 |
button_secondary_text_color="#6c757d",
|
| 36 |
button_secondary_text_color_hover="#005f73",
|
|
|
|
| 37 |
|
| 38 |
+
# === 主要按鈕 (及選中分頁) 樣式 ===
|
| 39 |
button_primary_background_fill="#005f73",
|
| 40 |
button_primary_background_fill_hover="#0a9396",
|
| 41 |
button_primary_text_color="white",
|
|
|
|
| 42 |
|
| 43 |
+
# === 輸入框樣式 ===
|
| 44 |
input_background_fill="white",
|
| 45 |
input_border_color="#dee2e6",
|
| 46 |
input_shadow="0 1px 3px rgba(0, 0, 0, 0.08)",
|
| 47 |
input_border_width="1.5px",
|
| 48 |
input_radius="8px",
|
| 49 |
|
| 50 |
+
# --- 其他細節 ---
|
| 51 |
link_text_color="#0a9396",
|
| 52 |
link_text_color_hover="#005f73",
|
| 53 |
)
|
| 54 |
|
| 55 |
|
| 56 |
+
# --- 應用程式啟動邏輯 ---
|
| 57 |
try:
|
| 58 |
count = get_and_update_visits()
|
| 59 |
visit_count_html = f"🚀 **總載入次數:** {count}"
|
|
|
|
| 62 |
visit_count_html = "🚀 **總載入次數:** N/A"
|
| 63 |
print(f"Could not update visit count: {e}")
|
| 64 |
|
| 65 |
+
# --- 建立 UI 並傳入佈景主題 ---
|
| 66 |
demo = create_ui(visit_count_html, theme=professional_theme)
|
| 67 |
|
| 68 |
+
# --- 啟動應用程式 ---
|
| 69 |
if __name__ == "__main__":
|
| 70 |
+
demo.launch()
|
| 71 |
+
|