Blame view

types/axios.d.ts 1.39 KB
1
2
export type ErrorMessageMode = 'none' | 'modal' | 'message' | undefined;
陈文彬 authored
3
export interface RequestOptions {
Vben authored
4
  // Splicing request parameters to url
陈文彬 authored
5
  joinParamsToUrl?: boolean;
Vben authored
6
  // Format request parameter time
陈文彬 authored
7
  formatDate?: boolean;
Vben authored
8
  // Whether to process the request result
9
  isTransformResponse?: boolean;
Vben authored
10
11
  // Whether to return native response headers
  // For example: use this attribute when you need to get the response headers
12
  isReturnNativeResponse?: boolean;
Vben authored
13
  // Whether to join url
陈文彬 authored
14
  joinPrefix?: boolean;
Vben authored
15
  // Interface address, use the default apiUrl if you leave it blank
陈文彬 authored
16
  apiUrl?: string;
17
18
  // 请求拼接路径
  urlPrefix?: string;
Vben authored
19
  // Error message prompt type
20
  errorMessageMode?: ErrorMessageMode;
Vben authored
21
  // Whether to add a timestamp
vben authored
22
  joinTime?: boolean;
Vben authored
23
  ignoreCancelToken?: boolean;
24
25
  // Whether to send token in header
  withToken?: boolean;
26
27
  // 请求重试机制
  retryRequest?: RetryRequest;
陈文彬 authored
28
29
}
30
31
32
33
34
export interface RetryRequest {
  isOpenRetry: boolean;
  count: number;
  waitTime: number;
}
陈文彬 authored
35
36
37
38
39
40
export interface Result<T = any> {
  code: number;
  type: 'success' | 'error' | 'warning';
  message: string;
  result: T;
}
Vben authored
41
42

// multipart/form-data: upload file
jq authored
43
export interface UploadFileParams {
Vben authored
44
  // Other parameters
Vben authored
45
  data?: Recordable;
Vben authored
46
  // File parameter interface field name
jq authored
47
  name?: string;
Vben authored
48
  // file name
jq authored
49
  file: File | Blob;
Vben authored
50
  // file name
jq authored
51
  filename?: string;
52
  [key: string]: any;
jq authored
53
}