Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -163,21 +163,26 @@ with gr.Blocks(
|
|
163 |
theme=gr.themes.Soft(),
|
164 |
title="PDF 摘要助手",
|
165 |
css="""
|
166 |
-
/*
|
167 |
.gradio-container {
|
168 |
-
max-width:
|
|
|
169 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
170 |
-
min-height: 100vh;
|
|
|
|
|
171 |
}
|
172 |
|
173 |
-
/* 主要內容區域 */
|
174 |
.main-content {
|
175 |
background: rgba(255, 255, 255, 0.95) !important;
|
176 |
border-radius: 20px !important;
|
177 |
-
margin: 20px !important;
|
178 |
padding: 30px !important;
|
179 |
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1) !important;
|
180 |
backdrop-filter: blur(10px) !important;
|
|
|
|
|
181 |
}
|
182 |
|
183 |
/* 標題樣式 */
|
@@ -185,58 +190,48 @@ with gr.Blocks(
|
|
185 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
186 |
-webkit-background-clip: text !important;
|
187 |
-webkit-text-fill-color: transparent !important;
|
|
|
188 |
text-align: center !important;
|
189 |
font-size: 2.5em !important;
|
190 |
font-weight: bold !important;
|
191 |
margin-bottom: 20px !important;
|
192 |
}
|
193 |
|
194 |
-
/* 分頁導航 */
|
195 |
-
.
|
196 |
-
|
197 |
-
|
198 |
-
padding: 10px !important;
|
199 |
-
}
|
200 |
-
|
201 |
-
.tab-nav button {
|
202 |
-
background: rgba(255, 255, 255, 0.2) !important;
|
203 |
-
color: white !important;
|
204 |
-
border: none !important;
|
205 |
-
border-radius: 10px !important;
|
206 |
-
margin: 0 5px !important;
|
207 |
-
padding: 12px 24px !important;
|
208 |
-
font-weight: 600 !important;
|
209 |
-
transition: all 0.3s ease !important;
|
210 |
-
}
|
211 |
-
|
212 |
-
.tab-nav button:hover {
|
213 |
-
background: rgba(255, 255, 255, 0.3) !important;
|
214 |
-
transform: translateY(-2px) !important;
|
215 |
}
|
216 |
|
217 |
-
.
|
|
|
218 |
background: white !important;
|
219 |
-
|
220 |
-
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2) !important;
|
221 |
}
|
222 |
|
223 |
-
/* 輸入框樣式 */
|
224 |
-
|
|
|
|
|
225 |
border: 2px solid #e0e6ff !important;
|
226 |
border-radius: 12px !important;
|
227 |
padding: 15px !important;
|
228 |
font-size: 16px !important;
|
229 |
transition: all 0.3s ease !important;
|
|
|
|
|
230 |
}
|
231 |
|
232 |
-
|
|
|
|
|
233 |
border-color: #667eea !important;
|
234 |
box-shadow: 0 0 20px rgba(102, 126, 234, 0.3) !important;
|
235 |
outline: none !important;
|
236 |
}
|
237 |
|
238 |
-
/* 按鈕樣式 */
|
239 |
-
|
240 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
241 |
border: none !important;
|
242 |
border-radius: 12px !important;
|
@@ -246,101 +241,111 @@ with gr.Blocks(
|
|
246 |
font-size: 16px !important;
|
247 |
transition: all 0.3s ease !important;
|
248 |
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4) !important;
|
|
|
|
|
|
|
|
|
249 |
}
|
250 |
|
251 |
-
|
252 |
-
transform: translateY(-
|
253 |
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6) !important;
|
254 |
}
|
255 |
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
|
258 |
}
|
259 |
|
260 |
/* 文件上傳區域 */
|
261 |
-
.
|
262 |
border: 3px dashed #667eea !important;
|
263 |
border-radius: 15px !important;
|
264 |
background: rgba(102, 126, 234, 0.05) !important;
|
265 |
padding: 40px !important;
|
266 |
text-align: center !important;
|
267 |
transition: all 0.3s ease !important;
|
|
|
268 |
}
|
269 |
|
270 |
-
.
|
271 |
background: rgba(102, 126, 234, 0.1) !important;
|
272 |
border-color: #764ba2 !important;
|
273 |
}
|
274 |
|
275 |
-
/*
|
276 |
-
.
|
277 |
background: rgba(102, 126, 234, 0.05) !important;
|
278 |
border-radius: 12px !important;
|
279 |
padding: 20px !important;
|
280 |
-
}
|
281 |
-
|
282 |
-
/* 卡片樣式 */
|
283 |
-
.gr-panel {
|
284 |
-
background: rgba(255, 255, 255, 0.9) !important;
|
285 |
-
border-radius: 15px !important;
|
286 |
-
border: 1px solid rgba(102, 126, 234, 0.2) !important;
|
287 |
-
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08) !important;
|
288 |
-
padding: 25px !important;
|
289 |
margin: 10px 0 !important;
|
290 |
}
|
291 |
|
292 |
-
/*
|
293 |
-
.
|
294 |
-
|
|
|
|
|
|
|
|
|
295 |
}
|
296 |
|
297 |
-
|
|
|
|
|
|
|
|
|
|
|
298 |
display: none !important;
|
299 |
}
|
300 |
|
301 |
-
/*
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
display: none !important;
|
307 |
}
|
308 |
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
opacity: 0;
|
313 |
-
transform: translateY(30px);
|
314 |
-
}
|
315 |
-
to {
|
316 |
-
opacity: 1;
|
317 |
-
transform: translateY(0);
|
318 |
-
}
|
319 |
}
|
320 |
|
321 |
-
|
322 |
-
|
|
|
323 |
}
|
324 |
|
325 |
/* 響應式設計 */
|
326 |
@media (max-width: 768px) {
|
327 |
-
.gradio-container {
|
328 |
-
margin: 10px !important;
|
329 |
-
}
|
330 |
-
|
331 |
.main-content {
|
332 |
-
padding: 20px !important;
|
333 |
margin: 10px !important;
|
|
|
|
|
334 |
}
|
335 |
|
336 |
.main-header {
|
337 |
-
font-size:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
}
|
339 |
}
|
340 |
"""
|
341 |
) as demo:
|
342 |
with gr.Column(elem_classes="main-content"):
|
343 |
-
gr.
|
344 |
<div class="main-header">📄 PDF 摘要 & 問答助手</div>
|
345 |
|
346 |
<div style="text-align: center; margin-bottom: 30px; padding: 25px; background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%); border-radius: 15px; border-left: 5px solid #667eea;">
|
|
|
163 |
theme=gr.themes.Soft(),
|
164 |
title="PDF 摘要助手",
|
165 |
css="""
|
166 |
+
/* 修復頁面大小問題 */
|
167 |
.gradio-container {
|
168 |
+
max-width: none !important;
|
169 |
+
width: 100% !important;
|
170 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
171 |
+
min-height: 100vh !important;
|
172 |
+
padding: 0 !important;
|
173 |
+
margin: 0 !important;
|
174 |
}
|
175 |
|
176 |
+
/* 主要內容區域 - 修復大小問題 */
|
177 |
.main-content {
|
178 |
background: rgba(255, 255, 255, 0.95) !important;
|
179 |
border-radius: 20px !important;
|
180 |
+
margin: 20px auto !important;
|
181 |
padding: 30px !important;
|
182 |
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1) !important;
|
183 |
backdrop-filter: blur(10px) !important;
|
184 |
+
max-width: 1400px !important;
|
185 |
+
width: calc(100% - 40px) !important;
|
186 |
}
|
187 |
|
188 |
/* 標題樣式 */
|
|
|
190 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
191 |
-webkit-background-clip: text !important;
|
192 |
-webkit-text-fill-color: transparent !important;
|
193 |
+
background-clip: text !important;
|
194 |
text-align: center !important;
|
195 |
font-size: 2.5em !important;
|
196 |
font-weight: bold !important;
|
197 |
margin-bottom: 20px !important;
|
198 |
}
|
199 |
|
200 |
+
/* 分頁導航 - 修復點擊問題 */
|
201 |
+
.gradio-tabs {
|
202 |
+
border-radius: 15px !important;
|
203 |
+
overflow: hidden !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
204 |
}
|
205 |
|
206 |
+
.gradio-tabitem {
|
207 |
+
padding: 25px !important;
|
208 |
background: white !important;
|
209 |
+
border-radius: 0 0 15px 15px !important;
|
|
|
210 |
}
|
211 |
|
212 |
+
/* 輸入框樣式 - 修復交互問題 */
|
213 |
+
input[type="text"],
|
214 |
+
input[type="password"],
|
215 |
+
textarea {
|
216 |
border: 2px solid #e0e6ff !important;
|
217 |
border-radius: 12px !important;
|
218 |
padding: 15px !important;
|
219 |
font-size: 16px !important;
|
220 |
transition: all 0.3s ease !important;
|
221 |
+
width: 100% !important;
|
222 |
+
box-sizing: border-box !important;
|
223 |
}
|
224 |
|
225 |
+
input[type="text"]:focus,
|
226 |
+
input[type="password"]:focus,
|
227 |
+
textarea:focus {
|
228 |
border-color: #667eea !important;
|
229 |
box-shadow: 0 0 20px rgba(102, 126, 234, 0.3) !important;
|
230 |
outline: none !important;
|
231 |
}
|
232 |
|
233 |
+
/* 按鈕樣式 - 修復點擊問題 */
|
234 |
+
button {
|
235 |
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
|
236 |
border: none !important;
|
237 |
border-radius: 12px !important;
|
|
|
241 |
font-size: 16px !important;
|
242 |
transition: all 0.3s ease !important;
|
243 |
box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4) !important;
|
244 |
+
cursor: pointer !important;
|
245 |
+
pointer-events: auto !important;
|
246 |
+
z-index: 100 !important;
|
247 |
+
position: relative !important;
|
248 |
}
|
249 |
|
250 |
+
button:hover {
|
251 |
+
transform: translateY(-2px) !important;
|
252 |
box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6) !important;
|
253 |
}
|
254 |
|
255 |
+
button:active {
|
256 |
+
transform: translateY(0px) !important;
|
257 |
+
}
|
258 |
+
|
259 |
+
/* 次要按鈕 */
|
260 |
+
button.secondary,
|
261 |
+
button[variant="secondary"] {
|
262 |
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
|
263 |
}
|
264 |
|
265 |
/* 文件上傳區域 */
|
266 |
+
.file-upload-area {
|
267 |
border: 3px dashed #667eea !important;
|
268 |
border-radius: 15px !important;
|
269 |
background: rgba(102, 126, 234, 0.05) !important;
|
270 |
padding: 40px !important;
|
271 |
text-align: center !important;
|
272 |
transition: all 0.3s ease !important;
|
273 |
+
min-height: 120px !important;
|
274 |
}
|
275 |
|
276 |
+
.file-upload-area:hover {
|
277 |
background: rgba(102, 126, 234, 0.1) !important;
|
278 |
border-color: #764ba2 !important;
|
279 |
}
|
280 |
|
281 |
+
/* 單選按鈕容器 */
|
282 |
+
.radio-group {
|
283 |
background: rgba(102, 126, 234, 0.05) !important;
|
284 |
border-radius: 12px !important;
|
285 |
padding: 20px !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
margin: 10px 0 !important;
|
287 |
}
|
288 |
|
289 |
+
/* 輸出文本區域 */
|
290 |
+
.output-text {
|
291 |
+
background: #f8f9ff !important;
|
292 |
+
border: 1px solid #e0e6ff !important;
|
293 |
+
border-radius: 12px !important;
|
294 |
+
padding: 20px !important;
|
295 |
+
min-height: 200px !important;
|
296 |
}
|
297 |
|
298 |
+
/* 隱藏 Gradio logo 和 footer */
|
299 |
+
footer,
|
300 |
+
.gradio-container footer,
|
301 |
+
div[class*="footer"],
|
302 |
+
div[class*="Footer"],
|
303 |
+
.gr-footer {
|
304 |
display: none !important;
|
305 |
}
|
306 |
|
307 |
+
/* 修復響應式問題 */
|
308 |
+
.gr-row {
|
309 |
+
display: flex !important;
|
310 |
+
gap: 20px !important;
|
311 |
+
width: 100% !important;
|
|
|
312 |
}
|
313 |
|
314 |
+
.gr-column {
|
315 |
+
flex: 1 !important;
|
316 |
+
min-width: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
317 |
}
|
318 |
|
319 |
+
/* 確保所有元素可以正常交互 */
|
320 |
+
* {
|
321 |
+
pointer-events: auto !important;
|
322 |
}
|
323 |
|
324 |
/* 響應式設計 */
|
325 |
@media (max-width: 768px) {
|
|
|
|
|
|
|
|
|
326 |
.main-content {
|
|
|
327 |
margin: 10px !important;
|
328 |
+
padding: 20px !important;
|
329 |
+
width: calc(100% - 20px) !important;
|
330 |
}
|
331 |
|
332 |
.main-header {
|
333 |
+
font-size: 1.8em !important;
|
334 |
+
}
|
335 |
+
|
336 |
+
.gr-row {
|
337 |
+
flex-direction: column !important;
|
338 |
+
}
|
339 |
+
|
340 |
+
button {
|
341 |
+
width: 100% !important;
|
342 |
+
margin: 5px 0 !important;
|
343 |
}
|
344 |
}
|
345 |
"""
|
346 |
) as demo:
|
347 |
with gr.Column(elem_classes="main-content"):
|
348 |
+
gr.HTML("""
|
349 |
<div class="main-header">📄 PDF 摘要 & 問答助手</div>
|
350 |
|
351 |
<div style="text-align: center; margin-bottom: 30px; padding: 25px; background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%); border-radius: 15px; border-left: 5px solid #667eea;">
|