mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 22:39:36 +08:00
feat(types): 添加图片文件类型守卫函数
添加 ImageFileMetadata 类型和 isImageFile 类型守卫函数,用于检查文件是否为图片类型
This commit is contained in:
parent
807861d207
commit
69cb81db85
@ -100,3 +100,16 @@ export enum FileTypes {
|
|||||||
DOCUMENT = 'document',
|
DOCUMENT = 'document',
|
||||||
OTHER = 'other'
|
OTHER = 'other'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ImageFileMetadata = FileMetadata & {
|
||||||
|
type: FileTypes.IMAGE
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型守卫函数,用于检查一个 FileMetadata 是否为图片文件元数据
|
||||||
|
* @param file - 要检查的文件元数据
|
||||||
|
* @returns 如果文件是图片类型则返回 true
|
||||||
|
*/
|
||||||
|
export const isImageFile = (file: FileMetadata): file is ImageFileMetadata => {
|
||||||
|
return file.type === FileTypes.IMAGE
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user