From 1f3842871606099cdbb025f1ddff6f4345eae5e0 Mon Sep 17 00:00:00 2001 From: icarus Date: Fri, 22 Aug 2025 20:53:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(useOcr):=20=E4=BF=AE=E5=A4=8D=E6=9C=AA?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=96=87=E4=BB=B6=E7=B1=BB=E5=9E=8B=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E6=8A=9B=E5=87=BA=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将不支持的OCR文件类型错误抛出逻辑移至条件判断内 --- src/renderer/src/hooks/useOcr.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/hooks/useOcr.ts b/src/renderer/src/hooks/useOcr.ts index 4513f31ad9..dab8467add 100644 --- a/src/renderer/src/hooks/useOcr.ts +++ b/src/renderer/src/hooks/useOcr.ts @@ -32,6 +32,9 @@ export const useOcr = () => { try { if (isImageFile(file)) { return ocrImage(file) + } else { + // @ts-expect-error all types should be covered + throw new Error(t('ocr.file.not_supported', { type: file.type })) } } catch (e) { logger.error('Failed to ocr.', e as Error) @@ -40,8 +43,6 @@ export const useOcr = () => { } finally { window.message.destroy(key) } - // @ts-expect-error all types should be covered - throw new Error(t('ocr.file.not_supported', { type: file.type })) } return {