cwadayi commited on
Commit
921e711
·
verified ·
1 Parent(s): 8fa7399

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -21
app.py CHANGED
@@ -3,55 +3,47 @@ import gradio as gr
3
  from core.visits import get_and_update_visits
4
  from ui.layouts import create_ui
5
 
6
- # --- 1. 全新定義一個更專業、更美觀的自訂主題 ---
7
- # 參考您提供的網站設計語言 (顏色、字體、卡片式佈局)
8
  professional_theme = gr.themes.Soft(
9
- # 設定字體為 Noto Sans TC
10
  font=gr.themes.GoogleFont("Noto Sans TC"),
11
 
12
- # 參考網站的藍綠色系設定主色調
13
  primary_hue=gr.themes.colors.teal,
14
  secondary_hue=gr.themes.colors.cyan,
15
  neutral_hue="slate",
16
 
17
- # 調整元件的圓角大小,使其更現代
18
  radius_size=gr.themes.sizes.radius_md,
 
 
19
 
20
  ).set(
21
- # === 整體佈局 ===
22
- # 設定頁面背景色 (淺灰色,用以凸顯卡片)
23
  body_background_fill="#f8f9fa",
24
 
25
- # === 卡片/區塊樣式 (核心) ===
26
- # 設定所有區塊 (如 Tab、Group) 的背景為純白
27
  block_background_fill="white",
28
- # 設定卡片的邊框
29
  block_border_width="1px",
30
  block_border_color="#dee2e6",
31
- # 設定卡片的圓角
32
  block_radius="16px",
33
- # 設定卡片的陰影,創造懸浮感
34
  block_shadow="0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.05)",
35
 
36
- # === 按鈕樣式 ===
37
- # 設定主按鈕的背景色 (深藍綠色)
38
  button_primary_background_fill="#005f73",
39
  button_primary_background_fill_hover="#0a9396",
40
  button_primary_text_color="white",
41
 
42
- # === 輸入框樣式 ===
43
  input_background_fill="white",
44
  input_border_color="#dee2e6",
45
  input_shadow="*shadow_drop",
46
  input_border_width="1.5px",
47
-
48
- # === 間距 ===
49
- spacing_size="20px", # 元件間的基礎間距
50
- layout_gap="25px", # 區塊間的間距
51
  )
52
 
53
 
54
- # --- 2. 應用程式啟動邏輯 (維持不變) ---
55
  try:
56
  count = get_and_update_visits()
57
  visit_count_html = f"🚀 **總載入次數:** {count}"
@@ -60,7 +52,7 @@ except Exception as e:
60
  visit_count_html = "🚀 **總載入次數:** N/A"
61
  print(f"Could not update visit count: {e}")
62
 
63
- # --- 3. 建立 UI 時傳入新的佈景主題 ---
64
  demo = create_ui(visit_count_html, theme=professional_theme)
65
 
66
  # --- 4. 啟動應用程式 ---
 
3
  from core.visits import get_and_update_visits
4
  from ui.layouts import create_ui
5
 
6
+ # --- 1. 定義最終版的專業佈景主題 ---
 
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="20px",
19
+ layout_gap="25px",
20
 
21
  ).set(
22
+ # --- .set() 用於設定顏色與具體樣式 ---
23
+ # 頁面背景
24
  body_background_fill="#f8f9fa",
25
 
26
+ # 卡片/區塊樣式
 
27
  block_background_fill="white",
 
28
  block_border_width="1px",
29
  block_border_color="#dee2e6",
 
30
  block_radius="16px",
 
31
  block_shadow="0 4px 6px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.05)",
32
 
33
+ # 按鈕樣式
 
34
  button_primary_background_fill="#005f73",
35
  button_primary_background_fill_hover="#0a9396",
36
  button_primary_text_color="white",
37
 
38
+ # 輸入框樣式
39
  input_background_fill="white",
40
  input_border_color="#dee2e6",
41
  input_shadow="*shadow_drop",
42
  input_border_width="1.5px",
 
 
 
 
43
  )
44
 
45
 
46
+ # --- 2. 應用程式啟動邏輯 ---
47
  try:
48
  count = get_and_update_visits()
49
  visit_count_html = f"🚀 **總載入次數:** {count}"
 
52
  visit_count_html = "🚀 **總載入次數:** N/A"
53
  print(f"Could not update visit count: {e}")
54
 
55
+ # --- 3. 建立 UI 並傳入佈景主題 ---
56
  demo = create_ui(visit_count_html, theme=professional_theme)
57
 
58
  # --- 4. 啟動應用程式 ---