axios.d.ts 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. }
  26. // export interface Result<T = any> {
  27. // code: number;
  28. // type: 'success' | 'error' | 'warning';
  29. // message: string | T;
  30. // result: T;
  31. // }
  32. export type Result = FlawResult;
  33. //TODO 后端不标准的返回字段
  34. export interface FlawResult<T = any> {
  35. code: number;
  36. type?: 'success' | 'error' | 'warning';
  37. message: T;
  38. result?: T;
  39. error?: string;
  40. }
  41. // multipart/form-data: upload file
  42. export interface UploadFileParams {
  43. // Other parameters
  44. data?: Recordable;
  45. // File parameter interface field name
  46. name?: string;
  47. // file name
  48. file: File | Blob;
  49. // file name
  50. filename?: string;
  51. [key: string]: any;
  52. }