@tarojs/taro 3.3.12 → 3.3.16
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 +5 -5
- package/types/api/ad/index.d.ts +34 -28
- package/types/api/alipay/index.d.ts +11 -7
- package/types/api/base/debug.d.ts +60 -54
- package/types/api/base/env.d.ts +12 -8
- package/types/api/base/index.d.ts +87 -83
- package/types/api/base/system.d.ts +59 -54
- package/types/api/base/update.d.ts +37 -33
- package/types/api/base/weapp/app-event.d.ts +147 -131
- package/types/api/base/weapp/life-cycle.d.ts +14 -10
- package/types/api/canvas/index.d.ts +115 -110
- package/types/api/cloud/index.d.ts +99 -94
- package/types/api/data-analysis/index.d.ts +68 -64
- package/types/api/device/accelerometer.d.ts +57 -50
- package/types/api/device/battery.d.ts +19 -15
- package/types/api/device/ble.d.ts +241 -228
- package/types/api/device/bluetooth.d.ts +207 -194
- package/types/api/device/clipboard.d.ts +48 -43
- package/types/api/device/compass.d.ts +55 -48
- package/types/api/device/contact.d.ts +13 -9
- package/types/api/device/gyroscope.d.ts +41 -35
- package/types/api/device/iBeacon.d.ts +79 -73
- package/types/api/device/motion.d.ts +42 -37
- package/types/api/device/network.d.ts +80 -42
- package/types/api/device/nfc.d.ts +105 -96
- package/types/api/device/performance.d.ts +32 -18
- package/types/api/device/phone.d.ts +20 -15
- package/types/api/device/scan.d.ts +31 -26
- package/types/api/device/screen.d.ts +74 -67
- package/types/api/device/vibrate.d.ts +31 -25
- package/types/api/device/wifi.d.ts +151 -140
- package/types/api/ext/index.d.ts +44 -39
- package/types/api/files/index.d.ts +219 -209
- package/types/api/framework/index.d.ts +25 -20
- package/types/api/location/index.d.ts +140 -136
- package/types/api/media/audio.d.ts +135 -127
- package/types/api/media/background-audio.d.ts +135 -126
- package/types/api/media/camera.d.ts +30 -26
- package/types/api/media/editor.d.ts +35 -33
- package/types/api/media/image.d.ts +161 -150
- package/types/api/media/live.d.ts +88 -82
- package/types/api/media/map.d.ts +47 -43
- package/types/api/media/recorder.d.ts +90 -84
- package/types/api/media/video-processing.d.ts +10 -6
- package/types/api/media/video.d.ts +63 -58
- package/types/api/network/download.d.ts +34 -30
- package/types/api/network/mdns.d.ts +104 -91
- package/types/api/network/request.d.ts +83 -79
- package/types/api/network/udp.d.ts +20 -16
- package/types/api/network/upload.d.ts +60 -56
- package/types/api/network/websocket.d.ts +201 -194
- package/types/api/open-api/account.d.ts +18 -14
- package/types/api/open-api/address.d.ts +27 -23
- package/types/api/open-api/authorize.d.ts +30 -26
- package/types/api/open-api/card.d.ts +55 -51
- package/types/api/open-api/customer-service.d.ts +21 -17
- package/types/api/open-api/facial.d.ts +28 -24
- package/types/api/open-api/invoice.d.ts +38 -34
- package/types/api/open-api/login.d.ts +56 -52
- package/types/api/open-api/navigate.d.ts +79 -75
- package/types/api/open-api/payment.d.ts +34 -30
- package/types/api/open-api/settings.d.ts +49 -45
- package/types/api/open-api/soter.d.ts +92 -86
- package/types/api/open-api/subscribe-message.d.ts +24 -20
- package/types/api/open-api/user-info.d.ts +60 -57
- package/types/api/open-api/werun.d.ts +50 -46
- package/types/api/route/index.d.ts +122 -118
- package/types/api/share/index.d.ts +68 -64
- package/types/api/storage/background-fetch.d.ts +40 -35
- package/types/api/storage/index.d.ts +267 -262
- package/types/api/swan/index.d.ts +47 -42
- package/types/api/ui/animation.d.ts +21 -17
- package/types/api/ui/background.d.ts +38 -34
- package/types/api/ui/custom-component.d.ts +22 -18
- package/types/api/ui/fonts.d.ts +26 -21
- package/types/api/ui/interaction.d.ts +171 -122
- package/types/api/ui/keyboard.d.ts +59 -55
- package/types/api/ui/menu.d.ts +10 -6
- package/types/api/ui/navigation-bar.d.ts +67 -63
- package/types/api/ui/pull-down-refresh.d.ts +33 -29
- package/types/api/ui/scroll.d.ts +30 -26
- package/types/api/ui/sticky.d.ts +22 -19
- package/types/api/ui/tab-bar.d.ts +101 -97
- package/types/api/ui/window.d.ts +24 -18
- package/types/api/worker/index.d.ts +28 -24
- package/types/api/wxml/index.d.ts +42 -38
- package/types/compile.d.ts +1 -5
- package/types/global.d.ts +392 -0
- package/types/index.d.ts +12 -98
- package/types/taro.api.d.ts +94 -0
- package/types/taro.component.d.ts +10 -57
- package/types/taro.config.d.ts +24 -6
- package/types/taro.extend.d.ts +46 -75
- package/types/taro.hooks.d.ts +68 -67
- package/types/taro.lifecycle.d.ts +47 -28
- package/types/api/ad/index.ts +0 -6
- package/types/api/alipay/index.ts +0 -7
- package/types/api/index.d.ts +0 -352
|
@@ -1,28 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace setScreenBrightness {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 屏幕亮度值,范围 0 ~ 1。0 最暗,1 最亮 */
|
|
5
7
|
value: number
|
|
6
8
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
7
|
-
complete?: (res:
|
|
9
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
8
10
|
/** 接口调用失败的回调函数 */
|
|
9
|
-
fail?: (res:
|
|
11
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
10
12
|
/** 接口调用成功的回调函数 */
|
|
11
|
-
success?: (res:
|
|
13
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
|
-
/** 设置屏幕亮度。
|
|
15
|
-
* @supported weapp, rn
|
|
16
|
-
* @example
|
|
17
|
-
* ```tsx
|
|
18
|
-
* Taro.setScreenBrightness(params).then(...)
|
|
19
|
-
* ```
|
|
20
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.setScreenBrightness.html
|
|
21
|
-
*/
|
|
22
|
-
function setScreenBrightness(option: setScreenBrightness.Option): Promise<General.CallbackResult>
|
|
23
16
|
|
|
24
17
|
namespace setKeepScreenOn {
|
|
25
|
-
interface Promised extends
|
|
18
|
+
interface Promised extends TaroGeneral.CallbackResult {
|
|
26
19
|
/** 调用结果 */
|
|
27
20
|
errMsg: string
|
|
28
21
|
}
|
|
@@ -30,49 +23,20 @@ declare namespace Taro {
|
|
|
30
23
|
/** 是否保持屏幕常亮 */
|
|
31
24
|
keepScreenOn: boolean
|
|
32
25
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
33
|
-
complete?: (res:
|
|
26
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
34
27
|
/** 接口调用失败的回调函数 */
|
|
35
|
-
fail?: (res:
|
|
28
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
36
29
|
/** 接口调用成功的回调函数 */
|
|
37
|
-
success?: (res:
|
|
30
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
38
31
|
}
|
|
39
32
|
}
|
|
40
|
-
/**
|
|
41
|
-
* 设置是否保持常亮状态。仅在当前小程序生效,离开小程序后设置失效。
|
|
42
|
-
* @supported weapp
|
|
43
|
-
* @example
|
|
44
|
-
* ```tsx
|
|
45
|
-
* // 保持屏幕常亮
|
|
46
|
-
* Taro.setKeepScreenOn({
|
|
47
|
-
* keepScreenOn: true
|
|
48
|
-
* })
|
|
49
|
-
* ```
|
|
50
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.setKeepScreenOn.html
|
|
51
|
-
*/
|
|
52
|
-
function setKeepScreenOn(option: setKeepScreenOn.Option): Promise<setKeepScreenOn.Promised>
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* 监听用户主动截屏事件,用户使用系统截屏按键截屏时触发此事件
|
|
56
|
-
* @supported weapp
|
|
57
|
-
* @example
|
|
58
|
-
* ```tsx
|
|
59
|
-
* Taro.onUserCaptureScreen(function (res) {
|
|
60
|
-
* console.log('用户截屏了')
|
|
61
|
-
* })
|
|
62
|
-
* ```
|
|
63
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.onUserCaptureScreen.html
|
|
64
|
-
*/
|
|
65
|
-
function onUserCaptureScreen(
|
|
66
|
-
/** 用户主动截屏事件的回调函数 */
|
|
67
|
-
callback: (res: General.CallbackResult) => void,
|
|
68
|
-
): void
|
|
69
33
|
|
|
70
34
|
namespace getScreenBrightness {
|
|
71
35
|
interface Option {
|
|
72
36
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
73
|
-
complete?: (res:
|
|
37
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
74
38
|
/** 接口调用失败的回调函数 */
|
|
75
|
-
fail?: (res:
|
|
39
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
76
40
|
/** 接口调用成功的回调函数 */
|
|
77
41
|
success?: (option: SuccessCallbackOption) => void
|
|
78
42
|
}
|
|
@@ -82,24 +46,67 @@ declare namespace Taro {
|
|
|
82
46
|
value: number
|
|
83
47
|
}
|
|
84
48
|
}
|
|
85
|
-
/**
|
|
86
|
-
* 获取屏幕亮度。
|
|
87
|
-
*
|
|
88
|
-
* **说明**
|
|
89
|
-
* - 若安卓系统设置中开启了自动调节亮度功能,则屏幕亮度会根据光线自动调整,该接口仅能获取自动调节亮度之前的值,而非实时的亮度值。
|
|
90
|
-
* @supported weapp
|
|
91
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.getScreenBrightness.html
|
|
92
|
-
*/
|
|
93
|
-
function getScreenBrightness(
|
|
94
|
-
option?: getScreenBrightness.Option
|
|
95
|
-
): Promise<getScreenBrightness.SuccessCallbackOption>
|
|
96
49
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
50
|
+
interface TaroStatic {
|
|
51
|
+
/** 设置屏幕亮度。
|
|
52
|
+
* @supported weapp, rn
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* Taro.setScreenBrightness(params).then(...)
|
|
56
|
+
* ```
|
|
57
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.setScreenBrightness.html
|
|
58
|
+
*/
|
|
59
|
+
setScreenBrightness(option: setScreenBrightness.Option): Promise<TaroGeneral.CallbackResult>
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 设置是否保持常亮状态。仅在当前小程序生效,离开小程序后设置失效。
|
|
63
|
+
* @supported weapp
|
|
64
|
+
* @example
|
|
65
|
+
* ```tsx
|
|
66
|
+
* // 保持屏幕常亮
|
|
67
|
+
* Taro.setKeepScreenOn({
|
|
68
|
+
* keepScreenOn: true
|
|
69
|
+
* })
|
|
70
|
+
* ```
|
|
71
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.setKeepScreenOn.html
|
|
72
|
+
*/
|
|
73
|
+
setKeepScreenOn(option: setKeepScreenOn.Option): Promise<setKeepScreenOn.Promised>
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* 监听用户主动截屏事件,用户使用系统截屏按键截屏时触发此事件
|
|
77
|
+
* @supported weapp
|
|
78
|
+
* @example
|
|
79
|
+
* ```tsx
|
|
80
|
+
* Taro.onUserCaptureScreen(function (res) {
|
|
81
|
+
* console.log('用户截屏了')
|
|
82
|
+
* })
|
|
83
|
+
* ```
|
|
84
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.onUserCaptureScreen.html
|
|
85
|
+
*/
|
|
86
|
+
onUserCaptureScreen(
|
|
87
|
+
/** 用户主动截屏事件的回调函数 */
|
|
88
|
+
callback: (res: TaroGeneral.CallbackResult) => void,
|
|
89
|
+
): void
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* 获取屏幕亮度。
|
|
93
|
+
*
|
|
94
|
+
* **说明**
|
|
95
|
+
* - 若安卓系统设置中开启了自动调节亮度功能,则屏幕亮度会根据光线自动调整,该接口仅能获取自动调节亮度之前的值,而非实时的亮度值。
|
|
96
|
+
* @supported weapp
|
|
97
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.getScreenBrightness.html
|
|
98
|
+
*/
|
|
99
|
+
getScreenBrightness(
|
|
100
|
+
option?: getScreenBrightness.Option
|
|
101
|
+
): Promise<getScreenBrightness.SuccessCallbackOption>
|
|
102
|
+
|
|
103
|
+
/** 用户主动截屏事件。取消事件监听。
|
|
104
|
+
* @supported weapp
|
|
105
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.offUserCaptureScreen.html
|
|
106
|
+
*/
|
|
107
|
+
offUserCaptureScreen(
|
|
108
|
+
/** 用户主动截屏事件的回调函数 */
|
|
109
|
+
callback: (...args: any[]) => any,
|
|
110
|
+
): void
|
|
111
|
+
}
|
|
105
112
|
}
|
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace vibrateShort {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
5
|
-
complete?: (res:
|
|
7
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
6
8
|
/** 接口调用失败的回调函数 */
|
|
7
|
-
fail?: (res:
|
|
9
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
8
10
|
/** 接口调用成功的回调函数 */
|
|
9
|
-
success?: (res:
|
|
11
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
|
-
/** 使手机发生较短时间的振动(15 ms)。仅在 iPhone `7 / 7 Plus` 以上及 Android 机型生效
|
|
13
|
-
* @supported weapp, h5, rn
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* Taro.vibrateShort(params).then(...)
|
|
17
|
-
* ```
|
|
18
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/vibrate/wx.vibrateShort.html
|
|
19
|
-
*/
|
|
20
|
-
function vibrateShort(option?: vibrateShort.Option): Promise<General.CallbackResult>
|
|
21
14
|
|
|
22
15
|
namespace vibrateLong {
|
|
23
16
|
interface Option {
|
|
24
17
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
25
|
-
complete?: (res:
|
|
18
|
+
complete?: (res: TaroGeneral.CallbackResult) => void
|
|
26
19
|
/** 接口调用失败的回调函数 */
|
|
27
|
-
fail?: (res:
|
|
20
|
+
fail?: (res: TaroGeneral.CallbackResult) => void
|
|
28
21
|
/** 接口调用成功的回调函数 */
|
|
29
|
-
success?: (res:
|
|
22
|
+
success?: (res: TaroGeneral.CallbackResult) => void
|
|
30
23
|
}
|
|
31
24
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
25
|
+
|
|
26
|
+
interface TaroStatic {
|
|
27
|
+
/** 使手机发生较短时间的振动(15 ms)。仅在 iPhone `7 / 7 Plus` 以上及 Android 机型生效
|
|
28
|
+
* @supported weapp, h5, rn
|
|
29
|
+
* @example
|
|
30
|
+
* ```tsx
|
|
31
|
+
* Taro.vibrateShort(params).then(...)
|
|
32
|
+
* ```
|
|
33
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/vibrate/wx.vibrateShort.html
|
|
34
|
+
*/
|
|
35
|
+
vibrateShort(option?: vibrateShort.Option): Promise<TaroGeneral.CallbackResult>
|
|
36
|
+
|
|
37
|
+
/** 使手机发生较长时间的振动(400ms)
|
|
38
|
+
* @supported weapp, h5, rn
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* Taro.vibrateLong(params).then(...)
|
|
42
|
+
* ```
|
|
43
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/vibrate/wx.vibrateLong.html
|
|
44
|
+
*/
|
|
45
|
+
vibrateLong(option?: vibrateLong.Option): Promise<TaroGeneral.CallbackResult>
|
|
46
|
+
}
|
|
41
47
|
}
|
|
@@ -1,62 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
import Taro from '../../index'
|
|
2
|
+
|
|
3
|
+
declare module '../../index' {
|
|
2
4
|
namespace stopWifi {
|
|
3
5
|
interface Option {
|
|
4
6
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
5
|
-
complete?: (res:
|
|
7
|
+
complete?: (res: TaroGeneral.WifiError) => void
|
|
6
8
|
/** 接口调用失败的回调函数 */
|
|
7
|
-
fail?: (res:
|
|
9
|
+
fail?: (res: TaroGeneral.WifiError) => void
|
|
8
10
|
/** 接口调用成功的回调函数 */
|
|
9
|
-
success?: (res:
|
|
11
|
+
success?: (res: TaroGeneral.WifiError) => void
|
|
10
12
|
}
|
|
11
13
|
}
|
|
12
|
-
/** 关闭 Wi-Fi 模块。
|
|
13
|
-
* @supported weapp
|
|
14
|
-
* @example
|
|
15
|
-
* ```tsx
|
|
16
|
-
* Taro.stopWifi({
|
|
17
|
-
* success: function (res) {
|
|
18
|
-
* console.log(res.errMsg)
|
|
19
|
-
* }
|
|
20
|
-
* })
|
|
21
|
-
* ```
|
|
22
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.stopWifi.html
|
|
23
|
-
*/
|
|
24
|
-
function stopWifi(option?: stopWifi.Option): Promise<General.WifiError>
|
|
25
14
|
|
|
26
15
|
namespace startWifi {
|
|
27
16
|
interface Option {
|
|
28
17
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
29
|
-
complete?: (res:
|
|
18
|
+
complete?: (res: TaroGeneral.WifiError) => void
|
|
30
19
|
/** 接口调用失败的回调函数 */
|
|
31
|
-
fail?: (res:
|
|
20
|
+
fail?: (res: TaroGeneral.WifiError) => void
|
|
32
21
|
/** 接口调用成功的回调函数 */
|
|
33
|
-
success?: (res:
|
|
22
|
+
success?: (res: TaroGeneral.WifiError) => void
|
|
34
23
|
}
|
|
35
24
|
}
|
|
36
|
-
/** 初始化 Wi-Fi 模块。
|
|
37
|
-
* @supported weapp
|
|
38
|
-
* @example
|
|
39
|
-
* ```tsx
|
|
40
|
-
* Taro.startWifi({
|
|
41
|
-
* success: function (res) {
|
|
42
|
-
* console.log(res.errMsg)
|
|
43
|
-
* }
|
|
44
|
-
* })
|
|
45
|
-
* ```
|
|
46
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.startWifi.html
|
|
47
|
-
*/
|
|
48
|
-
function startWifi(option?: startWifi.Option): Promise<General.WifiError>
|
|
49
25
|
|
|
50
26
|
namespace setWifiList {
|
|
51
27
|
interface Option {
|
|
52
28
|
/** 提供预设的 Wi-Fi 信息列表 */
|
|
53
29
|
wifiList: WifiData[]
|
|
54
30
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
55
|
-
complete?: (res:
|
|
31
|
+
complete?: (res: TaroGeneral.WifiError) => void
|
|
56
32
|
/** 接口调用失败的回调函数 */
|
|
57
|
-
fail?: (res:
|
|
33
|
+
fail?: (res: TaroGeneral.WifiError) => void
|
|
58
34
|
/** 接口调用成功的回调函数 */
|
|
59
|
-
success?: (res:
|
|
35
|
+
success?: (res: TaroGeneral.WifiError) => void
|
|
60
36
|
}
|
|
61
37
|
|
|
62
38
|
/** 提供预设的 Wi-Fi 信息列表 */
|
|
@@ -69,35 +45,6 @@ declare namespace Taro {
|
|
|
69
45
|
password?: string
|
|
70
46
|
}
|
|
71
47
|
}
|
|
72
|
-
/** 设置 `wifiList` 中 AP 的相关信息。在 `onGetWifiList` 回调后调用,**iOS特有接口**。
|
|
73
|
-
*
|
|
74
|
-
* **注意**
|
|
75
|
-
* - 该接口只能在 `onGetWifiList` 回调之后才能调用。
|
|
76
|
-
* - 此时客户端会挂起,等待小程序设置 Wi-Fi 信息,请务必尽快调用该接口,若无数据请传入一个空数组。
|
|
77
|
-
* - 有可能随着周边 Wi-Fi 列表的刷新,单个流程内收到多次带有存在重复的 Wi-Fi 列表的回调。
|
|
78
|
-
* @supported weapp
|
|
79
|
-
* @example
|
|
80
|
-
* ```tsx
|
|
81
|
-
* Taro.onGetWifiList(function (res) {
|
|
82
|
-
* if (res.wifiList.length) {
|
|
83
|
-
* Taro.setWifiList({
|
|
84
|
-
* wifiList: [{
|
|
85
|
-
* SSID: res.wifiList[0].SSID,
|
|
86
|
-
* BSSID: res.wifiList[0].BSSID,
|
|
87
|
-
* password: '123456'
|
|
88
|
-
* }]
|
|
89
|
-
* })
|
|
90
|
-
* } else {
|
|
91
|
-
* Taro.setWifiList({
|
|
92
|
-
* wifiList: []
|
|
93
|
-
* })
|
|
94
|
-
* }
|
|
95
|
-
* })
|
|
96
|
-
* Taro.getWifiList()
|
|
97
|
-
* ```
|
|
98
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.setWifiList.html
|
|
99
|
-
*/
|
|
100
|
-
function setWifiList(option: setWifiList.Option): Promise<General.WifiError>
|
|
101
48
|
|
|
102
49
|
namespace onWifiConnected {
|
|
103
50
|
/** 连接上 Wi-Fi 的事件的回调函数 */
|
|
@@ -109,14 +56,6 @@ declare namespace Taro {
|
|
|
109
56
|
wifi: WifiInfo
|
|
110
57
|
}
|
|
111
58
|
}
|
|
112
|
-
/** 监听连接上 Wi-Fi 的事件。
|
|
113
|
-
* @supported weapp
|
|
114
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.onWifiConnected.html
|
|
115
|
-
*/
|
|
116
|
-
function onWifiConnected(
|
|
117
|
-
/** 连接上 Wi-Fi 的事件的回调函数 */
|
|
118
|
-
callback: onWifiConnected.Callback,
|
|
119
|
-
): void
|
|
120
59
|
|
|
121
60
|
namespace onGetWifiList {
|
|
122
61
|
/** 获取到 Wi-Fi 列表数据事件的回调函数 */
|
|
@@ -126,74 +65,34 @@ declare namespace Taro {
|
|
|
126
65
|
wifiList: WifiInfo[]
|
|
127
66
|
}
|
|
128
67
|
}
|
|
129
|
-
/** 监听获取到 Wi-Fi 列表数据事件
|
|
130
|
-
* @supported weapp
|
|
131
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.onGetWifiList.html
|
|
132
|
-
*/
|
|
133
|
-
function onGetWifiList(
|
|
134
|
-
/** 获取到 Wi-Fi 列表数据事件的回调函数 */
|
|
135
|
-
callback: onGetWifiList.Callback,
|
|
136
|
-
): void
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* 取消监听连接上 Wi-Fi 的事件。
|
|
140
|
-
* @supported weapp
|
|
141
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offWifiConnected.html
|
|
142
|
-
*/
|
|
143
|
-
function offWifiConnected(
|
|
144
|
-
/** 连接上 Wi-Fi 的事件的回调函数 */
|
|
145
|
-
callback: (...args: any[]) => any,
|
|
146
|
-
): void
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* 取消监听获取到 Wi-Fi 列表数据事件。
|
|
150
|
-
* @supported weapp
|
|
151
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offGetWifiList.html
|
|
152
|
-
*/
|
|
153
|
-
function offGetWifiList(
|
|
154
|
-
/** 获取到 Wi-Fi 列表数据事件的回调函数 */
|
|
155
|
-
callback: (...args: any[]) => any,
|
|
156
|
-
): void
|
|
157
68
|
|
|
158
69
|
namespace getWifiList {
|
|
159
70
|
interface Option {
|
|
160
71
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
161
|
-
complete?: (res:
|
|
72
|
+
complete?: (res: TaroGeneral.WifiError) => void
|
|
162
73
|
/** 接口调用失败的回调函数 */
|
|
163
|
-
fail?: (res:
|
|
74
|
+
fail?: (res: TaroGeneral.WifiError) => void
|
|
164
75
|
/** 接口调用成功的回调函数 */
|
|
165
|
-
success?: (res:
|
|
166
|
-
|
|
76
|
+
success?: (res: TaroGeneral.WifiError) => void
|
|
77
|
+
}
|
|
167
78
|
}
|
|
168
|
-
/** 请求获取 Wi-Fi 列表。在 `onGetWifiList` 注册的回调中返回 `wifiList` 数据。 **Android 调用前需要 [用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.userLocation。**
|
|
169
|
-
*
|
|
170
|
-
* iOS 将跳转到系统的 Wi-Fi 界面,Android 不会跳转。 iOS 11.0 及 iOS 11.1 两个版本因系统问题,该方法失效。但在 iOS 11.2 中已修复。
|
|
171
|
-
* @supported weapp
|
|
172
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getWifiList.html
|
|
173
|
-
*/
|
|
174
|
-
function getWifiList(option?: getWifiList.Option): Promise<General.WifiError>
|
|
175
79
|
|
|
176
80
|
namespace getConnectedWifi {
|
|
177
81
|
interface Option {
|
|
178
82
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
179
|
-
complete?: (res:
|
|
83
|
+
complete?: (res: TaroGeneral.WifiError) => void
|
|
180
84
|
/** 接口调用失败的回调函数 */
|
|
181
|
-
fail?: (res:
|
|
85
|
+
fail?: (res: TaroGeneral.WifiError) => void
|
|
182
86
|
/** 接口调用成功的回调函数 */
|
|
183
87
|
success?: (result: SuccessCallbackResult) => void
|
|
184
88
|
}
|
|
185
|
-
interface SuccessCallbackResult extends
|
|
89
|
+
interface SuccessCallbackResult extends TaroGeneral.WifiError {
|
|
186
90
|
/** Wi-Fi 信息 */
|
|
187
91
|
wifi: WifiInfo
|
|
188
92
|
/** 调用结果 */
|
|
189
93
|
errMsg: string
|
|
190
94
|
}
|
|
191
95
|
}
|
|
192
|
-
/** 获取已连接中的 Wi-Fi 信息。
|
|
193
|
-
* @supported weapp
|
|
194
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getConnectedWifi.html
|
|
195
|
-
*/
|
|
196
|
-
function getConnectedWifi(option?: getConnectedWifi.Option): Promise<General.WifiError>
|
|
197
96
|
|
|
198
97
|
namespace connectWifi {
|
|
199
98
|
interface Option {
|
|
@@ -204,31 +103,14 @@ declare namespace Taro {
|
|
|
204
103
|
/** Wi-Fi 设备 BSSID */
|
|
205
104
|
BSSID?: string
|
|
206
105
|
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
207
|
-
complete?: (res:
|
|
106
|
+
complete?: (res: TaroGeneral.WifiError) => void
|
|
208
107
|
/** 接口调用失败的回调函数 */
|
|
209
|
-
fail?: (res:
|
|
108
|
+
fail?: (res: TaroGeneral.WifiError) => void
|
|
210
109
|
/** 接口调用成功的回调函数 */
|
|
211
|
-
success?: (res:
|
|
110
|
+
success?: (res: TaroGeneral.WifiError) => void
|
|
212
111
|
}
|
|
213
112
|
}
|
|
214
113
|
|
|
215
|
-
/**
|
|
216
|
-
* 连接 Wi-Fi。若已知 Wi-Fi 信息,可以直接利用该接口连接。仅 Android 与 iOS 11 以上版本支持。
|
|
217
|
-
* @example
|
|
218
|
-
* ```tsx
|
|
219
|
-
* Taro.connectWifi({
|
|
220
|
-
* SSID: '',
|
|
221
|
-
* BSSID: '',
|
|
222
|
-
* success: function (res) {
|
|
223
|
-
* console.log(res.errMsg)
|
|
224
|
-
* }
|
|
225
|
-
* })
|
|
226
|
-
* ```
|
|
227
|
-
* @supported weapp
|
|
228
|
-
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.connectWifi.html
|
|
229
|
-
*/
|
|
230
|
-
function connectWifi(option: connectWifi.Option): Promise<General.WifiError>
|
|
231
|
-
|
|
232
114
|
/** Wifi 信息 */
|
|
233
115
|
interface WifiInfo {
|
|
234
116
|
/** Wi-Fi 的 BSSID */
|
|
@@ -240,4 +122,133 @@ declare namespace Taro {
|
|
|
240
122
|
/** Wi-Fi 信号强度 */
|
|
241
123
|
signalStrength: number
|
|
242
124
|
}
|
|
125
|
+
|
|
126
|
+
interface TaroStatic {
|
|
127
|
+
/** 关闭 Wi-Fi 模块。
|
|
128
|
+
* @supported weapp
|
|
129
|
+
* @example
|
|
130
|
+
* ```tsx
|
|
131
|
+
* Taro.stopWifi({
|
|
132
|
+
* success: function (res) {
|
|
133
|
+
* console.log(res.errMsg)
|
|
134
|
+
* }
|
|
135
|
+
* })
|
|
136
|
+
* ```
|
|
137
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.stopWifi.html
|
|
138
|
+
*/
|
|
139
|
+
stopWifi(option?: stopWifi.Option): Promise<TaroGeneral.WifiError>
|
|
140
|
+
|
|
141
|
+
/** 初始化 Wi-Fi 模块。
|
|
142
|
+
* @supported weapp
|
|
143
|
+
* @example
|
|
144
|
+
* ```tsx
|
|
145
|
+
* Taro.startWifi({
|
|
146
|
+
* success: function (res) {
|
|
147
|
+
* console.log(res.errMsg)
|
|
148
|
+
* }
|
|
149
|
+
* })
|
|
150
|
+
* ```
|
|
151
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.startWifi.html
|
|
152
|
+
*/
|
|
153
|
+
startWifi(option?: startWifi.Option): Promise<TaroGeneral.WifiError>
|
|
154
|
+
|
|
155
|
+
/** 设置 `wifiList` 中 AP 的相关信息。在 `onGetWifiList` 回调后调用,**iOS特有接口**。
|
|
156
|
+
*
|
|
157
|
+
* **注意**
|
|
158
|
+
* - 该接口只能在 `onGetWifiList` 回调之后才能调用。
|
|
159
|
+
* - 此时客户端会挂起,等待小程序设置 Wi-Fi 信息,请务必尽快调用该接口,若无数据请传入一个空数组。
|
|
160
|
+
* - 有可能随着周边 Wi-Fi 列表的刷新,单个流程内收到多次带有存在重复的 Wi-Fi 列表的回调。
|
|
161
|
+
* @supported weapp
|
|
162
|
+
* @example
|
|
163
|
+
* ```tsx
|
|
164
|
+
* Taro.onGetWifiList(function (res) {
|
|
165
|
+
* if (res.wifiList.length) {
|
|
166
|
+
* Taro.setWifiList({
|
|
167
|
+
* wifiList: [{
|
|
168
|
+
* SSID: res.wifiList[0].SSID,
|
|
169
|
+
* BSSID: res.wifiList[0].BSSID,
|
|
170
|
+
* password: '123456'
|
|
171
|
+
* }]
|
|
172
|
+
* })
|
|
173
|
+
* } else {
|
|
174
|
+
* Taro.setWifiList({
|
|
175
|
+
* wifiList: []
|
|
176
|
+
* })
|
|
177
|
+
* }
|
|
178
|
+
* })
|
|
179
|
+
* Taro.getWifiList()
|
|
180
|
+
* ```
|
|
181
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.setWifiList.html
|
|
182
|
+
*/
|
|
183
|
+
setWifiList(option: setWifiList.Option): Promise<TaroGeneral.WifiError>
|
|
184
|
+
|
|
185
|
+
/** 监听连接上 Wi-Fi 的事件。
|
|
186
|
+
* @supported weapp
|
|
187
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.onWifiConnected.html
|
|
188
|
+
*/
|
|
189
|
+
onWifiConnected(
|
|
190
|
+
/** 连接上 Wi-Fi 的事件的回调函数 */
|
|
191
|
+
callback: onWifiConnected.Callback,
|
|
192
|
+
): void
|
|
193
|
+
|
|
194
|
+
/** 监听获取到 Wi-Fi 列表数据事件
|
|
195
|
+
* @supported weapp
|
|
196
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.onGetWifiList.html
|
|
197
|
+
*/
|
|
198
|
+
onGetWifiList(
|
|
199
|
+
/** 获取到 Wi-Fi 列表数据事件的回调函数 */
|
|
200
|
+
callback: onGetWifiList.Callback,
|
|
201
|
+
): void
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* 取消监听连接上 Wi-Fi 的事件。
|
|
205
|
+
* @supported weapp
|
|
206
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offWifiConnected.html
|
|
207
|
+
*/
|
|
208
|
+
offWifiConnected(
|
|
209
|
+
/** 连接上 Wi-Fi 的事件的回调函数 */
|
|
210
|
+
callback: (...args: any[]) => any,
|
|
211
|
+
): void
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* 取消监听获取到 Wi-Fi 列表数据事件。
|
|
215
|
+
* @supported weapp
|
|
216
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offGetWifiList.html
|
|
217
|
+
*/
|
|
218
|
+
offGetWifiList(
|
|
219
|
+
/** 获取到 Wi-Fi 列表数据事件的回调函数 */
|
|
220
|
+
callback: (...args: any[]) => any,
|
|
221
|
+
): void
|
|
222
|
+
|
|
223
|
+
/** 请求获取 Wi-Fi 列表。在 `onGetWifiList` 注册的回调中返回 `wifiList` 数据。 **Android 调用前需要 [用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.userLocation。**
|
|
224
|
+
*
|
|
225
|
+
* iOS 将跳转到系统的 Wi-Fi 界面,Android 不会跳转。 iOS 11.0 及 iOS 11.1 两个版本因系统问题,该方法失效。但在 iOS 11.2 中已修复。
|
|
226
|
+
* @supported weapp
|
|
227
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getWifiList.html
|
|
228
|
+
*/
|
|
229
|
+
getWifiList(option?: getWifiList.Option): Promise<TaroGeneral.WifiError>
|
|
230
|
+
|
|
231
|
+
/** 获取已连接中的 Wi-Fi 信息。
|
|
232
|
+
* @supported weapp
|
|
233
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getConnectedWifi.html
|
|
234
|
+
*/
|
|
235
|
+
getConnectedWifi(option?: getConnectedWifi.Option): Promise<TaroGeneral.WifiError>
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 连接 Wi-Fi。若已知 Wi-Fi 信息,可以直接利用该接口连接。仅 Android 与 iOS 11 以上版本支持。
|
|
239
|
+
* @example
|
|
240
|
+
* ```tsx
|
|
241
|
+
* Taro.connectWifi({
|
|
242
|
+
* SSID: '',
|
|
243
|
+
* BSSID: '',
|
|
244
|
+
* success: function (res) {
|
|
245
|
+
* console.log(res.errMsg)
|
|
246
|
+
* }
|
|
247
|
+
* })
|
|
248
|
+
* ```
|
|
249
|
+
* @supported weapp
|
|
250
|
+
* @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.connectWifi.html
|
|
251
|
+
*/
|
|
252
|
+
connectWifi(option: connectWifi.Option): Promise<TaroGeneral.WifiError>
|
|
253
|
+
}
|
|
243
254
|
}
|