props.d.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { IBaseProps } from '../_util/base';
  2. export type Status = 'uploading' | 'done' | 'error';
  3. export interface File {
  4. /**
  5. * @description 唯一标识符,不设置时会自动生成
  6. */
  7. uid?: string;
  8. /**
  9. * @description 图片的资源地址
  10. */
  11. url: string;
  12. /**
  13. * @description 上传状态
  14. */
  15. status?: Status;
  16. }
  17. export interface LocalFile {
  18. path: string;
  19. size?: number;
  20. }
  21. export interface IUploaderProps extends IBaseProps {
  22. /**
  23. * @description 默认已经上传的文件列表
  24. * @default []
  25. */
  26. defaultFileList: File[];
  27. /**
  28. * @description 已经上传的文件列表(受控)
  29. */
  30. fileList: File[];
  31. /**
  32. * @description 上传图片的最大数量
  33. */
  34. maxCount: number;
  35. /**
  36. * @description 图片缩放模式和裁剪模式
  37. * @default 'scaleToFill'
  38. */
  39. imageMode: 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'center' | 'left' | 'right' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
  40. /**
  41. * @description 视频选择的来源
  42. * @default ['album', 'camera']
  43. */
  44. sourceType: ['album'] | ['camera'] | ['camera', 'album'];
  45. /**
  46. * @description 图片上传前的回调函数,返回 false 可终止图片上传,支持返回 Promise
  47. */
  48. onBeforeUpload: (localFileList: LocalFile[]) => boolean | Promise<LocalFile[]>;
  49. /**
  50. * @description 选择图片失败回调
  51. */
  52. onChooseImageError: (err: any) => void;
  53. /**
  54. * @description 已上传的文件列表变化时触发
  55. */
  56. onChange: (v: Array<File>) => void;
  57. /**
  58. * @description 删除当前列表中的图片时触发,包括上传成功和上传失败的图片,如果返回 false 表示阻止删除,支持返回 Promise
  59. */
  60. onRemove: (v: File) => boolean | Promise<boolean>;
  61. /**
  62. * @description 点击图片进行预览时触发,会覆盖默认的预览功能
  63. */
  64. onPreview: (v: Array<File>) => void;
  65. /**
  66. * @description 自定义上传方式,只在不存在action字段时生效
  67. */
  68. onUpload: (localFile: LocalFile) => Promise<string>;
  69. }
  70. export declare const UploaderDefaultProps: Partial<IUploaderProps>;