Files
OCR/openspec/changes/simplify-frontend-ocr-config/tasks.md
egg cfe65158a3 feat: enable document orientation detection for scanned PDFs
- Enable PP-StructureV3's use_doc_orientation_classify feature
- Detect rotation angle from doc_preprocessor_res.angle
- Swap page dimensions (width <-> height) for 90°/270° rotations
- Output PDF now correctly displays landscape-scanned content

Also includes:
- Archive completed openspec proposals
- Add simplify-frontend-ocr-config proposal (pending)
- Code cleanup and frontend simplification

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-11 17:13:46 +08:00

1.9 KiB
Raw Blame History

Tasks: 簡化前端 OCR 配置選項

1. 前端清理

1.1 移除未使用的組件

  • 1.1.1 刪除 frontend/src/components/OCRPresetSelector.tsx
  • 1.1.2 刪除 frontend/src/components/TableDetectionSelector.tsx

1.2 清理 TypeScript 類型定義

  • 1.2.1 從 frontend/src/types/apiV2.ts 移除以下類型:
    • TableDetectionConfig (第 121-125 行)
    • OCRPreset (第 131 行)
    • TableParsingMode (第 140 行)
    • OCRConfig (第 146-166 行)
    • OCRPresetInfo (第 171-177 行)
  • 1.2.2 從 ProcessingOptions interface 移除以下欄位:
    • table_detection
    • ocr_preset
    • ocr_config

1.3 清理 ProcessingPage

  • 1.3.1 確認 frontend/src/pages/ProcessingPage.tsx 中沒有引用已移除的類型或組件
  • 1.3.2 移除相關的註解說明(如果有)- 保留說明性註解

2. 後端清理

2.1 清理 Schema 定義

  • 2.1.1 從 backend/app/schemas/task.py 移除未使用的 Enum 和 Model:
    • TableDetectionConfig
    • OCRPresetEnum
    • TableParsingModeEnum
    • OCRConfig
    • OCR_PRESET_CONFIGS
  • 2.1.2 從 ProcessingOptions 移除以下欄位:
    • table_detection
    • ocr_preset
    • ocr_config

2.2 清理 API 端點邏輯

  • 2.2.1 檢查 backend/app/routers/tasks.py 中的 start_task 端點,移除對已刪除欄位的處理
  • 2.2.2 更新 process_task_ocr 函數簽名和呼叫

2.3 清理 Service 層

  • 2.3.1 檢查 backend/app/services/ocr_service.py,確認沒有依賴已移除的配置項
    • 注意ocr_service.py 保留這些參數作為可選項,使用預設值處理。這是正確的設計,保持後端彈性。

3. 驗證

  • 3.1 確認 TypeScript 編譯無新錯誤(與本次變更相關的錯誤)
  • 3.2 確認後端 API 仍正常運作(需手動測試)
  • 3.3 測試上傳 -> 處理 -> 結果查看的完整流程(需手動測試)