wanglei2762 commited on
Commit
41768b1
·
1 Parent(s): efc5557

更改网页的样式

Browse files
Files changed (1) hide show
  1. app.py +85 -35
app.py CHANGED
@@ -24,79 +24,129 @@ DEFAULT_MODEL_DISPLAY_NAME = list(AVAILABLE_MODELS.keys())[0] # 默认选择第
24
  # --- 自定义 CSS ---
25
  custom_css = """
26
  body {
27
- background-color: #f0f2f5;
28
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
29
  }
 
30
  .gradio-container {
31
- border-radius: 15px !important;
32
- box-shadow: 0 4px 12px rgba(0,0,0,0.1) !important;
33
  background-color: #ffffff;
 
34
  }
 
35
  .message-bubble-user {
36
  background-color: #007bff !important;
37
  color: white !important;
38
- border-radius: 15px 15px 0 15px !important;
39
  align-self: flex-end;
40
- max-width: 70%;
 
 
41
  }
 
42
  .message-bubble-bot {
43
- background-color: #e9ecef !important;
44
- color: #333 !important;
45
- border-radius: 15px 15px 15px 0 !important;
46
  align-self: flex-start;
47
- max-width: 70%;
 
 
 
48
  }
 
49
  .message-bubble-user .message-text, .message-bubble-bot .message-text {
50
- font-size: 1rem !important;
51
- padding: 10px 15px !important;
 
52
  }
 
53
  .avatar-container img {
54
  border-radius: 50% !important;
55
- width: 40px !important;
56
- height: 40px !important;
57
  object-fit: cover;
58
- margin: 5px !important;
59
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
 
60
  }
 
61
  .textbox textarea {
62
- border-radius: 20px !important;
63
- border: 1px solid #343a40 !important; /* 深色边框,例如接近黑色的深灰 */
64
- background-color: #495057 !important; /* 深灰色背景 */
65
- color: #f8f9fa !important; /* 浅色文字,例如非常浅的灰色或白色 */
66
- padding: 10px 15px !important;
67
- font-size: 1rem !important;
68
- box-shadow: none !important;
69
  }
70
 
71
- /* (可选)当输入框获得焦点时的样式,可以进一步调整 */
72
  .textbox textarea:focus {
73
- border-color: #007bff !important; /* 例如,聚焦时边框变亮蓝色 */
74
- /* background-color: #5a6268 !important; */ /* 也可以调整聚焦时的背景色 */
75
- /* box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25) !important; */ /* 添加聚焦时的阴影效果 */
 
76
  }
 
77
  .submit-button {
78
  background-color: #007bff !important;
79
  color: white !important;
80
- border-radius: 20px !important;
81
  font-weight: bold !important;
82
- padding: 10px 20px !important;
83
- transition: background-color 0.2s ease-in-out;
 
 
 
84
  }
 
85
  .submit-button:hover {
86
  background-color: #0056b3 !important;
 
 
87
  }
 
88
  .gr-prose h1, .gr-prose h2, .gr-prose h3 {
89
- color: #343a40;
90
  text-align: center;
 
 
 
 
 
 
 
 
 
 
91
  }
 
 
 
 
 
92
  .gr-prose p {
93
- color: #495057;
94
  text-align: center;
95
- font-size: 1.1em;
 
 
96
  }
97
- /* 为下拉菜单添加一些边距 */
 
98
  .gradio-dropdown {
99
- margin-bottom: 15px !important;
 
 
 
 
 
 
 
 
 
 
100
  }
101
  """
102
 
@@ -159,7 +209,7 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css) as demo:
159
  choices=list(AVAILABLE_MODELS.keys()), # 用户看到的选项是显示名称
160
  value=DEFAULT_MODEL_DISPLAY_NAME, # 默认值
161
  label="选择AI模型",
162
- info="更改模型后,新的对话将使用所选模型。",
163
  elem_classes="gradio-dropdown" # 应用自定义CSS类 (可选)
164
  )
165
 
 
24
  # --- 自定义 CSS ---
25
  custom_css = """
26
  body {
27
+ background-color: #e9ecef; /* 稍微调暗一点背景,让前景更突出 */
28
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
29
  }
30
+
31
  .gradio-container {
32
+ border-radius: 20px !important; /* 稍微增大圆角 */
33
+ box-shadow: 0 8px 24px rgba(0,0,0,0.15) !important; /* 增强阴影 */
34
  background-color: #ffffff;
35
+ /* border: 1px solid #dee2e6 !important; */ /* (可选)添加一个细边框 */
36
  }
37
+
38
  .message-bubble-user {
39
  background-color: #007bff !important;
40
  color: white !important;
41
+ border-radius: 20px 20px 5px 20px !important; /* 调整圆角使其更有特色 */
42
  align-self: flex-end;
43
+ max-width: 75%; /* 稍微增加最大宽度 */
44
+ box-shadow: 3px 3px 8px rgba(0,0,0,0.2) !important; /* 添加阴影使其浮动 */
45
+ margin-bottom: 10px !important; /* 增加一点底部间距 */
46
  }
47
+
48
  .message-bubble-bot {
49
+ background-color: #f8f9fa !important; /* 使用更亮的背景增加对比 */
50
+ color: #212529 !important; /* 使用更深的文字颜色增加对比 */
51
+ border-radius: 20px 20px 20px 5px !important; /* 调整圆角 */
52
  align-self: flex-start;
53
+ max-width: 75%; /* 稍微增加最大宽度 */
54
+ border: 1px solid #ced4da !important; /* 添加边框使其更清晰 */
55
+ box-shadow: -3px 3px 8px rgba(0,0,0,0.1) !important; /* 添加阴影 */
56
+ margin-bottom: 10px !important; /* 增加一点底部间距 */
57
  }
58
+
59
  .message-bubble-user .message-text, .message-bubble-bot .message-text {
60
+ font-size: 1.05rem !important; /* 稍微增大字体 */
61
+ padding: 12px 18px !important; /* 增加内边距 */
62
+ line-height: 1.6 !important; /* 增加行高,提高可读性 */
63
  }
64
+
65
  .avatar-container img {
66
  border-radius: 50% !important;
67
+ width: 48px !important; /* 增大头像尺寸 */
68
+ height: 48px !important; /* 增大头像尺寸 */
69
  object-fit: cover;
70
+ margin: 8px !important; /* 增加外边距 */
71
+ box-shadow: 0 2px 6px rgba(0,0,0,0.25) !important; /* 增强阴影 */
72
+ border: 2px solid #ffffff !important; /* 给头像加一个白色边框,使其从背景中突出 */
73
  }
74
+
75
  .textbox textarea {
76
+ border-radius: 25px !important; /* 增大圆角 */
77
+ border: 2px solid #343a40 !important; /* 加粗边框 */
78
+ background-color: #495057 !important;
79
+ color: #f8f9fa !important;
80
+ padding: 12px 18px !important; /* 增加内边距 */
81
+ font-size: 1.05rem !important; /* 稍微增大字体 */
82
+ box-shadow: inset 0 1px 3px rgba(0,0,0,0.2) !important; /* 添加内阴影增加深度感 */
83
  }
84
 
 
85
  .textbox textarea:focus {
86
+ border-color: #007bff !important;
87
+ background-color: #5a6268 !important;
88
+ box-shadow: 0 0 0 0.25rem rgba(0, 123, 255, 0.35) !important; /* 增强聚焦阴影 */
89
+ /* transform: scale(1.01); */ /* (可选)聚焦时轻微放大 */
90
  }
91
+
92
  .submit-button {
93
  background-color: #007bff !important;
94
  color: white !important;
95
+ border-radius: 25px !important; /* 增大圆角 */
96
  font-weight: bold !important;
97
+ font-size: 1.1rem !important; /* 增大字体 */
98
+ padding: 12px 25px !important; /* 增加内边距 */
99
+ transition: all 0.2s ease-in-out; /* 平滑所有过渡 */
100
+ box-shadow: 0 3px 6px rgba(0, 123, 255, 0.3) !important; /* 添加阴影 */
101
+ border: none !important; /* 移除默认边框(如果存在) */
102
  }
103
+
104
  .submit-button:hover {
105
  background-color: #0056b3 !important;
106
+ box-shadow: 0 5px 10px rgba(0, 86, 179, 0.4) !important; /* 悬停时增强阴影 */
107
+ transform: translateY(-2px); /* 悬停时轻微上移 */
108
  }
109
+
110
  .gr-prose h1, .gr-prose h2, .gr-prose h3 {
111
+ color: #212529; /* 更深的颜色 */
112
  text-align: center;
113
+ margin-bottom: 0.75em !important; /* 增加标题下的间距 */
114
+ text-shadow: 1px 1px 2px rgba(0,0,0,0.1); /* 给标题添加轻微文字阴影 */
115
+ }
116
+ .gr-prose h1 {
117
+ font-size: 2.8em !important; /* 增大 H1 */
118
+ font-weight: 700 !important;
119
+ }
120
+ .gr-prose h2 {
121
+ font-size: 2.2em !important; /* 增大 H2 */
122
+ font-weight: 600 !important;
123
  }
124
+ .gr-prose h3 {
125
+ font-size: 1.8em !important; /* 增大 H3 */
126
+ font-weight: 600 !important;
127
+ }
128
+
129
  .gr-prose p {
130
+ color: #343a40; /* 更深的颜色 */
131
  text-align: center;
132
+ font-size: 1.15em !important; /* 增大段落字体 */
133
+ line-height: 1.7 !important; /* 增加行高 */
134
+ margin-bottom: 1.5em !important; /* 增加段落下间距 */
135
  }
136
+
137
+ /* 为下拉菜单添加一些边距和视觉强调 */
138
  .gradio-dropdown {
139
+ margin-top: 10px !important; /* 增加上方外边距 */
140
+ margin-bottom: 25px !important; /* 显著增加下方外边距,使其与其他元素分隔开 */
141
+ /* 如果想让下拉框本身更突出,可能需要针对其内部元素如 .gr-select select 或类似的选择器 */
142
+ /* 例如(需要根据实际Gradio版本检查选择器): */
143
+ /*
144
+ select {
145
+ border-width: 2px !important;
146
+ border-color: #007bff !important;
147
+ font-weight: bold !important;
148
+ }
149
+ */
150
  }
151
  """
152
 
 
209
  choices=list(AVAILABLE_MODELS.keys()), # 用户看到的选项是显示名称
210
  value=DEFAULT_MODEL_DISPLAY_NAME, # 默认值
211
  label="选择AI模型",
212
+ info="更改模型后,请刷新窗口,新的对话将使用所选模型。",
213
  elem_classes="gradio-dropdown" # 应用自定义CSS类 (可选)
214
  )
215