mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-26 03:31:24 +08:00
refactor(ocr): ocrImage实现使用OcrService并更新日志上下文
将ocrImage函数从useOcr钩子移动到OcrService中,提高代码复用性 更新日志服务上下文从'main'改为'renderer'以更准确反映模块位置
This commit is contained in:
parent
1f38428716
commit
e59279e962
@ -1,4 +1,5 @@
|
||||
import { loggerService } from '@logger'
|
||||
import * as OcrService from '@renderer/services/OcrService'
|
||||
import { useAppSelector } from '@renderer/store'
|
||||
import { ImageFileMetadata, isImageFile, SupportedOcrFile } from '@renderer/types'
|
||||
import { uuid } from '@renderer/utils'
|
||||
@ -15,9 +16,10 @@ export const useOcr = () => {
|
||||
* 对图片文件进行OCR识别
|
||||
* @param image 图片文件元数据
|
||||
* @returns OCR识别结果的Promise
|
||||
* @throws OCR失败时抛出错误
|
||||
*/
|
||||
const ocrImage = async (image: ImageFileMetadata) => {
|
||||
return window.api.ocr.ocr(image, imageProvider)
|
||||
return OcrService.ocr(image, imageProvider)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,7 +48,6 @@ export const useOcr = () => {
|
||||
}
|
||||
|
||||
return {
|
||||
ocrImage,
|
||||
ocr
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { OcrProvider, OcrResult, SupportedOcrFile } from '@renderer/types'
|
||||
|
||||
// const logger = loggerService.withContext('main:OcrService')
|
||||
// const logger = loggerService.withContext('renderer:OcrService')
|
||||
|
||||
/**
|
||||
* ocr a file
|
||||
|
||||
Loading…
Reference in New Issue
Block a user