Laramie2 commited on
Commit
47d4bda
·
verified ·
1 Parent(s): ef82173

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -3
app.py CHANGED
@@ -295,19 +295,51 @@ body, .gradio-container {
295
  .gradio-group:hover { box-shadow: 0 8px 32px rgba(168, 85, 247, 0.12) !important; border-color: #C084FC !important; }
296
  .dark .gradio-group { background: rgba(30, 30, 30, 0.9) !important; border-color: rgba(168, 85, 247, 0.3) !important; }
297
 
298
- /* ======== 修改:使用原生组件但优化视觉样式 ======== */
299
  #pdf-upload-box {
300
  border: 2px dashed rgba(192, 132, 252, 0.6) !important;
301
  border-radius: 12px !important;
302
  background-color: rgba(250, 245, 255, 0.5) !important;
303
  transition: all 0.3s ease !important;
 
 
304
  }
 
305
  #pdf-upload-box:hover {
306
  border-color: #A855F7 !important;
307
  background-color: rgba(243, 232, 255, 0.8) !important;
308
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.15) !important;
309
  }
310
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
311
  /* ======== 新增:主要操作按钮 (Start Mineru & Generate All) 悬浮与圆角动效 ======== */
312
  .primary-action-btn {
313
  border-radius: 30px !important;
@@ -373,9 +405,9 @@ with gr.Blocks(theme=purple_theme, css=custom_css) as demo:
373
  with gr.Group(elem_classes="gradio-group"):
374
  gr.Markdown("### 📄 2. Document Parsing")
375
 
376
- # 修复:移除破坏原生功能的全局遮罩使用原生 label 参数自定义英提示,保留完美的原生拖拽识别机制
377
  pdf_input = gr.File(
378
- label="🖱️ Click here to select a PDF or Drag & Drop the file here",
379
  file_types=[".pdf"],
380
  elem_id="pdf-upload-box"
381
  )
 
295
  .gradio-group:hover { box-shadow: 0 8px 32px rgba(168, 85, 247, 0.12) !important; border-color: #C084FC !important; }
296
  .dark .gradio-group { background: rgba(30, 30, 30, 0.9) !important; border-color: rgba(168, 85, 247, 0.3) !important; }
297
 
298
+ /* ======== 优化:文件上传框居中与背景清理 ======== */
299
  #pdf-upload-box {
300
  border: 2px dashed rgba(192, 132, 252, 0.6) !important;
301
  border-radius: 12px !important;
302
  background-color: rgba(250, 245, 255, 0.5) !important;
303
  transition: all 0.3s ease !important;
304
+ min-height: 220px !important; /* 增加高度提供居中空间 */
305
+ position: relative !important;
306
  }
307
+
308
  #pdf-upload-box:hover {
309
  border-color: #A855F7 !important;
310
  background-color: rgba(243, 232, 255, 0.8) !important;
311
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.15) !important;
312
  }
313
 
314
+ /* 隐藏原生的中/英文上传提示、图标及背景 */
315
+ #pdf-upload-box .upload-container {
316
+ background: transparent !important;
317
+ }
318
+ #pdf-upload-box .upload-container > span,
319
+ #pdf-upload-box .upload-container > svg {
320
+ display: none !important;
321
+ }
322
+
323
+ /* 使用伪元素在中央注入自定义文字和图标 */
324
+ #pdf-upload-box .upload-container::before {
325
+ content: "📤\\A Click here to select a PDF\\A or Drag & Drop the file here";
326
+ white-space: pre-wrap;
327
+ font-size: 1.2rem;
328
+ line-height: 1.8;
329
+ font-weight: 600;
330
+ color: #9333EA;
331
+ display: flex;
332
+ align-items: center;
333
+ justify-content: center;
334
+ text-align: center;
335
+ width: 100%;
336
+ height: 100%;
337
+ position: absolute;
338
+ top: 0;
339
+ left: 0;
340
+ pointer-events: none; /* 防止遮挡拖拽事件 */
341
+ }
342
+
343
  /* ======== 新增:主要操作按钮 (Start Mineru & Generate All) 悬浮与圆角动效 ======== */
344
  .primary-action-btn {
345
  border-radius: 30px !important;
 
405
  with gr.Group(elem_classes="gradio-group"):
406
  gr.Markdown("### 📄 2. Document Parsing")
407
 
408
+ # 简化了 Label因为 CSS 已经接管了内部字渲染
409
  pdf_input = gr.File(
410
+ label="Upload Document",
411
  file_types=[".pdf"],
412
  elem_id="pdf-upload-box"
413
  )