@dcloudio/uni-app-x 0.4.4 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +2 -1
- package/package.json +5 -3
- package/tsconfig.json +5 -0
- package/types/app.d.ts +986 -0
- package/types/common.d.ts +7 -0
- package/types/index.d.ts +3 -0
- package/types/native/AsyncApiResult.d.ts +1 -0
- package/types/native/CSSStyleDeclaration.d.ts +20 -0
- package/types/native/CustomEvent.d.ts +3 -0
- package/types/native/DOMRect.d.ts +56 -0
- package/types/native/DrawableContext.d.ts +102 -11
- package/types/native/Event.d.ts +25 -8
- package/types/native/IApp.d.ts +1 -0
- package/types/native/IDocument.d.ts +1 -0
- package/types/native/INode.d.ts +140 -5
- package/types/native/IPage.d.ts +1 -0
- package/types/native/IPageManager.d.ts +1 -0
- package/types/native/ITabsNode.d.ts +1 -0
- package/types/native/IWebViewNode.d.ts +28 -0
- package/types/native/ImageErrorEvent.d.ts +13 -0
- package/types/native/ImageLoadEvent.d.ts +17 -0
- package/types/native/MouseEvent.d.ts +44 -2
- package/types/native/NodeData.d.ts +1 -0
- package/types/native/PageEvent.d.ts +1 -0
- package/types/native/PageScrollEvent.d.ts +3 -0
- package/types/native/ResizeEvent.d.ts +26 -6
- package/types/native/RichTextItemClickEvent.d.ts +21 -0
- package/types/native/ScrollEvent.d.ts +27 -9
- package/types/native/SourceError.d.ts +38 -0
- package/types/native/TabTapEvent.d.ts +10 -2
- package/types/native/TouchEvent.d.ts +37 -10
- package/types/native/UTSError.d.ts +5 -2
- package/types/native/UTSPromise.d.ts +74 -0
- package/types/native/UniAggregateError.d.ts +17 -0
- package/types/native/UniAppManager.d.ts +1 -0
- package/types/native/UniError.d.ts +54 -5
- package/types/native/WebViewErrorEvent.d.ts +13 -0
- package/types/native/WebViewLoadedEvent.d.ts +8 -0
- package/types/native/WebViewLoadingEvent.d.ts +8 -0
- package/types/native/WebViewMessageEvent.d.ts +13 -0
- package/types/native/index.d.ts +15 -1
- package/types/page.d.ts +1729 -0
- package/types/shims-vue.d.ts +12 -0
- package/types/uni/core/lib/performance/index.d.ts +21 -0
- package/types/uni/core/lib/performance/interface.d.ts +152 -0
- package/types/uni/core/lib/ui/create-selector-query/index.d.ts +4 -0
- package/types/uni/ext/index.d.ts +0 -1
- package/types/uni/ext/lib/uni-audio/utssdk/index.d.ts +4 -0
- package/types/uni/ext/lib/uni-exit/utssdk/interface.d.ts +4 -4
- package/types/uni/ext/lib/uni-file-manager/utssdk/index.d.ts +2 -0
- package/types/uni/ext/lib/uni-file-manager/utssdk/interface.d.ts +6 -6
- package/types/uni/ext/lib/uni-getAppBaseInfo/utssdk/interface.d.ts +1 -1
- package/types/uni/ext/lib/uni-getDeviceInfo/utssdk/interface.d.ts +1 -1
- package/types/uni/ext/lib/uni-getLocation-system/utssdk/interface.d.ts +39 -17
- package/types/uni/ext/lib/uni-getNetworkType/utssdk/interface.d.ts +3 -10
- package/types/uni/ext/lib/uni-getRecorderManager/utssdk/index.d.ts +2 -0
- package/types/uni/ext/lib/uni-getSystemInfo/utssdk/interface.d.ts +3 -10
- package/types/uni/ext/lib/uni-media/utssdk/interface.d.ts +55 -55
- package/types/uni/ext/lib/uni-network/utssdk/app-ios/index.d.ts +67 -0
- package/types/uni/ext/lib/uni-network/utssdk/app-ios/interface.d.ts +530 -0
- package/types/uni/ext/lib/uni-network/utssdk/index.d.ts +10 -4
- package/types/uni/ext/lib/uni-network/utssdk/interface.d.ts +37 -77
- package/types/uni/ext/lib/uni-openAppAuthorizeSetting/utssdk/interface.d.ts +3 -3
- package/types/uni/ext/lib/uni-prompt/utssdk/index.d.ts +0 -8
- package/types/uni/ext/lib/uni-prompt/utssdk/interface.d.ts +35 -112
- package/types/uni/ext/lib/uni-storage/utssdk/interface.d.ts +13 -13
- package/types/uni/ext/lib/uni-websocket/utssdk/index.d.ts +2 -0
- package/types/uni/ext/lib/uni-websocket/utssdk/interface.d.ts +11 -18
- package/types/uni-cloud/index.d.ts +333 -274
- package/types/vue/index.d.ts +1 -1
- package/types/uni/ext/lib/uni-getLocation-tencent/utssdk/index.d.ts +0 -15
- package/types/uni/ext/lib/uni-getLocation-tencent/utssdk/interface.d.ts +0 -93
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
|
|
2
|
+
export type Request = (param: RequestOptions) => RequestTask | null;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 网络请求参数
|
|
6
|
+
*/
|
|
7
|
+
export type RequestOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* 开发者服务器接口地址
|
|
10
|
+
*/
|
|
11
|
+
url: string,
|
|
12
|
+
/**
|
|
13
|
+
* 请求的参数 Object|String类型
|
|
14
|
+
* @type {RequestDataOptions}
|
|
15
|
+
*/
|
|
16
|
+
data?: any | null,
|
|
17
|
+
/**
|
|
18
|
+
* 设置请求的 header,header 中不能设置 Referer
|
|
19
|
+
*/
|
|
20
|
+
header?: UTSJSONObject,
|
|
21
|
+
/**
|
|
22
|
+
* 请求类型 默认值GET
|
|
23
|
+
* GET|POST|PUT|DELETE|HEAD|OPTIONS
|
|
24
|
+
* @type {RequestMethod}
|
|
25
|
+
*/
|
|
26
|
+
method?: string | null,
|
|
27
|
+
/**
|
|
28
|
+
* 超时时间,单位 ms
|
|
29
|
+
*/
|
|
30
|
+
timeout?: number | null,
|
|
31
|
+
/**
|
|
32
|
+
* 如果设为 json,会对返回的数据进行一次 JSON.parse,非 json 不会进行 JSON.parse
|
|
33
|
+
*/
|
|
34
|
+
dataType?: string | null,
|
|
35
|
+
/**
|
|
36
|
+
* 设置响应的数据类型。
|
|
37
|
+
*
|
|
38
|
+
* @deprecated 不支持
|
|
39
|
+
*/
|
|
40
|
+
responseType?: string | null,
|
|
41
|
+
/**
|
|
42
|
+
* 验证 ssl 证书
|
|
43
|
+
*/
|
|
44
|
+
sslVerify?: boolean | null,
|
|
45
|
+
/**
|
|
46
|
+
* 跨域请求时是否携带凭证(cookies)
|
|
47
|
+
*/
|
|
48
|
+
withCredentials?: boolean | null,
|
|
49
|
+
/**
|
|
50
|
+
* DNS解析时优先使用ipv4
|
|
51
|
+
*/
|
|
52
|
+
firstIpv4?: boolean | null,
|
|
53
|
+
/**
|
|
54
|
+
* 网络请求成功回调。
|
|
55
|
+
*/
|
|
56
|
+
success?: RequestSuccessCallback | null,
|
|
57
|
+
/**
|
|
58
|
+
* 网络请求失败回调。
|
|
59
|
+
*/
|
|
60
|
+
fail?: RequestFailCallback | null,
|
|
61
|
+
/**
|
|
62
|
+
* 网络请求完成回调,成功或者失败都会调用。
|
|
63
|
+
*/
|
|
64
|
+
complete?: RequestCompleteCallback | null
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type RequestSuccess = {
|
|
68
|
+
/**
|
|
69
|
+
* 开发者服务器返回的数据
|
|
70
|
+
* @type {RequestDataOptions}
|
|
71
|
+
*/
|
|
72
|
+
data: any | null,
|
|
73
|
+
/**
|
|
74
|
+
* 开发者服务器返回的 HTTP 状态码
|
|
75
|
+
*/
|
|
76
|
+
statusCode: number,
|
|
77
|
+
/**
|
|
78
|
+
* 开发者服务器返回的 HTTP Response Header
|
|
79
|
+
*/
|
|
80
|
+
header: any,
|
|
81
|
+
/**
|
|
82
|
+
* 开发者服务器返回的 cookies,格式为字符串数组
|
|
83
|
+
*/
|
|
84
|
+
cookies: Array<string>
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type RequestFail = UniError;
|
|
88
|
+
export type RequestSuccessCallback = (option: RequestSuccess) => void;
|
|
89
|
+
export type RequestFailCallback = (option: RequestFail) => void;
|
|
90
|
+
export type RequestCompleteCallback = (option: any) => void;
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
export interface RequestTask {
|
|
94
|
+
/**
|
|
95
|
+
* abort()
|
|
96
|
+
* @description
|
|
97
|
+
* 中断网络请求。
|
|
98
|
+
* @param {void}
|
|
99
|
+
* @return {void}
|
|
100
|
+
* @tutorial https://uniapp.dcloud.net.cn/api/request/request.html#request
|
|
101
|
+
* @uniPlatform {
|
|
102
|
+
* "app": {
|
|
103
|
+
* "android": {
|
|
104
|
+
* "osVer": "4.4",
|
|
105
|
+
* "uniVer": "√",
|
|
106
|
+
* "unixVer": "3.9.0"
|
|
107
|
+
* },
|
|
108
|
+
* "ios": {
|
|
109
|
+
* "osVer": "9.0",
|
|
110
|
+
* "uniVer": "√",
|
|
111
|
+
* "unixVer": "3.9.0"
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
* }
|
|
115
|
+
* @example
|
|
116
|
+
```typescript
|
|
117
|
+
var requestTask = uni.request({
|
|
118
|
+
url: 'http://192.168.12.106:8080/postHalo', //仅为示例,并非真实接口地址。
|
|
119
|
+
complete: ()=> {}
|
|
120
|
+
});
|
|
121
|
+
requestTask.abort();
|
|
122
|
+
```
|
|
123
|
+
*/
|
|
124
|
+
abort(): void
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
//===============================上传==================================
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
export type UploadFile = (options: UploadFileOptions) => UploadTask | null;
|
|
132
|
+
export type UploadFileOptionFiles = {
|
|
133
|
+
/**
|
|
134
|
+
* multipart 提交时,表单的项目名,默认为 file,如果 name 不填或填的值相同,可能导致服务端读取文件时只能读取到一个文件。
|
|
135
|
+
*/
|
|
136
|
+
name: string | null,
|
|
137
|
+
/**
|
|
138
|
+
* 要上传文件资源的路径
|
|
139
|
+
*/
|
|
140
|
+
uri: string,
|
|
141
|
+
/**
|
|
142
|
+
* 要上传的文件对象,仅H5(2.6.15+)支持
|
|
143
|
+
*/
|
|
144
|
+
file: any | null
|
|
145
|
+
};
|
|
146
|
+
export type UploadFileSuccess = {
|
|
147
|
+
/**
|
|
148
|
+
* 开发者服务器返回的数据
|
|
149
|
+
*/
|
|
150
|
+
data: string,
|
|
151
|
+
/**
|
|
152
|
+
* 开发者服务器返回的 HTTP 状态码
|
|
153
|
+
*/
|
|
154
|
+
statusCode: number
|
|
155
|
+
};
|
|
156
|
+
export type UploadFileSuccessCallback = (result: UploadFileSuccess) => void;
|
|
157
|
+
export type UploadFileFail = UniError;
|
|
158
|
+
export type UploadFileFailCallback = (result: UploadFileFail) => void;
|
|
159
|
+
|
|
160
|
+
export type UploadFileCompleteCallback = (result: any) => void;
|
|
161
|
+
export type UploadFileOptions = {
|
|
162
|
+
/**
|
|
163
|
+
* 开发者服务器 url
|
|
164
|
+
*/
|
|
165
|
+
url: string,
|
|
166
|
+
/**
|
|
167
|
+
* 要上传文件资源的路径
|
|
168
|
+
*/
|
|
169
|
+
filePath?: string | null,
|
|
170
|
+
/**
|
|
171
|
+
* 文件对应的 key , 开发者在服务器端通过这个 key 可以获取到文件二进制内容
|
|
172
|
+
*/
|
|
173
|
+
name?: string | null,
|
|
174
|
+
/**
|
|
175
|
+
* 需要上传的文件列表。
|
|
176
|
+
*/
|
|
177
|
+
files?: (UploadFileOptionFiles[]) | null,
|
|
178
|
+
/**
|
|
179
|
+
* HTTP 请求 Header, header 中不能设置 Referer
|
|
180
|
+
*/
|
|
181
|
+
header?: UTSJSONObject | null,
|
|
182
|
+
/**
|
|
183
|
+
* HTTP 请求中其他额外的 form data
|
|
184
|
+
*/
|
|
185
|
+
formData?: UTSJSONObject | null,
|
|
186
|
+
/**
|
|
187
|
+
* 超时时间,单位 ms
|
|
188
|
+
*/
|
|
189
|
+
timeout?: number | null,
|
|
190
|
+
/**
|
|
191
|
+
* 成功返回的回调函数
|
|
192
|
+
*/
|
|
193
|
+
success?: UploadFileSuccessCallback | null,
|
|
194
|
+
/**
|
|
195
|
+
* 失败的回调函数
|
|
196
|
+
*/
|
|
197
|
+
fail?: UploadFileFailCallback | null,
|
|
198
|
+
/**
|
|
199
|
+
* 结束的回调函数(调用成功、失败都会执行)
|
|
200
|
+
*/
|
|
201
|
+
complete?: UploadFileCompleteCallback | null
|
|
202
|
+
};
|
|
203
|
+
export type OnProgressUpdateResult = {
|
|
204
|
+
/**
|
|
205
|
+
* 上传进度百分比
|
|
206
|
+
*/
|
|
207
|
+
progress: number,
|
|
208
|
+
/**
|
|
209
|
+
* 已经上传的数据长度,单位 Bytes
|
|
210
|
+
*/
|
|
211
|
+
totalBytesSent: number,
|
|
212
|
+
/**
|
|
213
|
+
* 预期需要上传的数据总长度,单位 Bytes
|
|
214
|
+
*/
|
|
215
|
+
totalBytesExpectedToSend: number
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
export type UploadFileProgressUpdateCallback = (result: OnProgressUpdateResult) => void
|
|
219
|
+
export interface UploadTask {
|
|
220
|
+
/**
|
|
221
|
+
* abort()
|
|
222
|
+
* @description
|
|
223
|
+
* 中断上传任务。
|
|
224
|
+
* @param {void}
|
|
225
|
+
* @return {void}
|
|
226
|
+
* @tutorial https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile
|
|
227
|
+
* @uniPlatform {
|
|
228
|
+
* "app": {
|
|
229
|
+
* "android": {
|
|
230
|
+
* "osVer": "4.4",
|
|
231
|
+
* "uniVer": "√",
|
|
232
|
+
* "unixVer": "3.9.0"
|
|
233
|
+
* },
|
|
234
|
+
* "ios": {
|
|
235
|
+
* "osVer": "9.0",
|
|
236
|
+
* "uniVer": "√",
|
|
237
|
+
* "unixVer": "3.9.0"
|
|
238
|
+
* }
|
|
239
|
+
* }
|
|
240
|
+
* }
|
|
241
|
+
* @example
|
|
242
|
+
```typescript
|
|
243
|
+
var uploadTask = uni.uploadFile({
|
|
244
|
+
url: 'http://192.168.12.106:8080/uploadFile', //仅为示例,并非真实接口地址。
|
|
245
|
+
complete: ()=> {}
|
|
246
|
+
});
|
|
247
|
+
uploadTask.abort();
|
|
248
|
+
```
|
|
249
|
+
*/
|
|
250
|
+
abort(): void,
|
|
251
|
+
/**
|
|
252
|
+
* onProgressUpdate()
|
|
253
|
+
* @description
|
|
254
|
+
* 监听上传进度变化。
|
|
255
|
+
* @param {UploadFileProgressUpdateCallback} callback
|
|
256
|
+
* @return {void}
|
|
257
|
+
* @tutorial https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile
|
|
258
|
+
* @uniPlatform {
|
|
259
|
+
* "app": {
|
|
260
|
+
* "android": {
|
|
261
|
+
* "osVer": "4.4",
|
|
262
|
+
* "uniVer": "√",
|
|
263
|
+
* "unixVer": "3.9.0"
|
|
264
|
+
* },
|
|
265
|
+
* "ios": {
|
|
266
|
+
* "osVer": "9.0",
|
|
267
|
+
* "uniVer": "√",
|
|
268
|
+
* "unixVer": "3.9.0"
|
|
269
|
+
* }
|
|
270
|
+
* }
|
|
271
|
+
* }
|
|
272
|
+
* @example
|
|
273
|
+
```typescript
|
|
274
|
+
uploadTask.onProgressUpdate((res) => {
|
|
275
|
+
console.log('上传进度' + res.progress);
|
|
276
|
+
console.log('已经上传的数据长度' + res.totalBytesSent);
|
|
277
|
+
console.log('预期需要上传的数据总长度' + res.totalBytesExpectedToSend);
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
*/
|
|
281
|
+
onProgressUpdate(callback: UploadFileProgressUpdateCallback): void,
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
//===============================下载==================================
|
|
285
|
+
|
|
286
|
+
export type DownloadFile = (options: DownloadFileOptions) => DownloadTask | null;
|
|
287
|
+
export type DownloadFileSuccess = {
|
|
288
|
+
/**
|
|
289
|
+
* 临时文件路径,下载后的文件会存储到一个临时文件
|
|
290
|
+
*/
|
|
291
|
+
tempFilePath: string,
|
|
292
|
+
/**
|
|
293
|
+
* 开发者服务器返回的 HTTP 状态码
|
|
294
|
+
*/
|
|
295
|
+
statusCode: number
|
|
296
|
+
};
|
|
297
|
+
export type DownloadFileSuccessCallback = (result: DownloadFileSuccess) => void;
|
|
298
|
+
export type DownloadFileFail = UniError;
|
|
299
|
+
export type DownloadFileFailCallback = (result: DownloadFileFail) => void;
|
|
300
|
+
export type DownloadFileComplete = any;
|
|
301
|
+
export type DownloadFileCompleteCallback = (result: DownloadFileComplete) => void;
|
|
302
|
+
export type DownloadFileOptions = {
|
|
303
|
+
/**
|
|
304
|
+
* 下载资源的 url
|
|
305
|
+
*/
|
|
306
|
+
url: string,
|
|
307
|
+
/**
|
|
308
|
+
* HTTP 请求 Header,header 中不能设置 Referer
|
|
309
|
+
*/
|
|
310
|
+
header?: UTSJSONObject | null,
|
|
311
|
+
/**
|
|
312
|
+
* 超时时间,单位 ms
|
|
313
|
+
*/
|
|
314
|
+
timeout?: number | null,
|
|
315
|
+
/**
|
|
316
|
+
* 下载成功后以 tempFilePath 的形式传给页面,res = {tempFilePath: '文件的临时路径'}
|
|
317
|
+
*/
|
|
318
|
+
success?: DownloadFileSuccessCallback | null,
|
|
319
|
+
/**
|
|
320
|
+
* 失败的回调函数
|
|
321
|
+
*/
|
|
322
|
+
fail?: DownloadFileFailCallback | null,
|
|
323
|
+
/**
|
|
324
|
+
* 结束的回调函数(调用成功、失败都会执行)
|
|
325
|
+
*/
|
|
326
|
+
complete?: DownloadFileCompleteCallback | null
|
|
327
|
+
};
|
|
328
|
+
export type OnProgressDownloadResult = {
|
|
329
|
+
/**
|
|
330
|
+
* 下载进度百分比
|
|
331
|
+
*/
|
|
332
|
+
progress: number,
|
|
333
|
+
/**
|
|
334
|
+
* 已经下载的数据长度,单位 Bytes
|
|
335
|
+
*/
|
|
336
|
+
totalBytesWritten: number,
|
|
337
|
+
/**
|
|
338
|
+
* 预期需要下载的数据总长度,单位 Bytes
|
|
339
|
+
*/
|
|
340
|
+
totalBytesExpectedToWrite: number
|
|
341
|
+
};
|
|
342
|
+
export type DownloadFileProgressUpdateCallback = (result: OnProgressDownloadResult) => void;
|
|
343
|
+
export interface DownloadTask {
|
|
344
|
+
/**
|
|
345
|
+
* abort()
|
|
346
|
+
* @description
|
|
347
|
+
* 中断下载任务。
|
|
348
|
+
* @param {void}
|
|
349
|
+
* @return {void}
|
|
350
|
+
* @tutorial https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile
|
|
351
|
+
* @uniPlatform {
|
|
352
|
+
* "app": {
|
|
353
|
+
* "android": {
|
|
354
|
+
* "osVer": "4.4",
|
|
355
|
+
* "uniVer": "√",
|
|
356
|
+
* "unixVer": "3.9.0"
|
|
357
|
+
* },
|
|
358
|
+
* "ios": {
|
|
359
|
+
* "osVer": "9.0",
|
|
360
|
+
* "uniVer": "√",
|
|
361
|
+
* "unixVer": "3.9.0"
|
|
362
|
+
* }
|
|
363
|
+
* }
|
|
364
|
+
* }
|
|
365
|
+
* @example
|
|
366
|
+
```typescript
|
|
367
|
+
var downloadTask = uni.downloadFile({
|
|
368
|
+
url: 'https://www.example.com/file/test', //仅为示例,并非真实接口地址。
|
|
369
|
+
complete: ()=> {}
|
|
370
|
+
});
|
|
371
|
+
downloadTask.abort();
|
|
372
|
+
```
|
|
373
|
+
*/
|
|
374
|
+
abort(): void,
|
|
375
|
+
/**
|
|
376
|
+
* onProgressUpdate()
|
|
377
|
+
* @description
|
|
378
|
+
* 监听下载进度变化。
|
|
379
|
+
* @param {DownloadFileProgressUpdateCallback} callback
|
|
380
|
+
* @return {void}
|
|
381
|
+
* @tutorial https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile
|
|
382
|
+
* @uniPlatform {
|
|
383
|
+
* "app": {
|
|
384
|
+
* "android": {
|
|
385
|
+
* "osVer": "4.4",
|
|
386
|
+
* "uniVer": "√",
|
|
387
|
+
* "unixVer": "3.9.0"
|
|
388
|
+
* },
|
|
389
|
+
* "ios": {
|
|
390
|
+
* "osVer": "9.0",
|
|
391
|
+
* "uniVer": "√",
|
|
392
|
+
* "unixVer": "3.9.0"
|
|
393
|
+
* }
|
|
394
|
+
* }
|
|
395
|
+
* }
|
|
396
|
+
* @example
|
|
397
|
+
```typescript
|
|
398
|
+
downloadTask.onProgressUpdate((res) => {
|
|
399
|
+
console.log('下载进度' + res.progress);
|
|
400
|
+
console.log('已经下载的数据长度' + res.totalBytesWritten);
|
|
401
|
+
console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
|
|
402
|
+
});
|
|
403
|
+
```
|
|
404
|
+
*/
|
|
405
|
+
onProgressUpdate(callback: DownloadFileProgressUpdateCallback): void,
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
export interface Uni {
|
|
410
|
+
/**
|
|
411
|
+
* Request()
|
|
412
|
+
* @description
|
|
413
|
+
* 发起网络请求。
|
|
414
|
+
* @param {RequestOptions} options
|
|
415
|
+
* @return {RequestTask | null}
|
|
416
|
+
* @tutorial https://uniapp.dcloud.net.cn/api/request/request.html
|
|
417
|
+
* @uniPlatform {
|
|
418
|
+
* "app": {
|
|
419
|
+
* "android": {
|
|
420
|
+
* "osVer": "4.4",
|
|
421
|
+
* "uniVer": "√",
|
|
422
|
+
* "unixVer": "3.9.0"
|
|
423
|
+
* },
|
|
424
|
+
* "ios": {
|
|
425
|
+
* "osVer": "9.0",
|
|
426
|
+
* "uniVer": "√",
|
|
427
|
+
* "unixVer": "3.9.0"
|
|
428
|
+
* }
|
|
429
|
+
* }
|
|
430
|
+
* }
|
|
431
|
+
* @example
|
|
432
|
+
```typescript
|
|
433
|
+
uni.request({
|
|
434
|
+
url: "http://192.168.12.106:8080/postHalo",
|
|
435
|
+
dataType: "json",
|
|
436
|
+
responseType: "json",
|
|
437
|
+
method: "POST",
|
|
438
|
+
data: {
|
|
439
|
+
platform: "ios",
|
|
440
|
+
},
|
|
441
|
+
// header: {
|
|
442
|
+
// "Content-Type": "application/json",
|
|
443
|
+
// },
|
|
444
|
+
timeout: 6000,
|
|
445
|
+
sslVerify: false,
|
|
446
|
+
withCredentials: false,
|
|
447
|
+
firstIpv4: false,
|
|
448
|
+
success(res) {
|
|
449
|
+
console.log("success :", res.data);
|
|
450
|
+
},
|
|
451
|
+
fail(e) {
|
|
452
|
+
console.log(e);
|
|
453
|
+
},
|
|
454
|
+
complete(res) {
|
|
455
|
+
console.log("complete :", res);
|
|
456
|
+
},
|
|
457
|
+
});
|
|
458
|
+
```
|
|
459
|
+
*/
|
|
460
|
+
request: Request,
|
|
461
|
+
/**
|
|
462
|
+
* UploadFile()
|
|
463
|
+
* @description
|
|
464
|
+
* 将本地资源上传到开发者服务器。
|
|
465
|
+
* @param {UploadFileOptions} options
|
|
466
|
+
* @return {UploadTask | null}
|
|
467
|
+
* @tutorial https://uniapp.dcloud.net.cn/api/request/network-file.html#uploadfile
|
|
468
|
+
* @uniPlatform {
|
|
469
|
+
* "app": {
|
|
470
|
+
* "android": {
|
|
471
|
+
* "osVer": "4.4",
|
|
472
|
+
* "uniVer": "√",
|
|
473
|
+
* "unixVer": "3.9.0"
|
|
474
|
+
* },
|
|
475
|
+
* "ios": {
|
|
476
|
+
* "osVer": "9.0",
|
|
477
|
+
* "uniVer": "√",
|
|
478
|
+
* "unixVer": "3.9.0"
|
|
479
|
+
* }
|
|
480
|
+
* }
|
|
481
|
+
* }
|
|
482
|
+
* @example
|
|
483
|
+
```typescript
|
|
484
|
+
uni.uploadFile({
|
|
485
|
+
url: 'http://192.168.12.106:8080/uploadFile', //仅为示例,非真实的接口地址
|
|
486
|
+
filePath: "/static/logo.png",
|
|
487
|
+
name: 'file',
|
|
488
|
+
formData: {
|
|
489
|
+
'user': 'test'
|
|
490
|
+
},
|
|
491
|
+
success: (uploadFileRes) => {
|
|
492
|
+
console.log(uploadFileRes.data);
|
|
493
|
+
}
|
|
494
|
+
});
|
|
495
|
+
```
|
|
496
|
+
*/
|
|
497
|
+
uploadFile: UploadFile,
|
|
498
|
+
/**
|
|
499
|
+
* DownloadFile()
|
|
500
|
+
* @description
|
|
501
|
+
* 下载文件资源到本地,客户端直接发起一个 HTTP GET 请求,返回文件的本地临时路径。
|
|
502
|
+
* @param {DownloadFileOptions} options
|
|
503
|
+
* @return {DownloadTask | null}
|
|
504
|
+
* @tutorial https://uniapp.dcloud.net.cn/api/request/network-file.html#downloadfile
|
|
505
|
+
* @uniPlatform {
|
|
506
|
+
* "app": {
|
|
507
|
+
* "android": {
|
|
508
|
+
* "osVer": "4.4",
|
|
509
|
+
* "uniVer": "√",
|
|
510
|
+
* "unixVer": "3.9.0"
|
|
511
|
+
* },
|
|
512
|
+
* "ios": {
|
|
513
|
+
* "osVer": "9.0",
|
|
514
|
+
* "uniVer": "√",
|
|
515
|
+
* "unixVer": "3.9.0"
|
|
516
|
+
* }
|
|
517
|
+
* }
|
|
518
|
+
* }
|
|
519
|
+
* @example
|
|
520
|
+
```typescript
|
|
521
|
+
uni.downloadFile({
|
|
522
|
+
url: "http://192.168.12.106:8080/downloadfile",
|
|
523
|
+
success(e) {
|
|
524
|
+
console.log("success111 :", e);
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
```
|
|
528
|
+
*/
|
|
529
|
+
downloadFile: DownloadFile
|
|
530
|
+
}
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
RequestSuccessCallback as RequestSuccessCallbackOrigin,
|
|
7
7
|
RequestFailCallback as RequestFailCallbackOrigin,
|
|
8
8
|
RequestCompleteCallback as RequestCompleteCallbackOrigin,
|
|
9
|
+
RequestTask as RequestTaskOrigin,
|
|
9
10
|
UploadFile as UploadFileOrigin,
|
|
10
11
|
UploadFileOptionFiles as UploadFileOptionFilesOrigin,
|
|
11
12
|
UploadFileSuccess as UploadFileSuccessOrigin,
|
|
@@ -16,6 +17,7 @@ import {
|
|
|
16
17
|
UploadFileOptions as UploadFileOptionsOrigin,
|
|
17
18
|
OnProgressUpdateResult as OnProgressUpdateResultOrigin,
|
|
18
19
|
UploadFileProgressUpdateCallback as UploadFileProgressUpdateCallbackOrigin,
|
|
20
|
+
UploadTask as UploadTaskOrigin,
|
|
19
21
|
DownloadFile as DownloadFileOrigin,
|
|
20
22
|
DownloadFileSuccess as DownloadFileSuccessOrigin,
|
|
21
23
|
DownloadFileSuccessCallback as DownloadFileSuccessCallbackOrigin,
|
|
@@ -26,17 +28,19 @@ import {
|
|
|
26
28
|
DownloadFileOptions as DownloadFileOptionsOrigin,
|
|
27
29
|
OnProgressDownloadResult as OnProgressDownloadResultOrigin,
|
|
28
30
|
DownloadFileProgressUpdateCallback as DownloadFileProgressUpdateCallbackOrigin,
|
|
31
|
+
DownloadTask as DownloadTaskOrigin,
|
|
29
32
|
Uni as UniOrigin
|
|
30
33
|
} from './interface'
|
|
31
34
|
|
|
32
35
|
declare global {
|
|
33
|
-
type Request = RequestOrigin
|
|
34
|
-
type RequestOptions = RequestOptionsOrigin
|
|
35
|
-
type RequestSuccess = RequestSuccessOrigin
|
|
36
|
+
type Request<T> = RequestOrigin<T>
|
|
37
|
+
type RequestOptions<T> = RequestOptionsOrigin<T>
|
|
38
|
+
type RequestSuccess<T> = RequestSuccessOrigin<T>
|
|
36
39
|
type RequestFail = RequestFailOrigin
|
|
37
|
-
type RequestSuccessCallback = RequestSuccessCallbackOrigin
|
|
40
|
+
type RequestSuccessCallback<T> = RequestSuccessCallbackOrigin<T>
|
|
38
41
|
type RequestFailCallback = RequestFailCallbackOrigin
|
|
39
42
|
type RequestCompleteCallback = RequestCompleteCallbackOrigin
|
|
43
|
+
type RequestTask = RequestTaskOrigin
|
|
40
44
|
type UploadFile = UploadFileOrigin
|
|
41
45
|
type UploadFileOptionFiles = UploadFileOptionFilesOrigin
|
|
42
46
|
type UploadFileSuccess = UploadFileSuccessOrigin
|
|
@@ -47,6 +51,7 @@ declare global {
|
|
|
47
51
|
type UploadFileOptions = UploadFileOptionsOrigin
|
|
48
52
|
type OnProgressUpdateResult = OnProgressUpdateResultOrigin
|
|
49
53
|
type UploadFileProgressUpdateCallback = UploadFileProgressUpdateCallbackOrigin
|
|
54
|
+
type UploadTask = UploadTaskOrigin
|
|
50
55
|
type DownloadFile = DownloadFileOrigin
|
|
51
56
|
type DownloadFileSuccess = DownloadFileSuccessOrigin
|
|
52
57
|
type DownloadFileSuccessCallback = DownloadFileSuccessCallbackOrigin
|
|
@@ -57,5 +62,6 @@ declare global {
|
|
|
57
62
|
type DownloadFileOptions = DownloadFileOptionsOrigin
|
|
58
63
|
type OnProgressDownloadResult = OnProgressDownloadResultOrigin
|
|
59
64
|
type DownloadFileProgressUpdateCallback = DownloadFileProgressUpdateCallbackOrigin
|
|
65
|
+
type DownloadTask = DownloadTaskOrigin
|
|
60
66
|
interface Uni extends UniOrigin { }
|
|
61
67
|
}
|