axios.d.ts 1.5 KB

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