From dc1777cc819eda0e9415e6b029f4c9316c997e07 Mon Sep 17 00:00:00 2001 From: icarus Date: Fri, 22 Aug 2025 14:34:54 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ocr):=20=E9=87=8D=E6=9E=84OCR=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E7=BB=93=E6=9E=84=E4=BB=A5=E6=94=AF=E6=8C=81=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=8F=90=E4=BE=9B=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将内置OCR提供者数组重构为单独定义的常量,并添加默认OCR提供者映射。这提高了代码的可维护性并支持未来扩展。 --- src/renderer/src/config/ocr.ts | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/renderer/src/config/ocr.ts b/src/renderer/src/config/ocr.ts index fbceb01d27..fef6c57f2e 100644 --- a/src/renderer/src/config/ocr.ts +++ b/src/renderer/src/config/ocr.ts @@ -1,11 +1,15 @@ -import { BuiltinOcrProvider } from '@renderer/types/ocr' +import { BuiltinOcrProvider, ImageOcrProvider, OcrProviderCapability } from '@renderer/types/ocr' -export const BUILTIN_OCR_PROVIDERS: BuiltinOcrProvider[] = [ - { - id: 'tesseract', - name: 'Tesseract', - capabilities: { - image: true - } +const tesseract: BuiltinOcrProvider & ImageOcrProvider = { + id: 'tesseract', + name: 'Tesseract', + capabilities: { + image: true } -] as const +} as const + +export const BUILTIN_OCR_PROVIDERS: BuiltinOcrProvider[] = [tesseract] as const + +export const DEFAULT_OCR_PROVIDER: Record = { + image: tesseract +} as const