axios.d.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. export type ErrorMessageMode = 'none' | 'modal' | 'message' | undefined;
  2. export type SuccessMessageMode = 'none' | 'success' | 'error' | undefined;
  3. export interface RequestOptions {
  4. // 将请求参数拼接到url
  5. joinParamsToUrl?: boolean;
  6. // 格式化请求参数时间
  7. formatDate?: boolean;
  8. // 是否处理请求结果
  9. isTransformResponse?: boolean;
  10. // 是否返回本地响应头,需要获取响应头时使用此属性
  11. isReturnNativeResponse?: boolean;
  12. // Whether to join url
  13. joinPrefix?: boolean;
  14. // 接口地址,如果保留为空,则使用默认值
  15. apiUrl?: string;
  16. // 错误消息提示类型
  17. errorMessageMode?: ErrorMessageMode;
  18. // 成功消息提示类型
  19. successMessageMode?: SuccessMessageMode;
  20. // 是否添加时间戳
  21. joinTime?: boolean;
  22. ignoreCancelToken?: boolean;
  23. //是否在标头中发送令牌
  24. withToken?: boolean;
  25. }
  26. export interface Result<T = any> {
  27. code: number;
  28. type: 'success' | 'error' | 'warning';
  29. message: string;
  30. result: T;
  31. }
  32. //文件上传参数
  33. export interface UploadFileParams {
  34. // 其他参数
  35. data?: Recordable;
  36. // 文件参数接口字段名
  37. name?: string;
  38. // 文件
  39. file: File | Blob;
  40. // 文件名
  41. filename?: string;
  42. [key: string]: any;
  43. }