@tarojs/taro 3.3.10 → 3.3.14

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.
Files changed (100) hide show
  1. package/html5.css +5 -5
  2. package/package.json +5 -5
  3. package/types/api/ad/index.d.ts +34 -28
  4. package/types/api/alipay/index.d.ts +11 -7
  5. package/types/api/base/debug.d.ts +60 -54
  6. package/types/api/base/env.d.ts +12 -8
  7. package/types/api/base/index.d.ts +87 -83
  8. package/types/api/base/system.d.ts +59 -54
  9. package/types/api/base/update.d.ts +37 -33
  10. package/types/api/base/weapp/app-event.d.ts +147 -131
  11. package/types/api/base/weapp/life-cycle.d.ts +14 -10
  12. package/types/api/canvas/index.d.ts +115 -110
  13. package/types/api/cloud/index.d.ts +99 -94
  14. package/types/api/data-analysis/index.d.ts +72 -0
  15. package/types/api/device/accelerometer.d.ts +57 -50
  16. package/types/api/device/battery.d.ts +19 -15
  17. package/types/api/device/ble.d.ts +241 -228
  18. package/types/api/device/bluetooth.d.ts +207 -194
  19. package/types/api/device/clipboard.d.ts +48 -43
  20. package/types/api/device/compass.d.ts +55 -48
  21. package/types/api/device/contact.d.ts +13 -9
  22. package/types/api/device/gyroscope.d.ts +41 -35
  23. package/types/api/device/iBeacon.d.ts +79 -73
  24. package/types/api/device/motion.d.ts +42 -37
  25. package/types/api/device/network.d.ts +48 -42
  26. package/types/api/device/nfc.d.ts +105 -96
  27. package/types/api/device/performance.d.ts +22 -18
  28. package/types/api/device/phone.d.ts +20 -15
  29. package/types/api/device/scan.d.ts +31 -26
  30. package/types/api/device/screen.d.ts +74 -67
  31. package/types/api/device/vibrate.d.ts +31 -25
  32. package/types/api/device/wifi.d.ts +151 -140
  33. package/types/api/ext/index.d.ts +44 -39
  34. package/types/api/files/index.d.ts +219 -209
  35. package/types/api/framework/index.d.ts +25 -20
  36. package/types/api/location/index.d.ts +140 -136
  37. package/types/api/media/audio.d.ts +139 -127
  38. package/types/api/media/background-audio.d.ts +135 -126
  39. package/types/api/media/camera.d.ts +30 -26
  40. package/types/api/media/editor.d.ts +35 -33
  41. package/types/api/media/image.d.ts +190 -137
  42. package/types/api/media/live.d.ts +88 -82
  43. package/types/api/media/map.d.ts +47 -43
  44. package/types/api/media/recorder.d.ts +90 -84
  45. package/types/api/media/video-processing.d.ts +10 -6
  46. package/types/api/media/video.d.ts +63 -58
  47. package/types/api/network/download.d.ts +34 -30
  48. package/types/api/network/mdns.d.ts +104 -91
  49. package/types/api/network/request.d.ts +83 -79
  50. package/types/api/network/udp.d.ts +20 -16
  51. package/types/api/network/upload.d.ts +60 -56
  52. package/types/api/network/websocket.d.ts +201 -194
  53. package/types/api/open-api/account.d.ts +18 -14
  54. package/types/api/open-api/address.d.ts +27 -23
  55. package/types/api/open-api/authorize.d.ts +30 -26
  56. package/types/api/open-api/card.d.ts +55 -51
  57. package/types/api/open-api/customer-service.d.ts +45 -0
  58. package/types/api/open-api/facial.d.ts +28 -24
  59. package/types/api/open-api/invoice.d.ts +38 -34
  60. package/types/api/open-api/login.d.ts +56 -52
  61. package/types/api/open-api/navigate.d.ts +79 -75
  62. package/types/api/open-api/payment.d.ts +34 -30
  63. package/types/api/open-api/settings.d.ts +54 -45
  64. package/types/api/open-api/soter.d.ts +92 -86
  65. package/types/api/open-api/subscribe-message.d.ts +24 -20
  66. package/types/api/open-api/user-info.d.ts +60 -57
  67. package/types/api/open-api/werun.d.ts +50 -46
  68. package/types/api/route/index.d.ts +122 -118
  69. package/types/api/share/index.d.ts +68 -64
  70. package/types/api/storage/background-fetch.d.ts +40 -35
  71. package/types/api/storage/index.d.ts +267 -262
  72. package/types/api/swan/index.d.ts +47 -42
  73. package/types/api/ui/animation.d.ts +21 -17
  74. package/types/api/ui/background.d.ts +38 -34
  75. package/types/api/ui/custom-component.d.ts +22 -18
  76. package/types/api/ui/fonts.d.ts +26 -21
  77. package/types/api/ui/interaction.d.ts +167 -121
  78. package/types/api/ui/keyboard.d.ts +59 -55
  79. package/types/api/ui/menu.d.ts +10 -6
  80. package/types/api/ui/navigation-bar.d.ts +67 -63
  81. package/types/api/ui/pull-down-refresh.d.ts +33 -29
  82. package/types/api/ui/scroll.d.ts +30 -26
  83. package/types/api/ui/sticky.d.ts +22 -19
  84. package/types/api/ui/tab-bar.d.ts +101 -97
  85. package/types/api/ui/window.d.ts +24 -18
  86. package/types/api/worker/index.d.ts +28 -24
  87. package/types/api/wxml/index.d.ts +42 -38
  88. package/types/global.d.ts +350 -0
  89. package/types/index.d.ts +14 -99
  90. package/types/taro.api.d.ts +94 -0
  91. package/types/taro.component.d.ts +10 -57
  92. package/types/taro.config.d.ts +24 -6
  93. package/types/taro.extend.d.ts +70 -67
  94. package/types/taro.hooks.d.ts +68 -67
  95. package/types/taro.lifecycle.d.ts +47 -28
  96. package/types/api/ad/index.ts +0 -6
  97. package/types/api/alipay/index.ts +0 -7
  98. package/types/api/index.d.ts +0 -352
  99. package/types/api/open-api/data-analysis.d.ts +0 -19
  100. package/types/api/open-api/report.d.ts +0 -19
@@ -1,4 +1,6 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace createAnimation {
3
5
  interface Option {
4
6
  /** 动画延迟时间,单位 ms */
@@ -27,28 +29,13 @@ declare namespace Taro {
27
29
  }
28
30
  }
29
31
 
30
- /** 创建一个动画实例 animation。调用实例的方法来描述动画。最后通过动画实例的 export 方法导出动画数据传递给组件的 animation 属性。
31
- * @supported weapp, h5
32
- * @example
33
- * ```tsx
34
- * var animation = Taro.createAnimation({
35
- * transformOrigin: "50% 50%",
36
- * duration: 1000,
37
- * timingFunction: "ease",
38
- * delay: 0
39
- * })
40
- * ```
41
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/wx.createAnimation.html
42
- */
43
- function createAnimation(option: createAnimation.Option): Animation
44
-
45
32
  interface Animation {
46
33
  /** 导出动画队列。**export 方法每次调用后会清掉之前的动画操作。**
47
34
  * @supported weapp
48
35
  * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.export.html
49
36
  */
50
37
  export(): {
51
- actions: General.IAnyObject[]
38
+ actions: TaroGeneral.IAnyObject[]
52
39
  }
53
40
  /** 设置背景色
54
41
  * @supported weapp
@@ -465,4 +452,21 @@ declare namespace Taro {
465
452
  /** 起始和结束的滚动范围映射的时间长度,该时间可用于与关键帧动画里的时间 (duration) 相匹配,单位 ms */
466
453
  timeRange: number
467
454
  }
455
+
456
+ interface TaroStatic {
457
+ /** 创建一个动画实例 animation。调用实例的方法来描述动画。最后通过动画实例的 export 方法导出动画数据传递给组件的 animation 属性。
458
+ * @supported weapp, h5
459
+ * @example
460
+ * ```tsx
461
+ * var animation = Taro.createAnimation({
462
+ * transformOrigin: "50% 50%",
463
+ * duration: 1000,
464
+ * timingFunction: "ease",
465
+ * delay: 0
466
+ * })
467
+ * ```
468
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/wx.createAnimation.html
469
+ */
470
+ createAnimation(option: createAnimation.Option): Animation
471
+ }
468
472
  }
@@ -1,4 +1,6 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace setBackgroundTextStyle {
3
5
  interface Option {
4
6
  /** 下拉背景字体、loading 图的样式。
@@ -8,26 +10,14 @@ declare namespace Taro {
8
10
  * - 'light': light 样式; */
9
11
  textStyle: 'dark' | 'light'
10
12
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
11
- complete?: (res: General.CallbackResult) => void
13
+ complete?: (res: TaroGeneral.CallbackResult) => void
12
14
  /** 接口调用失败的回调函数 */
13
- fail?: (res: General.CallbackResult) => void
15
+ fail?: (res: TaroGeneral.CallbackResult) => void
14
16
  /** 接口调用成功的回调函数 */
15
- success?: (res: General.CallbackResult) => void
17
+ success?: (res: TaroGeneral.CallbackResult) => void
16
18
  }
17
19
  }
18
20
 
19
- /** 动态设置下拉背景字体、loading 图的样式
20
- * @supported weapp
21
- * @example
22
- * ```tsx
23
- * Taro.setBackgroundTextStyle({
24
- * textStyle: 'dark' // 下拉背景字体、loading 图的样式为dark
25
- * })
26
- * ```
27
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/background/wx.setBackgroundTextStyle.html
28
- */
29
- function setBackgroundTextStyle(option: setBackgroundTextStyle.Option): Promise<General.CallbackResult>
30
-
31
21
  namespace setBackgroundColor {
32
22
  interface Option {
33
23
  /** 窗口的背景色,必须为十六进制颜色值 */
@@ -37,27 +27,41 @@ declare namespace Taro {
37
27
  /** 顶部窗口的背景色,必须为十六进制颜色值,仅 iOS 支持 */
38
28
  backgroundColorTop?: string
39
29
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
40
- complete?: (res: General.CallbackResult) => void
30
+ complete?: (res: TaroGeneral.CallbackResult) => void
41
31
  /** 接口调用失败的回调函数 */
42
- fail?: (res: General.CallbackResult) => void
32
+ fail?: (res: TaroGeneral.CallbackResult) => void
43
33
  /** 接口调用成功的回调函数 */
44
- success?: (res: General.CallbackResult) => void
34
+ success?: (res: TaroGeneral.CallbackResult) => void
45
35
  }
46
36
  }
47
37
 
48
- /** 动态设置窗口的背景色
49
- * @supported weapp
50
- * @example
51
- * ```tsx
52
- * Taro.setBackgroundColor({
53
- * backgroundColor: '#ffffff', // 窗口的背景色为白色
54
- * })
55
- * Taro.setBackgroundColor({
56
- * backgroundColorTop: '#ffffff', // 顶部窗口的背景色为白色
57
- * backgroundColorBottom: '#ffffff', // 底部窗口的背景色为白色
58
- * })
59
- * ```
60
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/background/wx.setBackgroundColor.html
61
- */
62
- function setBackgroundColor(option: setBackgroundColor.Option): Promise<General.CallbackResult>
38
+ interface TaroStatic {
39
+ /** 动态设置下拉背景字体、loading 图的样式
40
+ * @supported weapp
41
+ * @example
42
+ * ```tsx
43
+ * Taro.setBackgroundTextStyle({
44
+ * textStyle: 'dark' // 下拉背景字体、loading 图的样式为dark
45
+ * })
46
+ * ```
47
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/background/wx.setBackgroundTextStyle.html
48
+ */
49
+ setBackgroundTextStyle(option: setBackgroundTextStyle.Option): Promise<TaroGeneral.CallbackResult>
50
+
51
+ /** 动态设置窗口的背景色
52
+ * @supported weapp
53
+ * @example
54
+ * ```tsx
55
+ * Taro.setBackgroundColor({
56
+ * backgroundColor: '#ffffff', // 窗口的背景色为白色
57
+ * })
58
+ * Taro.setBackgroundColor({
59
+ * backgroundColorTop: '#ffffff', // 顶部窗口的背景色为白色
60
+ * backgroundColorBottom: '#ffffff', // 底部窗口的背景色为白色
61
+ * })
62
+ * ```
63
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/background/wx.setBackgroundColor.html
64
+ */
65
+ setBackgroundColor(option: setBackgroundColor.Option): Promise<TaroGeneral.CallbackResult>
66
+ }
63
67
  }
@@ -1,19 +1,23 @@
1
- declare namespace Taro {
2
- /** 延迟一部分操作到下一个时间片再执行。(类似于 setTimeout)
3
- *
4
- * **说明**
5
- * 因为自定义组件中的 setData 和 triggerEvent 等接口本身是同步的操作,当这几个接口被连续调用时,都是在一个同步流程中执行完的,因此若逻辑不当可能会导致出错。
6
- * 一个极端的案例:当父组件的 setData 引发了子组件的 triggerEvent,进而使得父组件又进行了一次 setData,期间有通过 wx:if 语句对子组件进行卸载,就有可能引发奇怪的错误,所以对于不需要在一个同步流程内完成的逻辑,可以使用此接口延迟到下一个时间片再执行。
7
- * @supported weapp
8
- * @example
9
- * ```tsx
10
- * this.setData({ number: 1 }) // 直接在当前同步流程中执行
11
- * Taro.nextTick(() => {
12
- * this.setData({ number: 3 }) // 在当前同步流程结束后,下一个时间片执行
13
- * })
14
- * this.setData({ number: 2 }) // 直接在当前同步流程中执行
15
- * ```
16
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/custom-component/wx.nextTick.html
17
- */
18
- function nextTick(callback: (...args: any[]) => any): void
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ interface TaroStatic {
5
+ /** 延迟一部分操作到下一个时间片再执行。(类似于 setTimeout)
6
+ *
7
+ * **说明**
8
+ * 因为自定义组件中的 setData 和 triggerEvent 等接口本身是同步的操作,当这几个接口被连续调用时,都是在一个同步流程中执行完的,因此若逻辑不当可能会导致出错。
9
+ * 一个极端的案例:当父组件的 setData 引发了子组件的 triggerEvent,进而使得父组件又进行了一次 setData,期间有通过 wx:if 语句对子组件进行卸载,就有可能引发奇怪的错误,所以对于不需要在一个同步流程内完成的逻辑,可以使用此接口延迟到下一个时间片再执行。
10
+ * @supported weapp
11
+ * @example
12
+ * ```tsx
13
+ * this.setData({ number: 1 }) // 直接在当前同步流程中执行
14
+ * Taro.nextTick(() => {
15
+ * this.setData({ number: 3 }) // 在当前同步流程结束后,下一个时间片执行
16
+ * })
17
+ * this.setData({ number: 2 }) // 直接在当前同步流程中执行
18
+ * ```
19
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/custom-component/wx.nextTick.html
20
+ */
21
+ nextTick(callback: (...args: any[]) => any): void
22
+ }
19
23
  }
@@ -1,4 +1,6 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace loadFontFace {
3
5
  interface Option {
4
6
  /** 是否全局生效
@@ -52,24 +54,27 @@ declare namespace Taro {
52
54
  status: string
53
55
  }
54
56
  }
55
- /** 动态加载网络字体。文件地址需为下载类型。iOS 仅支持 https 格式文件地址。
56
- *
57
- * 注意:
58
- * 1. 字体文件返回的 contet-type 参考 [font](https://www.iana.org/assignments/media-types/media-types.xhtml#font),格式不正确时会解析失败。
59
- * 2. 字体链接必须是https(ios不支持http)
60
- * 3. 字体链接必须是同源下的,或开启了cors支持,小程序的域名是`servicewechat.com`
61
- * 4. canvas等原生组件不支持使用接口添加的字体
62
- * 5. 工具里提示 Faild to load font可以忽略
63
- * @supported weapp
64
- * @example
65
- * ```tsx
66
- * Taro.loadFontFace({
67
- * family: 'Bitstream Vera Serif Bold',
68
- * source: 'url("https://sungd.github.io/Pacifico.ttf")',
69
- * success: console.log
70
- * })
71
- * ```
72
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/font/wx.loadFontFace.html
73
- */
74
- function loadFontFace(option: loadFontFace.Option): void
57
+
58
+ interface TaroStatic {
59
+ /** 动态加载网络字体。文件地址需为下载类型。iOS 仅支持 https 格式文件地址。
60
+ *
61
+ * 注意:
62
+ * 1. 字体文件返回的 contet-type 参考 [font](https://www.iana.org/assignments/media-types/media-types.xhtml#font),格式不正确时会解析失败。
63
+ * 2. 字体链接必须是https(ios不支持http)
64
+ * 3. 字体链接必须是同源下的,或开启了cors支持,小程序的域名是`servicewechat.com`
65
+ * 4. canvas等原生组件不支持使用接口添加的字体
66
+ * 5. 工具里提示 Faild to load font可以忽略
67
+ * @supported weapp
68
+ * @example
69
+ * ```tsx
70
+ * Taro.loadFontFace({
71
+ * family: 'Bitstream Vera Serif Bold',
72
+ * source: 'url("https://sungd.github.io/Pacifico.ttf")',
73
+ * success: console.log
74
+ * })
75
+ * ```
76
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/font/wx.loadFontFace.html
77
+ */
78
+ loadFontFace(option: loadFontFace.Option): void
79
+ }
75
80
  }
@@ -1,14 +1,16 @@
1
- declare namespace Taro {
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
2
4
  namespace showToast {
3
5
  interface Option {
4
6
  /** 提示的内容 */
5
7
  title: string
6
8
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
7
- complete?: (res: General.CallbackResult) => void
9
+ complete?: (res: TaroGeneral.CallbackResult) => void
8
10
  /** 提示的延迟时间 */
9
11
  duration?: number
10
12
  /** 接口调用失败的回调函数 */
11
- fail?: (res: General.CallbackResult) => void
13
+ fail?: (res: TaroGeneral.CallbackResult) => void
12
14
  /** 图标
13
15
  *
14
16
  * 可选值:
@@ -21,28 +23,10 @@ declare namespace Taro {
21
23
  /** 是否显示透明蒙层,防止触摸穿透 */
22
24
  mask?: boolean
23
25
  /** 接口调用成功的回调函数 */
24
- success?: (res: General.CallbackResult) => void
26
+ success?: (res: TaroGeneral.CallbackResult) => void
25
27
  }
26
28
  }
27
29
 
28
- /** 显示消息提示框
29
- *
30
- * **注意**
31
- * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
32
- * - Taro.showToast 应与 Taro.hideToast 配对使用
33
- * @supported weapp, h5, rn
34
- * @example
35
- * ```tsx
36
- * Taro.showToast({
37
- * title: '成功',
38
- * icon: 'success',
39
- * duration: 2000
40
- * })
41
- * ```
42
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html
43
- */
44
- function showToast(option?: showToast.Option): Promise<General.CallbackResult>
45
-
46
30
  namespace showModal {
47
31
  interface Option {
48
32
  /** 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 */
@@ -50,7 +34,7 @@ declare namespace Taro {
50
34
  /** 取消按钮的文字,最多 4 个字符 */
51
35
  cancelText?: string
52
36
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
53
- complete?: (res: General.CallbackResult) => void
37
+ complete?: (res: TaroGeneral.CallbackResult) => void
54
38
  /** 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 */
55
39
  confirmColor?: string
56
40
  /** 确认按钮的文字,最多 4 个字符 */
@@ -58,7 +42,7 @@ declare namespace Taro {
58
42
  /** 提示的内容 */
59
43
  content?: string
60
44
  /** 接口调用失败的回调函数 */
61
- fail?: (res: General.CallbackResult) => void
45
+ fail?: (res: TaroGeneral.CallbackResult) => void
62
46
  /** 是否显示取消按钮 */
63
47
  showCancel?: boolean
64
48
  /** 接口调用成功的回调函数 */
@@ -67,7 +51,7 @@ declare namespace Taro {
67
51
  title?: string
68
52
  }
69
53
 
70
- interface SuccessCallbackResult extends General.CallbackResult {
54
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
71
55
  /** 为 true 时,表示用户点击了取消(用于 Android 系统区分点击蒙层关闭还是点击取消按钮关闭) */
72
56
  cancel: boolean
73
57
  /** 为 true 时,表示用户点击了确定按钮 */
@@ -77,77 +61,35 @@ declare namespace Taro {
77
61
  }
78
62
  }
79
63
 
80
- /** 显示模态对话框
81
- * **注意**
82
- * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
83
- * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
84
- * @supported weapp, h5, rn
85
- * @example
86
- * ```tsx
87
- * Taro.showModal({
88
- * title: '提示',
89
- * content: '这是一个模态弹窗',
90
- * success: function (res) {
91
- * if (res.confirm) {
92
- * console.log('用户点击确定')
93
- * } else if (res.cancel) {
94
- * console.log('用户点击取消')
95
- * }
96
- * }
97
- * })
98
- * ```
99
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html
100
- */
101
- function showModal(option?: showModal.Option): Promise<showModal.SuccessCallbackResult>
102
-
103
64
  namespace showLoading {
104
65
  interface Option {
105
66
  /** 提示的内容 */
106
67
  title: string
107
68
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
108
- complete?: (res: General.CallbackResult) => void
69
+ complete?: (res: TaroGeneral.CallbackResult) => void
109
70
  /** 接口调用失败的回调函数 */
110
- fail?: (res: General.CallbackResult) => void
71
+ fail?: (res: TaroGeneral.CallbackResult) => void
111
72
  /** 是否显示透明蒙层,防止触摸穿透 */
112
73
  mask?: boolean
113
74
  /** 接口调用成功的回调函数 */
114
- success?: (res: General.CallbackResult) => void
75
+ success?: (res: TaroGeneral.CallbackResult) => void
115
76
  }
116
77
  }
117
78
 
118
- /** 显示 loading 提示框。需主动调用 Taro.hideLoading 才能关闭提示框
119
- *
120
- * **注意**
121
- * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
122
- * - Taro.showLoading 应与 Taro.hideLoading 配对使用
123
- * @supported weapp, h5, rn
124
- * @example
125
- * ```tsx
126
- * Taro.showLoading({
127
- * title: '加载中',
128
- * })
129
- * setTimeout(function () {
130
- * Taro.hideLoading()
131
- * }, 2000)
132
- * ```
133
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showLoading.html
134
- */
135
- function showLoading(option?: showLoading.Option): Promise<General.CallbackResult>
136
-
137
79
  namespace showActionSheet {
138
80
  interface Option {
139
81
  /** 按钮的文字数组,数组长度最大为 6 */
140
82
  itemList: string[]
141
83
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
142
- complete?: (res: General.CallbackResult) => void
84
+ complete?: (res: TaroGeneral.CallbackResult) => void
143
85
  /** 接口调用失败的回调函数 */
144
- fail?: (res: General.CallbackResult) => void
86
+ fail?: (res: TaroGeneral.CallbackResult) => void
145
87
  /** 按钮的文字颜色 */
146
88
  itemColor?: string
147
89
  /** 接口调用成功的回调函数 */
148
90
  success?: (result: SuccessCallbackResult) => void
149
91
  }
150
- interface SuccessCallbackResult extends General.CallbackResult {
92
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
151
93
  /** 用户点击的按钮序号,从上到下的顺序,从0开始 */
152
94
  tapIndex: number
153
95
  /** 调用结果 */
@@ -155,68 +97,172 @@ declare namespace Taro {
155
97
  }
156
98
  }
157
99
 
158
- /** 显示操作菜单
159
- *
160
- * **注意**
161
- * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
162
- * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
163
- * @supported weapp, h5, rn
164
- * @example
165
- * ```tsx
166
- * Taro.showActionSheet({
167
- * itemList: ['A', 'B', 'C'],
168
- * success: function (res) {
169
- * console.log(res.tapIndex)
170
- * },
171
- * fail: function (res) {
172
- * console.log(res.errMsg)
173
- * }
174
- * })
175
- * ```
176
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showActionSheet.html
177
- */
178
- function showActionSheet(option: showActionSheet.Option): Promise<showActionSheet.SuccessCallbackResult>
179
-
180
100
  namespace hideToast {
181
101
  interface Option {
182
102
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
183
- complete?: (res: General.CallbackResult) => void
103
+ complete?: (res: TaroGeneral.CallbackResult) => void
184
104
  /** 接口调用失败的回调函数 */
185
- fail?: (res: General.CallbackResult) => void
105
+ fail?: (res: TaroGeneral.CallbackResult) => void
186
106
  /** 接口调用成功的回调函数 */
187
- success?: (res: General.CallbackResult) => void
107
+ success?: (res: TaroGeneral.CallbackResult) => void
188
108
  }
189
109
  }
190
110
 
191
- /** 隐藏消息提示框
192
- * @supported weapp, h5, rn
193
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html
194
- */
195
- function hideToast(option?: hideToast.Option): void
196
-
197
111
  namespace hideLoading {
198
112
  interface Option {
199
113
  /** 接口调用结束的回调函数(调用成功、失败都会执行) */
200
- complete?: (res: General.CallbackResult) => void
114
+ complete?: (res: TaroGeneral.CallbackResult) => void
115
+ /** 接口调用失败的回调函数 */
116
+ fail?: (res: TaroGeneral.CallbackResult) => void
117
+ /** 接口调用成功的回调函数 */
118
+ success?: (res: TaroGeneral.CallbackResult) => void
119
+ }
120
+ }
121
+
122
+ namespace enableAlertBeforeUnload {
123
+ interface Option {
124
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
125
+ complete?: (res: TaroGeneral.CallbackResult) => void
126
+ /** 接口调用失败的回调函数 */
127
+ fail?: (res: TaroGeneral.CallbackResult) => void
128
+ /** 接口调用成功的回调函数 */
129
+ success?: (res: TaroGeneral.CallbackResult) => void
130
+ }
131
+ }
132
+
133
+ namespace disableAlertBeforeUnload {
134
+ interface Option {
135
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
136
+ complete?: (res: TaroGeneral.CallbackResult) => void
201
137
  /** 接口调用失败的回调函数 */
202
- fail?: (res: General.CallbackResult) => void
138
+ fail?: (res: TaroGeneral.CallbackResult) => void
203
139
  /** 接口调用成功的回调函数 */
204
- success?: (res: General.CallbackResult) => void
140
+ success?: (res: TaroGeneral.CallbackResult) => void
205
141
  }
206
142
  }
207
143
 
208
- /** 隐藏 loading 提示框
209
- * @supported weapp, h5, rn
210
- * @example
211
- * ```tsx
212
- * Taro.showLoading({
213
- * title: '加载中',
214
- * })
215
- * setTimeout(function (){
216
- * Taro.hideLoading()
217
- * },2000)
218
- * ```
219
- * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideLoading.html
220
- */
221
- function hideLoading(option?: hideLoading.Option): void
144
+ interface TaroStatic {
145
+ /** 显示消息提示框
146
+ *
147
+ * **注意**
148
+ * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
149
+ * - Taro.showToast 应与 Taro.hideToast 配对使用
150
+ * @supported weapp, h5, rn
151
+ * @example
152
+ * ```tsx
153
+ * Taro.showToast({
154
+ * title: '成功',
155
+ * icon: 'success',
156
+ * duration: 2000
157
+ * })
158
+ * ```
159
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showToast.html
160
+ */
161
+ showToast(option?: showToast.Option): Promise<TaroGeneral.CallbackResult>
162
+
163
+ /** 显示模态对话框
164
+ * **注意**
165
+ * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
166
+ * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
167
+ * @supported weapp, h5, rn
168
+ * @example
169
+ * ```tsx
170
+ * Taro.showModal({
171
+ * title: '提示',
172
+ * content: '这是一个模态弹窗',
173
+ * success: function (res) {
174
+ * if (res.confirm) {
175
+ * console.log('用户点击确定')
176
+ * } else if (res.cancel) {
177
+ * console.log('用户点击取消')
178
+ * }
179
+ * }
180
+ * })
181
+ * ```
182
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html
183
+ */
184
+ showModal(option?: showModal.Option): Promise<showModal.SuccessCallbackResult>
185
+
186
+ /** 显示 loading 提示框。需主动调用 Taro.hideLoading 才能关闭提示框
187
+ *
188
+ * **注意**
189
+ * - Taro.showLoading 和 Taro.showToast 同时只能显示一个
190
+ * - Taro.showLoading 应与 Taro.hideLoading 配对使用
191
+ * @supported weapp, h5, rn
192
+ * @example
193
+ * ```tsx
194
+ * Taro.showLoading({
195
+ * title: '加载中',
196
+ * })
197
+ * setTimeout(function () {
198
+ * Taro.hideLoading()
199
+ * }, 2000)
200
+ * ```
201
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showLoading.html
202
+ */
203
+ showLoading(option?: showLoading.Option): Promise<TaroGeneral.CallbackResult>
204
+
205
+ /** 显示操作菜单
206
+ *
207
+ * **注意**
208
+ * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel";
209
+ * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑
210
+ * @supported weapp, h5, rn
211
+ * @example
212
+ * ```tsx
213
+ * Taro.showActionSheet({
214
+ * itemList: ['A', 'B', 'C'],
215
+ * success: function (res) {
216
+ * console.log(res.tapIndex)
217
+ * },
218
+ * fail: function (res) {
219
+ * console.log(res.errMsg)
220
+ * }
221
+ * })
222
+ * ```
223
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showActionSheet.html
224
+ */
225
+ showActionSheet(option: showActionSheet.Option): Promise<showActionSheet.SuccessCallbackResult>
226
+
227
+ /** 隐藏消息提示框
228
+ * @supported weapp, h5, rn
229
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html
230
+ */
231
+ hideToast(option?: hideToast.Option): void
232
+
233
+ /** 隐藏 loading 提示框
234
+ * @supported weapp, h5, rn
235
+ * @example
236
+ * ```tsx
237
+ * Taro.showLoading({
238
+ * title: '加载中',
239
+ * })
240
+ * setTimeout(function (){
241
+ * Taro.hideLoading()
242
+ * },2000)
243
+ * ```
244
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideLoading.html
245
+ */
246
+ hideLoading(option?: hideLoading.Option): void /** 隐藏 loading 提示框
247
+
248
+ /** 开启小程序页面返回询问对话框
249
+ * @supported weapp
250
+ * @example
251
+ * ```tsx
252
+ * Taro.enableAlertBeforeUnload({
253
+ * success: function () {
254
+ * console.log('success')
255
+ * },
256
+ * })
257
+ * ```
258
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.enableAlertBeforeUnload.html
259
+ */
260
+ enableAlertBeforeUnload(option?: enableAlertBeforeUnload.Option): void
261
+
262
+ /** 关闭小程序页面返回询问对话框
263
+ * @supported weapp
264
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.disableAlertBeforeUnload.html
265
+ */
266
+ disableAlertBeforeUnload(option?: disableAlertBeforeUnload.Option): void
267
+ }
222
268
  }