import { UploadFile } from 'antd'; type DUploadFile = Omit & { /** 文件id */ id?: string | number; /** 文件uid,系统自动生成 */ uid?: string | number; /** 文件来源 upload:文件对话框,remote:已上传的文件对象 */ source?: 'upload' | 'remote'; /** 文件状态 */ status?: 'error' | 'success' | 'done' | 'uploading' | 'removed'; }; /** 转换base64时的参数 */ type CompressProps = { width?: number; /** 图像高度 */ height?: number; /** 图像质量 */ quality?: number; }; type ThumbOptionProps = { /** 对目标文件进行过滤,默认只对图片格式生成缩略图 */ filter?: ((file: DUploadFile) => boolean) | Array; /** 文件大小,当上传文件大于指定值时会对缩略图进行压缩,单位为字节,默认2MB */ size?: number; /** 缩略图压缩参数,默认为 {width:300,height:200,quality:0.7} */ compress?: CompressProps | null; /** 缩略图生成失败时的回调函数 */ onError?: (err: Error) => void; /** 自定义生成base64缩略图的方法 */ getThumbUrl?: (file: DUploadFile, option: ThumbOptionProps) => Promise; }; /** * @description : 将图像文件转换为Base64格式 * @param {Blob} blob 图像文件 * @param {CompressProps} options 指定图像压缩参数,其格式为: {width:300,height:200,quality:0.7} * @return {Promise} 包含Base64字符串的Promise对象 * @example : imageToBase64(file,{ width: 300, height: 200, quality: 0.7 }).then( url => console.log( url ) ) */ declare function imageToBase64(blob: Blob, options?: CompressProps | null): Promise; /** * @description : 将传入的文件转换为UploadFile数组 * @param {any} files 目标文件对象 * @return {UploadFile[]} UploadFile数组 * @example : */ declare function getUploadFile(files: any, maxCount?: number): any[]; /** * @description : 根据传入的option对象获取缩略图参数 * @param {ThumbOptionProps} option 缩略图参数对象 * @return {ThumbOptionProps} ThumbOption对象 * @example : */ declare function getThumbOption(option?: ThumbOptionProps | null): { size: number; filter: (file: DUploadFile) => boolean; compress: { width: number; height: number; quality: number; } | null; onError: ((err: Error) => void) | undefined; getThumbUrl: ((file: DUploadFile, option: ThumbOptionProps) => Promise) | undefined; }; /** * @description : a标签下载文件 * @param {Blob | string} url a标签的下载url或文件流 * @param {string} fileName 下载文件的名称,如果缺省则尝试从url中获取,默认为: "新建文件" * @return {*} * @example : */ declare function downloadFile(url: Blob | string, fileName?: string): void; /** * @description : a标签预览文件 * @param {Blob | string} url a标签的预览url或文件流 * @return {*} * @example : */ declare function previewFile(url: Blob | string): void; /** * @description : 以递归方式深度查找一个对象 * @param {Record} object 待查找的对象 * @param {function} fn 查找函数,每次递归时执行,如果执行结果为true,则递归过程并返回当前对象 * @param {number} maxDepth 递归的最大深度,默认10 * @return {*} 查找到的对象,未查找到则返回undefined * @example : */ declare function deepFindObject(object: Record, fn: (item: any, parent: any, fieldMap: any) => boolean, maxDepth?: number): any; /** * @description : 以递归方式深度查找一个Jsx对象 * @param {Record} object 待查找的Jsx对象 * @param {function} fn 查找函数,每次递归时执行,如果执行结果为true,则停止递归过程并返回当前对象 * @param {number} maxDepth 递归的最大深度,默认10 * @return {*} 查找到的对象,未查找到则返回undefined * @example : */ declare function deepFindJsx(object: Record, fn: (item: any, parent: any) => boolean, maxDepth?: number): any; declare const _default: { imageToBase64: typeof imageToBase64; getUploadFile: typeof getUploadFile; getThumbOption: typeof getThumbOption; downloadFile: typeof downloadFile; previewFile: typeof previewFile; deepFindObject: typeof deepFindObject; deepFindJsx: typeof deepFindJsx; }; export default _default; export type { DUploadFile, ThumbOptionProps };