Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
ffb7037
1
Parent(s):
2a8ac85
修复make_custom_css函数定义顺序,解决函数未定义错误
Browse files
app.py
CHANGED
@@ -818,6 +818,137 @@ quick_prompts = [
|
|
818 |
quick_prompts = [[x] for x in quick_prompts]
|
819 |
|
820 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
821 |
css = make_custom_css()
|
822 |
block = gr.Blocks(css=css).queue()
|
823 |
with block:
|
@@ -1137,135 +1268,4 @@ with block:
|
|
1137 |
end_button.click(fn=end_process)
|
1138 |
|
1139 |
|
1140 |
-
# 创建一个自定义CSS,增加响应式布局支持
|
1141 |
-
def make_custom_css():
|
1142 |
-
progress_bar_css = make_progress_bar_css()
|
1143 |
-
|
1144 |
-
responsive_css = """
|
1145 |
-
/* 基础响应式设置 */
|
1146 |
-
#app-container {
|
1147 |
-
max-width: 100%;
|
1148 |
-
margin: 0 auto;
|
1149 |
-
}
|
1150 |
-
|
1151 |
-
/* 语言切换按钮样式 */
|
1152 |
-
#language-toggle {
|
1153 |
-
position: fixed;
|
1154 |
-
top: 10px;
|
1155 |
-
right: 10px;
|
1156 |
-
z-index: 1000;
|
1157 |
-
background-color: rgba(0, 0, 0, 0.7);
|
1158 |
-
color: white;
|
1159 |
-
border: none;
|
1160 |
-
border-radius: 4px;
|
1161 |
-
padding: 5px 10px;
|
1162 |
-
cursor: pointer;
|
1163 |
-
font-size: 14px;
|
1164 |
-
}
|
1165 |
-
|
1166 |
-
/* 页面标题样式 */
|
1167 |
-
h1 {
|
1168 |
-
font-size: 2rem;
|
1169 |
-
text-align: center;
|
1170 |
-
margin-bottom: 1rem;
|
1171 |
-
}
|
1172 |
-
|
1173 |
-
/* 按钮样式 */
|
1174 |
-
.start-btn, .stop-btn {
|
1175 |
-
min-height: 45px;
|
1176 |
-
font-size: 1rem;
|
1177 |
-
}
|
1178 |
-
|
1179 |
-
/* 移动设备样式 - 小屏幕 */
|
1180 |
-
@media (max-width: 768px) {
|
1181 |
-
h1 {
|
1182 |
-
font-size: 1.5rem;
|
1183 |
-
margin-bottom: 0.5rem;
|
1184 |
-
}
|
1185 |
-
|
1186 |
-
/* 单列布局 */
|
1187 |
-
.mobile-full-width {
|
1188 |
-
flex-direction: column !important;
|
1189 |
-
}
|
1190 |
-
|
1191 |
-
.mobile-full-width > .gr-block {
|
1192 |
-
min-width: 100% !important;
|
1193 |
-
flex-grow: 1;
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
/* 调整视频大小 */
|
1197 |
-
.video-container {
|
1198 |
-
height: auto !important;
|
1199 |
-
}
|
1200 |
-
|
1201 |
-
/* 调整按钮大小 */
|
1202 |
-
.button-container button {
|
1203 |
-
min-height: 50px;
|
1204 |
-
font-size: 1rem;
|
1205 |
-
touch-action: manipulation;
|
1206 |
-
}
|
1207 |
-
|
1208 |
-
/* 调整滑块 */
|
1209 |
-
.slider-container input[type="range"] {
|
1210 |
-
height: 30px;
|
1211 |
-
}
|
1212 |
-
}
|
1213 |
-
|
1214 |
-
/* 平板设备样式 */
|
1215 |
-
@media (min-width: 769px) and (max-width: 1024px) {
|
1216 |
-
.tablet-adjust {
|
1217 |
-
width: 48% !important;
|
1218 |
-
}
|
1219 |
-
}
|
1220 |
-
|
1221 |
-
/* 黑暗模式支持 */
|
1222 |
-
@media (prefers-color-scheme: dark) {
|
1223 |
-
.dark-mode-text {
|
1224 |
-
color: #f0f0f0;
|
1225 |
-
}
|
1226 |
-
|
1227 |
-
.dark-mode-bg {
|
1228 |
-
background-color: #2a2a2a;
|
1229 |
-
}
|
1230 |
-
}
|
1231 |
-
|
1232 |
-
/* 增强可访问性 */
|
1233 |
-
button, input, select, textarea {
|
1234 |
-
font-size: 16px; /* 防止iOS缩放 */
|
1235 |
-
}
|
1236 |
-
|
1237 |
-
/* 触摸优化 */
|
1238 |
-
button, .interactive-element {
|
1239 |
-
min-height: 44px;
|
1240 |
-
min-width: 44px;
|
1241 |
-
}
|
1242 |
-
|
1243 |
-
/* 提高对比度 */
|
1244 |
-
.high-contrast {
|
1245 |
-
color: #fff;
|
1246 |
-
background-color: #000;
|
1247 |
-
}
|
1248 |
-
|
1249 |
-
/* 进度条样式增强 */
|
1250 |
-
.progress-container {
|
1251 |
-
margin-top: 10px;
|
1252 |
-
margin-bottom: 10px;
|
1253 |
-
}
|
1254 |
-
|
1255 |
-
/* 错误消息样式 */
|
1256 |
-
#error-message {
|
1257 |
-
color: #ff4444;
|
1258 |
-
font-weight: bold;
|
1259 |
-
padding: 10px;
|
1260 |
-
border-radius: 4px;
|
1261 |
-
margin-top: 10px;
|
1262 |
-
background-color: rgba(255, 0, 0, 0.1);
|
1263 |
-
}
|
1264 |
-
"""
|
1265 |
-
|
1266 |
-
# 合并CSS
|
1267 |
-
combined_css = progress_bar_css + responsive_css
|
1268 |
-
return combined_css
|
1269 |
-
|
1270 |
-
|
1271 |
block.launch()
|
|
|
818 |
quick_prompts = [[x] for x in quick_prompts]
|
819 |
|
820 |
|
821 |
+
# 创建一个自定义CSS,增加响应式布局支持
|
822 |
+
def make_custom_css():
|
823 |
+
progress_bar_css = make_progress_bar_css()
|
824 |
+
|
825 |
+
responsive_css = """
|
826 |
+
/* 基础响应式设置 */
|
827 |
+
#app-container {
|
828 |
+
max-width: 100%;
|
829 |
+
margin: 0 auto;
|
830 |
+
}
|
831 |
+
|
832 |
+
/* 语言切换按钮样式 */
|
833 |
+
#language-toggle {
|
834 |
+
position: fixed;
|
835 |
+
top: 10px;
|
836 |
+
right: 10px;
|
837 |
+
z-index: 1000;
|
838 |
+
background-color: rgba(0, 0, 0, 0.7);
|
839 |
+
color: white;
|
840 |
+
border: none;
|
841 |
+
border-radius: 4px;
|
842 |
+
padding: 5px 10px;
|
843 |
+
cursor: pointer;
|
844 |
+
font-size: 14px;
|
845 |
+
}
|
846 |
+
|
847 |
+
/* 页面标题样式 */
|
848 |
+
h1 {
|
849 |
+
font-size: 2rem;
|
850 |
+
text-align: center;
|
851 |
+
margin-bottom: 1rem;
|
852 |
+
}
|
853 |
+
|
854 |
+
/* 按钮样式 */
|
855 |
+
.start-btn, .stop-btn {
|
856 |
+
min-height: 45px;
|
857 |
+
font-size: 1rem;
|
858 |
+
}
|
859 |
+
|
860 |
+
/* 移动设备样式 - 小屏幕 */
|
861 |
+
@media (max-width: 768px) {
|
862 |
+
h1 {
|
863 |
+
font-size: 1.5rem;
|
864 |
+
margin-bottom: 0.5rem;
|
865 |
+
}
|
866 |
+
|
867 |
+
/* 单列布局 */
|
868 |
+
.mobile-full-width {
|
869 |
+
flex-direction: column !important;
|
870 |
+
}
|
871 |
+
|
872 |
+
.mobile-full-width > .gr-block {
|
873 |
+
min-width: 100% !important;
|
874 |
+
flex-grow: 1;
|
875 |
+
}
|
876 |
+
|
877 |
+
/* 调整视频大小 */
|
878 |
+
.video-container {
|
879 |
+
height: auto !important;
|
880 |
+
}
|
881 |
+
|
882 |
+
/* 调整按钮大小 */
|
883 |
+
.button-container button {
|
884 |
+
min-height: 50px;
|
885 |
+
font-size: 1rem;
|
886 |
+
touch-action: manipulation;
|
887 |
+
}
|
888 |
+
|
889 |
+
/* 调整滑块 */
|
890 |
+
.slider-container input[type="range"] {
|
891 |
+
height: 30px;
|
892 |
+
}
|
893 |
+
}
|
894 |
+
|
895 |
+
/* 平板设备样式 */
|
896 |
+
@media (min-width: 769px) and (max-width: 1024px) {
|
897 |
+
.tablet-adjust {
|
898 |
+
width: 48% !important;
|
899 |
+
}
|
900 |
+
}
|
901 |
+
|
902 |
+
/* 黑暗模式支持 */
|
903 |
+
@media (prefers-color-scheme: dark) {
|
904 |
+
.dark-mode-text {
|
905 |
+
color: #f0f0f0;
|
906 |
+
}
|
907 |
+
|
908 |
+
.dark-mode-bg {
|
909 |
+
background-color: #2a2a2a;
|
910 |
+
}
|
911 |
+
}
|
912 |
+
|
913 |
+
/* 增强可访问性 */
|
914 |
+
button, input, select, textarea {
|
915 |
+
font-size: 16px; /* 防止iOS缩放 */
|
916 |
+
}
|
917 |
+
|
918 |
+
/* 触摸优化 */
|
919 |
+
button, .interactive-element {
|
920 |
+
min-height: 44px;
|
921 |
+
min-width: 44px;
|
922 |
+
}
|
923 |
+
|
924 |
+
/* 提高对比度 */
|
925 |
+
.high-contrast {
|
926 |
+
color: #fff;
|
927 |
+
background-color: #000;
|
928 |
+
}
|
929 |
+
|
930 |
+
/* 进度条样式增强 */
|
931 |
+
.progress-container {
|
932 |
+
margin-top: 10px;
|
933 |
+
margin-bottom: 10px;
|
934 |
+
}
|
935 |
+
|
936 |
+
/* 错误消息样式 */
|
937 |
+
#error-message {
|
938 |
+
color: #ff4444;
|
939 |
+
font-weight: bold;
|
940 |
+
padding: 10px;
|
941 |
+
border-radius: 4px;
|
942 |
+
margin-top: 10px;
|
943 |
+
background-color: rgba(255, 0, 0, 0.1);
|
944 |
+
}
|
945 |
+
"""
|
946 |
+
|
947 |
+
# 合并CSS
|
948 |
+
combined_css = progress_bar_css + responsive_css
|
949 |
+
return combined_css
|
950 |
+
|
951 |
+
|
952 |
css = make_custom_css()
|
953 |
block = gr.Blocks(css=css).queue()
|
954 |
with block:
|
|
|
1268 |
end_button.click(fn=end_process)
|
1269 |
|
1270 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1271 |
block.launch()
|