3a05chatgpt commited on
Commit
a119ef4
·
verified ·
1 Parent(s): c67d332

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +98 -8
app.py CHANGED
@@ -231,7 +231,10 @@ with gr.Blocks(
231
  }
232
 
233
  /* 按鈕樣式 - 修復點擊問題 */
234
- button {
 
 
 
235
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
236
  border: none !important;
237
  border-radius: 12px !important;
@@ -243,25 +246,58 @@ with gr.Blocks(
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;
@@ -316,11 +352,62 @@ with gr.Blocks(
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 {
@@ -403,6 +490,9 @@ with gr.Blocks(
403
  value="✅ 已選擇:gpt-4",
404
  elem_classes="status-display"
405
  )
 
 
 
406
 
407
  with gr.Tab("📄 PDF 處理", elem_classes="pdf-tab"):
408
  gr.Markdown("### 📁 文件上傳與摘要生成")
 
231
  }
232
 
233
  /* 按鈕樣式 - 修復點擊問題 */
234
+ button,
235
+ .gr-button,
236
+ input[type="submit"],
237
+ input[type="button"] {
238
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
239
  border: none !important;
240
  border-radius: 12px !important;
 
246
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4) !important;
247
  cursor: pointer !important;
248
  pointer-events: auto !important;
249
+ z-index: 1000 !important;
250
  position: relative !important;
251
+ display: inline-block !important;
252
+ min-height: 44px !important;
253
+ line-height: normal !important;
254
  }
255
 
256
+ button:hover,
257
+ .gr-button:hover,
258
+ input[type="submit"]:hover,
259
+ input[type="button"]:hover {
260
  transform: translateY(-2px) !important;
261
  box-shadow: 0 8px 25px rgba(102, 126, 234, 0.6) !important;
262
+ background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%) !important;
263
  }
264
 
265
+ button:active,
266
+ .gr-button:active,
267
+ input[type="submit"]:active,
268
+ input[type="button"]:active {
269
  transform: translateY(0px) !important;
270
+ box-shadow: 0 3px 10px rgba(102, 126, 234, 0.4) !important;
271
  }
272
 
273
+ /* 次要按鈕樣式 */
274
+ button[data-testid*="secondary"],
275
+ .gr-button.secondary,
276
+ button.secondary {
277
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%) !important;
278
  }
279
 
280
+ button[data-testid*="secondary"]:hover,
281
+ .gr-button.secondary:hover,
282
+ button.secondary:hover {
283
+ background: linear-gradient(135deg, #e081e9 0%, #e3455a 100%) !important;
284
+ }
285
+
286
+ /* 修復 Gradio 特定的按鈕容器 */
287
+ .gr-form > div,
288
+ .gr-button-group,
289
+ div[data-testid="button"] {
290
+ pointer-events: auto !important;
291
+ z-index: 999 !important;
292
+ }
293
+
294
+ /* 確保按鈕內的文字可點擊 */
295
+ button span,
296
+ .gr-button span {
297
+ pointer-events: none !important;
298
+ user-select: none !important;
299
+ }
300
+
301
  /* 文件上傳區域 */
302
  .file-upload-area {
303
  border: 3px dashed #667eea !important;
 
352
  min-width: 0 !important;
353
  }
354
 
355
+ /* 確保所有交互元素正常工作 */
356
  * {
357
  pointer-events: auto !important;
358
  }
359
 
360
+ /* 特殊修復:覆蓋可能的 Gradio 樣式衝突 */
361
+ .gradio-container * {
362
+ pointer-events: auto !important;
363
+ }
364
+
365
+ /* 修復單選按鈕 */
366
+ input[type="radio"] {
367
+ pointer-events: auto !important;
368
+ cursor: pointer !important;
369
+ z-index: 1000 !important;
370
+ position: relative !important;
371
+ }
372
+
373
+ /* 修復文件上傳 */
374
+ input[type="file"] {
375
+ pointer-events: auto !important;
376
+ cursor: pointer !important;
377
+ z-index: 1000 !important;
378
+ }
379
+
380
+ /* 添加 JavaScript 來確保按鈕響應 */
381
+ </style>
382
+ <script>
383
+ document.addEventListener('DOMContentLoaded', function() {
384
+ // 確保所有按鈕都可以點擊
385
+ function fixButtons() {
386
+ const buttons = document.querySelectorAll('button, input[type="submit"], input[type="button"]');
387
+ buttons.forEach(btn => {
388
+ btn.style.pointerEvents = 'auto';
389
+ btn.style.cursor = 'pointer';
390
+ btn.style.zIndex = '1000';
391
+ btn.style.position = 'relative';
392
+ });
393
+ }
394
+
395
+ // 初始修復
396
+ fixButtons();
397
+
398
+ // 定期檢查並修復新出現的按鈕
399
+ setInterval(fixButtons, 1000);
400
+
401
+ // 監聽 DOM 變化
402
+ const observer = new MutationObserver(fixButtons);
403
+ observer.observe(document.body, {
404
+ childList: true,
405
+ subtree: true
406
+ });
407
+ });
408
+ </script>
409
+ <style>
410
+
411
  /* 響應式設計 */
412
  @media (max-width: 768px) {
413
  .main-content {
 
490
  value="✅ 已選擇:gpt-4",
491
  elem_classes="status-display"
492
  )
493
+
494
+ # 添加測試按鈕
495
+ gr.HTML("<div style='margin: 20px 0; padding: 15px; background: rgba(102, 126, 234, 0.1); border-radius: 10px;'><strong>💡 提示:</strong> 設定完成後,請前往「PDF 處理」頁面上傳文件開始使用!</div>")
496
 
497
  with gr.Tab("📄 PDF 處理", elem_classes="pdf-tab"):
498
  gr.Markdown("### 📁 文件上傳與摘要生成")