@tarojs/taro 3.6.17 → 3.6.19
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/package.json +4 -4
- package/types/api/data-analysis/index.d.ts +51 -1
- package/types/api/device/accelerometer.d.ts +8 -6
- package/types/api/device/accessibility.d.ts +1 -1
- package/types/api/device/battery.d.ts +2 -2
- package/types/api/device/bluetooth-ble.d.ts +40 -17
- package/types/api/device/bluetooth-peripheral.d.ts +26 -26
- package/types/api/device/bluetooth.d.ts +37 -13
- package/types/api/device/calendar.d.ts +11 -1
- package/types/api/device/clipboard.d.ts +2 -2
- package/types/api/device/compass.d.ts +5 -5
- package/types/api/device/gyroscope.d.ts +4 -4
- package/types/api/device/iBeacon.d.ts +10 -8
- package/types/api/device/keyboard.d.ts +7 -5
- package/types/api/device/memory.d.ts +3 -4
- package/types/api/device/motion.d.ts +8 -6
- package/types/api/device/network.d.ts +12 -6
- package/types/api/device/nfc.d.ts +13 -13
- package/types/api/device/phone.d.ts +1 -1
- package/types/api/device/scan.d.ts +5 -3
- package/types/api/device/screen.d.ts +27 -11
- package/types/api/device/sms.d.ts +1 -1
- package/types/api/device/vibrate.d.ts +5 -5
- package/types/api/device/wifi.d.ts +25 -13
- package/types/api/files/index.d.ts +71 -41
- package/types/api/location/index.d.ts +166 -18
- package/types/api/media/camera.d.ts +6 -3
- package/types/api/open-api/login.d.ts +1 -1
- package/types/api/storage/background-fetch.d.ts +63 -11
- package/types/api/storage/cache-manager.d.ts +52 -1
- package/types/api/storage/index.d.ts +125 -10
- package/types/api/ui/fonts.d.ts +4 -3
- package/types/compile/config/h5.d.ts +3 -0
- package/types/compile/config/mini.d.ts +11 -8
- package/types/taro.config.d.ts +35 -4
|
@@ -7,16 +7,23 @@ declare module '../../index' {
|
|
|
7
7
|
latitude: number
|
|
8
8
|
/** 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */
|
|
9
9
|
longitude: number
|
|
10
|
+
/** 缩放比例
|
|
11
|
+
* @weapp 范围 5~18,默认值18
|
|
12
|
+
* @alipay 范围 3~19,默认值15
|
|
13
|
+
*/
|
|
14
|
+
scale?: number
|
|
15
|
+
/** 位置名 */
|
|
16
|
+
name?: string
|
|
10
17
|
/** 地址的详细说明 */
|
|
11
18
|
address?: string
|
|
19
|
+
/** 定义在拉起的地图 App 面板中需要被屏蔽的地图类 App
|
|
20
|
+
* @supported swan
|
|
21
|
+
*/
|
|
22
|
+
ignoredApps?: Array<any>
|
|
12
23
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
13
24
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
14
25
|
/** 接口调用失败的回调函数 */
|
|
15
26
|
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
16
|
-
/** 位置名 */
|
|
17
|
-
name?: string
|
|
18
|
-
/** 缩放比例,范围5~18 */
|
|
19
|
-
scale?: number
|
|
20
27
|
/** 接口调用成功的回调函数 */
|
|
21
28
|
success?: (res: TaroGeneral.CallbackResult) => void
|
|
22
29
|
}
|
|
@@ -24,20 +31,32 @@ declare module '../../index' {
|
|
|
24
31
|
|
|
25
32
|
namespace getLocation {
|
|
26
33
|
interface Option {
|
|
27
|
-
/** 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度
|
|
28
|
-
|
|
34
|
+
/** 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度
|
|
35
|
+
* @default false
|
|
36
|
+
*/
|
|
37
|
+
altitude?: boolean
|
|
29
38
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
30
39
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
31
40
|
/** 接口调用失败的回调函数 */
|
|
32
41
|
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
33
42
|
/** 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 */
|
|
34
43
|
highAccuracyExpireTime?: number
|
|
35
|
-
/** 开启高精度定位
|
|
44
|
+
/** 开启高精度定位
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
36
47
|
isHighAccuracy?: boolean
|
|
37
48
|
/** 接口调用成功的回调函数 */
|
|
38
49
|
success?: (result: SuccessCallbackResult) => void
|
|
39
|
-
/** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标
|
|
50
|
+
/** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标
|
|
51
|
+
* @default "wgs84"
|
|
52
|
+
*/
|
|
40
53
|
type?: string
|
|
54
|
+
/** 针对 iOS14/Android12 及以上的新特性,其他情况本参数忽略。默认情况宿主是精确定位就返回精确定位信息。
|
|
55
|
+
* 传入 true 会强制使用精确定位信息,iOS14/Android12 及以上如果没有精确定位权限,会弹出精确定位授权弹框
|
|
56
|
+
* @supported swan
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
needFullAccuracy?: boolean
|
|
41
60
|
}
|
|
42
61
|
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
43
62
|
/** 位置的精确度 */
|
|
@@ -54,6 +73,42 @@ declare module '../../index' {
|
|
|
54
73
|
speed: number
|
|
55
74
|
/** 垂直精度,单位 m(Android 无法获取,返回 0) */
|
|
56
75
|
verticalAccuracy: number
|
|
76
|
+
/** 城市名称
|
|
77
|
+
* @supported swan
|
|
78
|
+
*/
|
|
79
|
+
street?: string
|
|
80
|
+
/** 国家代码
|
|
81
|
+
* @supported swan
|
|
82
|
+
*/
|
|
83
|
+
cityCode?: string
|
|
84
|
+
/** 城市名称
|
|
85
|
+
* @supported swan, tt
|
|
86
|
+
*/
|
|
87
|
+
city?: string
|
|
88
|
+
/** 国家
|
|
89
|
+
* @supported swan
|
|
90
|
+
*/
|
|
91
|
+
country?: string
|
|
92
|
+
/** 国家代码
|
|
93
|
+
* @supported swan
|
|
94
|
+
*/
|
|
95
|
+
countryCode?: string
|
|
96
|
+
/** 省份
|
|
97
|
+
* @supported swan
|
|
98
|
+
*/
|
|
99
|
+
province?: string
|
|
100
|
+
/** 街道号码
|
|
101
|
+
* @supported swan
|
|
102
|
+
*/
|
|
103
|
+
streetNumber?: string
|
|
104
|
+
/** 区
|
|
105
|
+
* @supported swan
|
|
106
|
+
*/
|
|
107
|
+
district?: string
|
|
108
|
+
/** 是不是精确定位信息
|
|
109
|
+
* @supported swan
|
|
110
|
+
*/
|
|
111
|
+
isFullAccuracy?: boolean
|
|
57
112
|
/** 调用结果 */
|
|
58
113
|
errMsg: string
|
|
59
114
|
}
|
|
@@ -97,6 +152,12 @@ declare module '../../index' {
|
|
|
97
152
|
* @see https://lbs.qq.com/webApi/component/componentGuide/componentPicker
|
|
98
153
|
*/
|
|
99
154
|
mapOpts?: Record<string, unknown>
|
|
155
|
+
/** 页面显示标题
|
|
156
|
+
* @supported alipay
|
|
157
|
+
* @alipay 安卓默认值为 位置,iOS、IDE 默认值为 你在哪里?
|
|
158
|
+
* @see https://opendocs.alipay.com/mini/api/location?pathHash=951b46a1
|
|
159
|
+
*/
|
|
160
|
+
title?: string
|
|
100
161
|
/** 接口调用成功的回调函数 */
|
|
101
162
|
success?: (result: SuccessCallbackResult) => void
|
|
102
163
|
/** 接口调用失败的回调函数 */
|
|
@@ -114,6 +175,30 @@ declare module '../../index' {
|
|
|
114
175
|
longitude: number
|
|
115
176
|
/** 位置名称 */
|
|
116
177
|
name: string
|
|
178
|
+
/** 区县代码
|
|
179
|
+
* @supported alipay
|
|
180
|
+
*/
|
|
181
|
+
adCode?: number
|
|
182
|
+
/** 区县名称
|
|
183
|
+
* @supported alipay
|
|
184
|
+
*/
|
|
185
|
+
adName?: string
|
|
186
|
+
/** 城市代码
|
|
187
|
+
* @supported alipay
|
|
188
|
+
*/
|
|
189
|
+
cityCode?: string
|
|
190
|
+
/** 城市名称
|
|
191
|
+
* @supported alipay
|
|
192
|
+
*/
|
|
193
|
+
cityName?: string
|
|
194
|
+
/** 省份代码
|
|
195
|
+
* @supported alipay
|
|
196
|
+
*/
|
|
197
|
+
provinceCode?: number
|
|
198
|
+
/** 省份名称
|
|
199
|
+
* @supported alipay
|
|
200
|
+
*/
|
|
201
|
+
provinceName?: string
|
|
117
202
|
/** 调用结果 */
|
|
118
203
|
errMsg: string
|
|
119
204
|
}
|
|
@@ -132,6 +217,10 @@ declare module '../../index' {
|
|
|
132
217
|
|
|
133
218
|
namespace startLocationUpdateBackground {
|
|
134
219
|
interface Option {
|
|
220
|
+
/** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
|
221
|
+
* @default "gcj02"
|
|
222
|
+
*/
|
|
223
|
+
type?: string
|
|
135
224
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
136
225
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
137
226
|
/** 接口调用失败的回调函数 */
|
|
@@ -143,6 +232,16 @@ declare module '../../index' {
|
|
|
143
232
|
|
|
144
233
|
namespace startLocationUpdate {
|
|
145
234
|
interface Option {
|
|
235
|
+
/** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标
|
|
236
|
+
* @default "gcj02"
|
|
237
|
+
*/
|
|
238
|
+
type?: string
|
|
239
|
+
/** 针对 iOS14/Android12 及以上的新特性,其他情况本参数忽略。默认情况宿主是精确定位就返回精确定位信息。
|
|
240
|
+
* 传入 true 会强制使用精确定位信息,iOS14/Android12 及以上如果没有精确定位权限,会弹出精确定位授权弹框
|
|
241
|
+
* @supported swan
|
|
242
|
+
* @default false
|
|
243
|
+
*/
|
|
244
|
+
needFullAccuracy?: boolean
|
|
146
245
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
147
246
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
148
247
|
/** 接口调用失败的回调函数 */
|
|
@@ -161,6 +260,11 @@ declare module '../../index' {
|
|
|
161
260
|
interface CallbackResult {
|
|
162
261
|
/** 错误码 */
|
|
163
262
|
errCode: number
|
|
263
|
+
/** 错误信息
|
|
264
|
+
* @supported tt
|
|
265
|
+
* @tt 最低支持版本 2.48.0
|
|
266
|
+
*/
|
|
267
|
+
errMsg?: string
|
|
164
268
|
}
|
|
165
269
|
}
|
|
166
270
|
|
|
@@ -185,13 +289,50 @@ declare module '../../index' {
|
|
|
185
289
|
speed: number
|
|
186
290
|
/** 垂直精度,单位 m(Android 无法获取,返回 0) */
|
|
187
291
|
verticalAccuracy: number
|
|
292
|
+
/** 街道名称
|
|
293
|
+
* @supported swan
|
|
294
|
+
*/
|
|
295
|
+
street?: string
|
|
296
|
+
/** 城市编码
|
|
297
|
+
* @supported swan
|
|
298
|
+
*/
|
|
299
|
+
cityCode?: string
|
|
300
|
+
/** 城市名称
|
|
301
|
+
* @supported swan, tt
|
|
302
|
+
* @tt iOS 不支持
|
|
303
|
+
*/
|
|
304
|
+
city?: string
|
|
305
|
+
/** 国家
|
|
306
|
+
* @supported swan
|
|
307
|
+
*/
|
|
308
|
+
country?: string
|
|
309
|
+
/** 国家代码
|
|
310
|
+
* @supported swan
|
|
311
|
+
*/
|
|
312
|
+
countryCode?: string
|
|
313
|
+
/** 省份
|
|
314
|
+
* @supported swan
|
|
315
|
+
*/
|
|
316
|
+
province?: string
|
|
317
|
+
/** 街道号码
|
|
318
|
+
* @supported swan
|
|
319
|
+
*/
|
|
320
|
+
streetNumber?: string
|
|
321
|
+
/** 区
|
|
322
|
+
* @supported swan
|
|
323
|
+
*/
|
|
324
|
+
district?: string
|
|
325
|
+
/** 是不是精确定位信息
|
|
326
|
+
* @supported swan
|
|
327
|
+
*/
|
|
328
|
+
isFullAccuracy?: boolean
|
|
188
329
|
}
|
|
189
330
|
}
|
|
190
331
|
|
|
191
332
|
namespace getFuzzyLocation {
|
|
192
333
|
interface Option {
|
|
193
334
|
/** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 */
|
|
194
|
-
type?:
|
|
335
|
+
type?: keyof Type
|
|
195
336
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
196
337
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
197
338
|
/** 接口调用失败的回调函数 */
|
|
@@ -200,6 +341,13 @@ declare module '../../index' {
|
|
|
200
341
|
success?: (result: SuccessCallbackResult) => void
|
|
201
342
|
}
|
|
202
343
|
|
|
344
|
+
interface Type {
|
|
345
|
+
/** 返回 gps 坐标 */
|
|
346
|
+
wgs84
|
|
347
|
+
/** 返回 gcj02 坐标*/
|
|
348
|
+
gcj02
|
|
349
|
+
}
|
|
350
|
+
|
|
203
351
|
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
204
352
|
/** 纬度,范围为 -90~90,负数表示南纬 */
|
|
205
353
|
latitude: number
|
|
@@ -210,7 +358,7 @@ declare module '../../index' {
|
|
|
210
358
|
|
|
211
359
|
interface TaroStatic {
|
|
212
360
|
/** 关闭监听实时位置变化,前后台都停止消息接收
|
|
213
|
-
* @supported weapp,
|
|
361
|
+
* @supported weapp, swan, tt, rn
|
|
214
362
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.stopLocationUpdate.html
|
|
215
363
|
*/
|
|
216
364
|
stopLocationUpdate(option?: stopLocationUpdate.Option): void
|
|
@@ -232,13 +380,13 @@ declare module '../../index' {
|
|
|
232
380
|
*
|
|
233
381
|
* **注意**
|
|
234
382
|
* - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。
|
|
235
|
-
* @supported weapp,
|
|
383
|
+
* @supported weapp, swan, tt, rn
|
|
236
384
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdate.html
|
|
237
385
|
*/
|
|
238
386
|
startLocationUpdate(option?: startLocationUpdate.Option): void
|
|
239
387
|
|
|
240
388
|
/** 使用微信内置地图查看位置
|
|
241
|
-
* @supported weapp,
|
|
389
|
+
* @supported weapp, alipay, swan, jd, tt, h5
|
|
242
390
|
* @example
|
|
243
391
|
* ```tsx
|
|
244
392
|
* Taro.getLocation({
|
|
@@ -268,7 +416,7 @@ declare module '../../index' {
|
|
|
268
416
|
): void
|
|
269
417
|
|
|
270
418
|
/** 监听实时地理位置变化事件,需结合 Taro.startLocationUpdateBackground、Taro.startLocationUpdate 使用。
|
|
271
|
-
* @supported weapp,
|
|
419
|
+
* @supported weapp, swan, tt, rn
|
|
272
420
|
* @example
|
|
273
421
|
* ```tsx
|
|
274
422
|
* const _locationChangeFn = function (res) {
|
|
@@ -290,16 +438,16 @@ declare module '../../index' {
|
|
|
290
438
|
*/
|
|
291
439
|
offLocationChangeError(
|
|
292
440
|
/** 监听持续定位接口返回失败时触发的回调函数 */
|
|
293
|
-
callback
|
|
441
|
+
callback?: onLocationChangeError.Callback,
|
|
294
442
|
): void
|
|
295
443
|
|
|
296
444
|
/** 取消监听实时地理位置变化事件
|
|
297
|
-
* @supported weapp,
|
|
445
|
+
* @supported weapp, swan, tt, rn
|
|
298
446
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.offLocationChange.html
|
|
299
447
|
*/
|
|
300
448
|
offLocationChange(
|
|
301
449
|
/** 实时地理位置变化事件的回调函数 */
|
|
302
|
-
callback
|
|
450
|
+
callback?: onLocationChange.Callback,
|
|
303
451
|
): void
|
|
304
452
|
|
|
305
453
|
/** 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。
|
|
@@ -307,7 +455,7 @@ declare module '../../index' {
|
|
|
307
455
|
* **注意**
|
|
308
456
|
* - 工具中定位模拟使用IP定位,可能会有一定误差。且工具目前仅支持 gcj02 坐标。
|
|
309
457
|
* - 使用第三方服务进行逆地址解析时,请确认第三方服务默认的坐标系,正确进行坐标转换。
|
|
310
|
-
* @supported weapp,
|
|
458
|
+
* @supported weapp, swan, jd, qq, tt, rn
|
|
311
459
|
* @example
|
|
312
460
|
* ```tsx
|
|
313
461
|
* Taro.getLocation({
|
|
@@ -333,7 +481,7 @@ declare module '../../index' {
|
|
|
333
481
|
/** 打开地图选择位置。
|
|
334
482
|
*
|
|
335
483
|
* `chooseLocation` api功能是依赖于腾讯位置服务,所以需要使用 api 密钥。如果您没有,可以前往腾讯位置服务[开发者控制台](https://lbs.qq.com/console/mykey.html?console=mykey)进行申请。
|
|
336
|
-
* @supported weapp,
|
|
484
|
+
* @supported weapp, alipay, swan, jd, tt, h5
|
|
337
485
|
* @example
|
|
338
486
|
* ```tsx
|
|
339
487
|
* // config/index.js
|
|
@@ -90,15 +90,15 @@ declare module '../../index' {
|
|
|
90
90
|
* @supported alipay
|
|
91
91
|
*/
|
|
92
92
|
height: string
|
|
93
|
-
|
|
93
|
+
/** 视频文件的宽度。
|
|
94
94
|
* @supported alipay
|
|
95
95
|
*/
|
|
96
96
|
width: string
|
|
97
|
-
|
|
97
|
+
/** 视频文件的尺寸。
|
|
98
98
|
* @supported alipay
|
|
99
99
|
*/
|
|
100
100
|
size: string
|
|
101
|
-
|
|
101
|
+
/** 录制的持续时间。
|
|
102
102
|
* @supported alipay
|
|
103
103
|
*/
|
|
104
104
|
duration: string
|
|
@@ -152,6 +152,8 @@ declare module '../../index' {
|
|
|
152
152
|
normal
|
|
153
153
|
/** 低质量 */
|
|
154
154
|
low
|
|
155
|
+
/** 原图 */
|
|
156
|
+
original
|
|
155
157
|
}
|
|
156
158
|
}
|
|
157
159
|
|
|
@@ -192,6 +194,7 @@ declare module '../../index' {
|
|
|
192
194
|
|
|
193
195
|
interface TaroStatic {
|
|
194
196
|
/** 创建 camera 上下文 CameraContext 对象。
|
|
197
|
+
* @alipay 支付宝小程序需指定 camera 组件中的 id 属性
|
|
195
198
|
* @supported weapp, rn, tt, alipay
|
|
196
199
|
* @example
|
|
197
200
|
* ```tsx
|
|
@@ -81,7 +81,7 @@ declare module '../../index' {
|
|
|
81
81
|
*
|
|
82
82
|
* 通过 Taro.login 接口获得的用户登录态拥有一定的时效性。用户越久未使用小程序,用户登录态越有可能失效。反之如果用户一直在使用小程序,则用户登录态一直保持有效。具体时效逻辑由微信维护,对开发者透明。开发者只需要调用 Taro.checkSession 接口检测当前用户登录态是否有效。
|
|
83
83
|
*
|
|
84
|
-
* 登录态过期后开发者可以再调用 Taro.login
|
|
84
|
+
* 登录态过期后开发者可以再调用 Taro.login 获取新的用户登录态。调用 Taro.checkSession 成功说明当前 session_key 未过期,调用失败说明 session_key 已过期。更多使用方法详见 [小程序登录](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html)。
|
|
85
85
|
* @supported weapp
|
|
86
86
|
* @example
|
|
87
87
|
* ```tsx
|
|
@@ -25,6 +25,25 @@ declare module '../../index' {
|
|
|
25
25
|
/** 接口调用成功的回调函数 */
|
|
26
26
|
success?: (res: TaroGeneral.CallbackResult) => void
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
type Callback = (
|
|
30
|
+
result: CallbackResult,
|
|
31
|
+
) => void
|
|
32
|
+
|
|
33
|
+
interface CallbackResult {
|
|
34
|
+
/** 缓存数据类别,取值为 periodic 或 pre */
|
|
35
|
+
fetchType: string
|
|
36
|
+
/** 缓存数据 */
|
|
37
|
+
fetchedData: string
|
|
38
|
+
/** 客户端拿到缓存数据的时间戳 */
|
|
39
|
+
timeStamp: number
|
|
40
|
+
/** 小程序页面路径 */
|
|
41
|
+
path: string
|
|
42
|
+
/** 传给页面的 query 参数 */
|
|
43
|
+
query: string
|
|
44
|
+
/** 进入小程序的场景值 */
|
|
45
|
+
scene: number
|
|
46
|
+
}
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
namespace getBackgroundFetchToken {
|
|
@@ -34,46 +53,79 @@ declare module '../../index' {
|
|
|
34
53
|
/** 接口调用失败的回调函数 */
|
|
35
54
|
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
36
55
|
/** 接口调用成功的回调函数 */
|
|
37
|
-
success?: (res:
|
|
56
|
+
success?: (res: SuccessCallbackResult) => void
|
|
57
|
+
}
|
|
58
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
59
|
+
/** 自定义的登录态 */
|
|
60
|
+
token: string
|
|
61
|
+
/** 接口调用结果 */
|
|
62
|
+
errMsg: string
|
|
38
63
|
}
|
|
39
64
|
}
|
|
40
65
|
|
|
41
66
|
namespace getBackgroundFetchData {
|
|
42
67
|
interface Option {
|
|
43
|
-
/**
|
|
68
|
+
/** 缓存数据类别
|
|
69
|
+
* @weapp 取值为 periodic
|
|
70
|
+
* @qq 取值为 periodic
|
|
71
|
+
* @alipay 取值为 pre: 数据预拉取; jsapiPre: API 预调用(目前仅支持地理位置预拉取)
|
|
72
|
+
*/
|
|
44
73
|
fetchType: string
|
|
45
74
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
46
75
|
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
47
76
|
/** 接口调用失败的回调函数 */
|
|
48
77
|
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
49
78
|
/** 接口调用成功的回调函数 */
|
|
50
|
-
success?: (res:
|
|
79
|
+
success?: (res: SuccessCallbackResult) => void
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
83
|
+
/** 缓存数据
|
|
84
|
+
* @alipay Object
|
|
85
|
+
*/
|
|
86
|
+
fetchedData: string | Object
|
|
87
|
+
/** 客户端拿到缓存数据的时间戳 ms。(iOS 时间戳存在异常,8.0.27 修复) */
|
|
88
|
+
timeStamp: number
|
|
89
|
+
/** 小程序页面路径 */
|
|
90
|
+
path: string
|
|
91
|
+
/** 传给页面的 query 参数 */
|
|
92
|
+
query: string
|
|
93
|
+
/** 进入小程序的场景值 */
|
|
94
|
+
scene: number
|
|
95
|
+
/** 缓存数据类型,与入参 fetchType 一致
|
|
96
|
+
* @supported alipay
|
|
97
|
+
*/
|
|
98
|
+
fetchType?: string
|
|
99
|
+
/** 缓存数据的时间戳。单位:ms。
|
|
100
|
+
* @supported alipay
|
|
101
|
+
*/
|
|
102
|
+
timestamp?: number
|
|
51
103
|
}
|
|
52
104
|
}
|
|
53
105
|
|
|
54
106
|
interface TaroStatic {
|
|
55
107
|
/** 设置自定义登录态,在周期性拉取数据时带上,便于第三方服务器验证请求合法性
|
|
56
|
-
* @supported weapp
|
|
108
|
+
* @supported weapp, qq
|
|
57
109
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.setBackgroundFetchToken.html
|
|
58
110
|
*/
|
|
59
|
-
setBackgroundFetchToken(option: setBackgroundFetchToken.Option):
|
|
111
|
+
setBackgroundFetchToken(option: setBackgroundFetchToken.Option): Promise<TaroGeneral.CallbackResult>
|
|
60
112
|
|
|
61
113
|
/** 收到 backgroundFetch 数据时的回调
|
|
62
|
-
* @supported weapp
|
|
114
|
+
* @supported weapp, qq
|
|
63
115
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.onBackgroundFetchData.html
|
|
64
116
|
*/
|
|
65
|
-
onBackgroundFetchData(option?: onBackgroundFetchData.Option): void
|
|
117
|
+
onBackgroundFetchData(option?: onBackgroundFetchData.Option | onBackgroundFetchData.Callback): void
|
|
66
118
|
|
|
67
119
|
/** 获取设置过的自定义登录态。若无,则返回 fail。
|
|
68
|
-
* @supported weapp
|
|
120
|
+
* @supported weapp, qq
|
|
69
121
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchToken.html
|
|
70
122
|
*/
|
|
71
|
-
getBackgroundFetchToken(option?: getBackgroundFetchToken.Option):
|
|
123
|
+
getBackgroundFetchToken(option?: getBackgroundFetchToken.Option): Promise<TaroGeneral.CallbackResult>
|
|
72
124
|
|
|
73
125
|
/** 拉取 backgroundFetch 客户端缓存数据
|
|
74
|
-
* @supported weapp
|
|
126
|
+
* @supported weapp, alipay, qq
|
|
75
127
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchData.html
|
|
76
128
|
*/
|
|
77
|
-
getBackgroundFetchData(option: getBackgroundFetchData.Option):
|
|
129
|
+
getBackgroundFetchData(option: getBackgroundFetchData.Option): Promise<getBackgroundFetchData.SuccessCallbackResult>
|
|
78
130
|
}
|
|
79
131
|
}
|
|
@@ -2,8 +2,42 @@ import Taro from '../../index'
|
|
|
2
2
|
|
|
3
3
|
declare module '../../index' {
|
|
4
4
|
interface CacheManager {
|
|
5
|
+
/** 当前缓存模式 */
|
|
6
|
+
mode: keyof CacheManager.Mode
|
|
7
|
+
/** 全局 origin */
|
|
8
|
+
origin: string
|
|
9
|
+
/** 全局缓存有效时间 */
|
|
10
|
+
maxAge: number
|
|
11
|
+
/** 当前缓存管理器状态 */
|
|
12
|
+
state: keyof CacheManager.State
|
|
5
13
|
/** 添加规则
|
|
6
14
|
* @supported weapp
|
|
15
|
+
* @example
|
|
16
|
+
* ```tsx
|
|
17
|
+
* const ruleId = cacheManager.addRule({
|
|
18
|
+
* id: 'haha-rule',
|
|
19
|
+
* method: 'GET',
|
|
20
|
+
* url: '/haha',
|
|
21
|
+
* maxAge: 123455,
|
|
22
|
+
* dataSchema: [
|
|
23
|
+
* // data 字段的匹配,默认为空,表示不匹配
|
|
24
|
+
* // 类型可以是:string、number、boolean、null、object、any(表示任意类型均可),以及这些类型的数组表示方式
|
|
25
|
+
* {name: 'aaa', schema: {type: 'string'}}, // 类型为 string
|
|
26
|
+
* {name: 'bbb', schema: [{type: 'number'}, {type: 'string'}]}, // 类型为 number, string
|
|
27
|
+
* {name: 'ccc', schema: {type: 'string', value: 'abc'}}, // 值为 abc
|
|
28
|
+
* {name: 'ddd', schema: {type: 'string', value: /(abc|cba)/ig}}, // 值符合该正则匹配,如果该值不是字符串类型,则会被尝试转成字符串后再进行比较
|
|
29
|
+
* {name: 'ddd', schema: {type: 'string', value: val => val === '123'}}, // 传入函数来校验值
|
|
30
|
+
* {name: 'eee', schema: {type: 'object', value: [{ // 类型为对象,则通过嵌套的方式来逐层校验
|
|
31
|
+
* name: 'aaa', schema: {type: 'string'},
|
|
32
|
+
* // ...
|
|
33
|
+
* // 嵌套 dataSchema,同上面的方式一样来匹配嵌套的对象
|
|
34
|
+
* }]}},
|
|
35
|
+
* {name: 'fff', schema: {type: 'string[]'}}, // 类型为 string 数组
|
|
36
|
+
* {name: 'ggg', schema: {type: 'any'}}, // 类型为任意类型
|
|
37
|
+
* {name: 'hhh', schema: {type: 'any[]'}}, // 类型为任意类型的数组
|
|
38
|
+
* ]
|
|
39
|
+
* })
|
|
40
|
+
* ```
|
|
7
41
|
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRule.html
|
|
8
42
|
*/
|
|
9
43
|
addRule(option: CacheManager.AddRuleOption): string
|
|
@@ -92,6 +126,22 @@ declare module '../../index' {
|
|
|
92
126
|
}
|
|
93
127
|
|
|
94
128
|
namespace CacheManager {
|
|
129
|
+
interface Mode {
|
|
130
|
+
/** 默认值,弱网/离线使用缓存返回 */
|
|
131
|
+
weakNetwork
|
|
132
|
+
/** 总是使用缓存返回 */
|
|
133
|
+
always
|
|
134
|
+
/** 不开启,后续可手动开启/停止使用缓存返回 */
|
|
135
|
+
none
|
|
136
|
+
}
|
|
137
|
+
interface State {
|
|
138
|
+
/** 不使用缓存返回 */
|
|
139
|
+
0
|
|
140
|
+
/** 使用缓存返回 */
|
|
141
|
+
1
|
|
142
|
+
/** 未知 */
|
|
143
|
+
2
|
|
144
|
+
}
|
|
95
145
|
interface DataSchema {
|
|
96
146
|
/** 需要匹配的 data 对象的参数类型
|
|
97
147
|
* string、number、boolean、null、object、any(表示任意类型),
|
|
@@ -135,6 +185,7 @@ declare module '../../index' {
|
|
|
135
185
|
rule: Rule
|
|
136
186
|
}
|
|
137
187
|
interface AddRulesOption {
|
|
188
|
+
/** 规则列表 */
|
|
138
189
|
rules: Rule[]
|
|
139
190
|
}
|
|
140
191
|
interface MatchOption {
|
|
@@ -191,7 +242,7 @@ declare module '../../index' {
|
|
|
191
242
|
interface TaroStatic {
|
|
192
243
|
/** 创建缓存管理器
|
|
193
244
|
* @supported weapp
|
|
194
|
-
* @see
|
|
245
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/wx.createCacheManager.html
|
|
195
246
|
*/
|
|
196
247
|
createCacheManager(option: createCacheManager.Option): CacheManager
|
|
197
248
|
}
|