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