interface.uts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * interface.uts
  3. * uts插件接口定义文件,按规范定义接口文件可以在HBuilderX中更好的做到语法提示
  4. */
  5. /**
  6. * myApi 异步函数的参数,在type里定义函数需要的参数以及api成功、失败的相关回调函数。
  7. */
  8. export type ChooseFileOptions = {
  9. success ?: (res : ChooseFileResult) => void
  10. fail ?: (res : ChooseFileFail) => void
  11. complete ?: (res : any) => void
  12. }
  13. /**
  14. * 函数返回结果
  15. * 可以是void, 基本数据类型,自定义type, 或者其他类型。
  16. * [可选实现]
  17. */
  18. // 返回文件的路径、名称、大小
  19. export type ChooseFileResult = {
  20. size : number,
  21. path : string,
  22. name : string
  23. }
  24. /**
  25. * 错误码
  26. * 根据uni错误码规范要求,建议错误码以90开头,以下是错误码示例:
  27. * - 9010001 错误信息1
  28. * - 9010002 错误信息2
  29. */
  30. export type ChooseFileErrorCode = 9010001 | 9010002;
  31. /**
  32. * ChooseFile 的错误回调参数
  33. */
  34. export interface ChooseFileFail extends IUniError {
  35. errCode : ChooseFileErrorCode
  36. };
  37. /*
  38. 异步函数定义
  39. interface中的方法 如ChooseFile 提供给各端组件去使用
  40. */
  41. // 选择文件
  42. export type ChooseFile = (options : ChooseFileOptions) => void