mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-27 04:31:27 +08:00
refactor(ocr): 简化OCR文件类型检查逻辑
使用现有的isImageFile函数替代冗余的类型检查逻辑,提高代码复用性
This commit is contained in:
parent
ae027e4978
commit
a7838e0d72
@ -1,4 +1,4 @@
|
||||
import { FileMetadata, FileTypes, Model } from '.'
|
||||
import { FileMetadata, ImageFileMetadata, isImageFile, Model } from '.'
|
||||
|
||||
export const BuiltinOcrProviderIds = {
|
||||
tesseract: 'tesseract'
|
||||
@ -62,18 +62,10 @@ export const isImageOcrProvider = (p: OcrProvider): p is ImageOcrProvider => {
|
||||
return p.capabilities.image
|
||||
}
|
||||
|
||||
export type SupportedOcrFileType = FileTypes.IMAGE
|
||||
|
||||
export const isSupportedOcrFileType = (type: FileTypes): type is SupportedOcrFileType => {
|
||||
return type === FileTypes.IMAGE
|
||||
}
|
||||
|
||||
export type SupportedOcrFile = FileMetadata & {
|
||||
type: FileTypes.IMAGE
|
||||
}
|
||||
export type SupportedOcrFile = ImageFileMetadata
|
||||
|
||||
export const isSupportedOcrFile = (file: FileMetadata): file is SupportedOcrFile => {
|
||||
return isSupportedOcrFileType(file.type)
|
||||
return isImageFile(file)
|
||||
}
|
||||
|
||||
export type OcrResult = {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user