types.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * 在 uniapp 的 RequestOptions 和 IUniUploadFileOptions 基础上,添加自定义参数
  3. */
  4. export type CustomRequestOptions = UniApp.RequestOptions & {
  5. query?: Record<string, any>
  6. /** 出错时是否隐藏错误提示 */
  7. hideErrorToast?: boolean
  8. } & IUniUploadFileOptions // 添加uni.uploadFile参数类型
  9. /** 主要提供给 openapi-ts-request 生成的代码使用 */
  10. export type CustomRequestOptions_ = Omit<CustomRequestOptions, 'url'>
  11. export interface HttpRequestResult<T> {
  12. promise: Promise<T>
  13. requestTask: UniApp.RequestTask
  14. }
  15. // 通用响应格式(兼容 msg + message 字段)
  16. export type IResponse<T = any> = {
  17. code: number
  18. data: T
  19. message: string
  20. [key: string]: any // 允许额外属性
  21. } | {
  22. code: number
  23. data: T
  24. msg: string
  25. [key: string]: any // 允许额外属性
  26. }
  27. // 分页请求参数
  28. export interface PageParams {
  29. page: number
  30. pageSize: number
  31. [key: string]: any
  32. }
  33. // 分页响应数据
  34. export interface PageResult<T> {
  35. list: T[]
  36. total: number
  37. page: number
  38. pageSize: number
  39. }