axios.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. export type ErrorMessageMode = 'none' | 'modal' | 'message' | undefined;
  2. export interface RequestOptions {
  3. // Splicing request parameters to url
  4. joinParamsToUrl?: boolean;
  5. // Format request parameter time
  6. formatDate?: boolean;
  7. // Whether to process the request result
  8. isTransformResponse?: boolean;
  9. // Whether to return native response headers
  10. // For example: use this attribute when you need to get the response headers
  11. isReturnNativeResponse?: boolean;
  12. // Whether to join url
  13. joinPrefix?: boolean;
  14. // Interface address, use the default apiUrl if you leave it blank
  15. apiUrl?: string;
  16. // 请求拼接路径
  17. urlPrefix?: string;
  18. // Error message prompt type
  19. errorMessageMode?: ErrorMessageMode;
  20. // Whether to add a timestamp
  21. joinTime?: boolean;
  22. ignoreCancelToken?: boolean;
  23. // Whether to send token in header
  24. withToken?: boolean;
  25. useResult?: boolean;
  26. }
  27. // export interface Result<T = any> {
  28. // code: number;
  29. // type: 'success' | 'error' | 'warning';
  30. // message: string | T;
  31. // result: T;
  32. // }
  33. export type Result = FlawResult;
  34. //TODO 后端不标准的返回字段
  35. export interface FlawResult<T = any> {
  36. code: number;
  37. type?: 'success' | 'error' | 'warning';
  38. message: T;
  39. result?: T;
  40. error?: string;
  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. }