feat(backend): refactor OCR client to support HTTP + subprocess dual mode

- runtime-config.js: add baseUrl field to ocr type definition
- default.cjs: add ocr.baseUrl default (empty string = subprocess mode)
- runtime.js: add OCR_BASE_URL env var parsing
- ocr.js: add HTTP mode (when OCR_BASE_URL set) alongside existing subprocess mode
  - resolveOcrMode() detects mode from runtimeConfig.ocr.baseUrl
  - callOcrViaHttp() calls FastAPI endpoints directly with payload
  - warmupOcrViaHttp() calls /health endpoint for HTTP mode warmup
  - callOcrRequest() routes between HTTP and subprocess based on mode
  - All 5 original exports preserved (recognizeTencentCaptcha, etc.)
  - Subprocess mode remains backward compatible (default when no OCR_BASE_URL)
This commit is contained in:
yml
2026-05-19 23:09:30 +08:00
parent f87238b6c0
commit bc5fd4212d
4 changed files with 437 additions and 216 deletions
+1
View File
@@ -20,6 +20,7 @@ module.exports = {
ocr: {
projectRoot: path.resolve(__dirname, '../subservices/ocr-worker'),
baseUrl: '',
},
data: {