axios.d.ts 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * @Author: wjc
  3. * @Date: 2023-05-09 09:13:16
  4. * @LastEditors: wjc
  5. * @LastEditTime: 2023-05-09 09:13:46
  6. * @Description:
  7. */
  8. export type ErrorMessageMode = 'none' | 'modal' | 'message' | undefined
  9. export type SuccessMessageMode = ErrorMessageMode
  10. export type Recordable = Recordable
  11. export interface RequestOptions {
  12. // Splicing request parameters to url
  13. joinParamsToUrl?: boolean
  14. // Format request parameter time
  15. formatDate?: boolean
  16. // Whether to process the request result
  17. isTransformResponse?: boolean
  18. // Whether to return native response headers
  19. // For example: use this attribute when you need to get the response headers
  20. isReturnNativeResponse?: boolean
  21. // Whether to join url
  22. joinPrefix?: boolean
  23. // Interface address, use the default apiUrl if you leave it blank
  24. apiUrl?: string
  25. // 请求拼接路径
  26. urlPrefix?: string
  27. // Error message prompt type
  28. errorMessageMode?: ErrorMessageMode
  29. // Success message prompt type
  30. successMessageMode?: SuccessMessageMode
  31. // Whether to add a timestamp
  32. joinTime?: boolean
  33. ignoreCancelToken?: boolean
  34. // Whether to send token in header
  35. withToken?: boolean
  36. // 请求重试机制
  37. retryRequest?: RetryRequest
  38. }
  39. export interface RetryRequest {
  40. isOpenRetry: boolean
  41. count: number
  42. waitTime: number
  43. }
  44. export interface Result<T = any> {
  45. code: number
  46. type: 'success' | 'error' | 'warning'
  47. message: string
  48. result: T
  49. }
  50. // multipart/form-data: upload file
  51. export interface UploadFileParams {
  52. // Other parameters
  53. data?: Recordable
  54. // File parameter interface field name
  55. name?: string
  56. // file name
  57. file: File | Blob
  58. // file name
  59. filename?: string
  60. [key: string]: any
  61. }