@spcsn/taro 0.1.0

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 (140) hide show
  1. package/README.md +12 -0
  2. package/dist/index.js +147 -0
  3. package/dist/index.js.map +1 -0
  4. package/index.js +9 -0
  5. package/package.json +86 -0
  6. package/types/api/ad/index.d.ts +197 -0
  7. package/types/api/ai/face.d.ts +133 -0
  8. package/types/api/ai/inference.d.ts +129 -0
  9. package/types/api/ai/visionkit.d.ts +874 -0
  10. package/types/api/alipay/index.d.ts +69 -0
  11. package/types/api/base/crypto.d.ts +104 -0
  12. package/types/api/base/debug.d.ts +329 -0
  13. package/types/api/base/env.d.ts +19 -0
  14. package/types/api/base/index.d.ts +102 -0
  15. package/types/api/base/performance.d.ts +258 -0
  16. package/types/api/base/system.d.ts +742 -0
  17. package/types/api/base/update.d.ts +130 -0
  18. package/types/api/base/weapp/app-event.d.ts +265 -0
  19. package/types/api/base/weapp/life-cycle.d.ts +155 -0
  20. package/types/api/canvas/index.d.ts +2162 -0
  21. package/types/api/cloud/index.d.ts +2622 -0
  22. package/types/api/data-analysis/index.d.ts +122 -0
  23. package/types/api/device/accelerometer.d.ts +102 -0
  24. package/types/api/device/accessibility.d.ts +26 -0
  25. package/types/api/device/battery.d.ts +46 -0
  26. package/types/api/device/bluetooth-ble.d.ts +601 -0
  27. package/types/api/device/bluetooth-peripheral.d.ts +430 -0
  28. package/types/api/device/bluetooth.d.ts +463 -0
  29. package/types/api/device/calendar.d.ts +98 -0
  30. package/types/api/device/clipboard.d.ts +81 -0
  31. package/types/api/device/compass.d.ts +105 -0
  32. package/types/api/device/contact.d.ts +110 -0
  33. package/types/api/device/gyroscope.d.ts +85 -0
  34. package/types/api/device/iBeacon.d.ts +168 -0
  35. package/types/api/device/keyboard.d.ts +97 -0
  36. package/types/api/device/memory.d.ts +52 -0
  37. package/types/api/device/motion.d.ts +88 -0
  38. package/types/api/device/network.d.ts +172 -0
  39. package/types/api/device/nfc.d.ts +1238 -0
  40. package/types/api/device/phone.d.ts +30 -0
  41. package/types/api/device/scan.d.ts +111 -0
  42. package/types/api/device/screen.d.ts +217 -0
  43. package/types/api/device/sms.d.ts +26 -0
  44. package/types/api/device/vibrate.d.ts +51 -0
  45. package/types/api/device/wifi.d.ts +301 -0
  46. package/types/api/ext/index.d.ts +64 -0
  47. package/types/api/files/index.d.ts +1472 -0
  48. package/types/api/framework/index.d.ts +51 -0
  49. package/types/api/location/index.d.ts +517 -0
  50. package/types/api/media/audio.d.ts +1013 -0
  51. package/types/api/media/background-audio.d.ts +291 -0
  52. package/types/api/media/camera.d.ts +207 -0
  53. package/types/api/media/editor.d.ts +239 -0
  54. package/types/api/media/image.d.ts +469 -0
  55. package/types/api/media/live.d.ts +461 -0
  56. package/types/api/media/map.d.ts +638 -0
  57. package/types/api/media/media-recorder.d.ts +117 -0
  58. package/types/api/media/recorder.d.ts +317 -0
  59. package/types/api/media/video-decoder.d.ts +117 -0
  60. package/types/api/media/video-processing.d.ts +84 -0
  61. package/types/api/media/video.d.ts +527 -0
  62. package/types/api/media/voip.d.ts +393 -0
  63. package/types/api/navigate/index.d.ts +327 -0
  64. package/types/api/network/download.d.ts +173 -0
  65. package/types/api/network/mdns.d.ts +191 -0
  66. package/types/api/network/request.d.ts +480 -0
  67. package/types/api/network/tcp.d.ts +181 -0
  68. package/types/api/network/udp.d.ts +218 -0
  69. package/types/api/network/upload.d.ts +201 -0
  70. package/types/api/network/websocket.d.ts +383 -0
  71. package/types/api/open-api/account.d.ts +51 -0
  72. package/types/api/open-api/address.d.ts +68 -0
  73. package/types/api/open-api/authorize.d.ts +80 -0
  74. package/types/api/open-api/card.d.ts +110 -0
  75. package/types/api/open-api/channels.d.ts +225 -0
  76. package/types/api/open-api/customer-service.d.ts +45 -0
  77. package/types/api/open-api/device-voip.d.ts +103 -0
  78. package/types/api/open-api/facial.d.ts +98 -0
  79. package/types/api/open-api/favorites.d.ts +101 -0
  80. package/types/api/open-api/group.d.ts +59 -0
  81. package/types/api/open-api/invoice.d.ts +87 -0
  82. package/types/api/open-api/license-plate.d.ts +27 -0
  83. package/types/api/open-api/login.d.ts +115 -0
  84. package/types/api/open-api/my-miniprogram.d.ts +28 -0
  85. package/types/api/open-api/privacy.d.ts +107 -0
  86. package/types/api/open-api/redpackage.d.ts +24 -0
  87. package/types/api/open-api/settings.d.ts +174 -0
  88. package/types/api/open-api/soter.d.ts +184 -0
  89. package/types/api/open-api/sticker.d.ts +83 -0
  90. package/types/api/open-api/subscribe-message.d.ts +305 -0
  91. package/types/api/open-api/user-info.d.ts +182 -0
  92. package/types/api/open-api/werun.d.ts +101 -0
  93. package/types/api/payment/index.d.ts +119 -0
  94. package/types/api/qq/index.d.ts +354 -0
  95. package/types/api/route/index.d.ts +324 -0
  96. package/types/api/share/index.d.ts +354 -0
  97. package/types/api/skyline/index.d.ts +345 -0
  98. package/types/api/storage/background-fetch.d.ts +131 -0
  99. package/types/api/storage/cache-manager.d.ts +249 -0
  100. package/types/api/storage/index.d.ts +405 -0
  101. package/types/api/swan/bookshelf.d.ts +307 -0
  102. package/types/api/swan/download-package.d.ts +80 -0
  103. package/types/api/swan/index.d.ts +251 -0
  104. package/types/api/swan/pay.d.ts +139 -0
  105. package/types/api/taro.extend.d.ts +233 -0
  106. package/types/api/taro.hooks.d.ts +148 -0
  107. package/types/api/ui/animation.d.ts +427 -0
  108. package/types/api/ui/background.d.ts +69 -0
  109. package/types/api/ui/custom-component.d.ts +23 -0
  110. package/types/api/ui/fonts.d.ts +77 -0
  111. package/types/api/ui/interaction.d.ts +281 -0
  112. package/types/api/ui/menu.d.ts +29 -0
  113. package/types/api/ui/navigation-bar.d.ts +130 -0
  114. package/types/api/ui/pull-down-refresh.d.ts +50 -0
  115. package/types/api/ui/scroll.d.ts +114 -0
  116. package/types/api/ui/sticky.d.ts +32 -0
  117. package/types/api/ui/tab-bar.d.ts +196 -0
  118. package/types/api/ui/window.d.ts +71 -0
  119. package/types/api/worker/index.d.ts +83 -0
  120. package/types/api/wxml/index.d.ts +540 -0
  121. package/types/compile/compiler.d.ts +32 -0
  122. package/types/compile/config/h5.d.ts +134 -0
  123. package/types/compile/config/harmony.d.ts +118 -0
  124. package/types/compile/config/index.d.ts +8 -0
  125. package/types/compile/config/manifest.d.ts +155 -0
  126. package/types/compile/config/mini.d.ts +118 -0
  127. package/types/compile/config/plugin.d.ts +34 -0
  128. package/types/compile/config/project.d.ts +338 -0
  129. package/types/compile/config/rn.d.ts +85 -0
  130. package/types/compile/config/util.d.ts +179 -0
  131. package/types/compile/hooks.d.ts +13 -0
  132. package/types/compile/index.d.ts +11 -0
  133. package/types/compile/viteCompilerContext.d.ts +167 -0
  134. package/types/global.d.ts +428 -0
  135. package/types/index.d.ts +190 -0
  136. package/types/taro.api.d.ts +130 -0
  137. package/types/taro.component.d.ts +168 -0
  138. package/types/taro.config.d.ts +712 -0
  139. package/types/taro.lifecycle.d.ts +220 -0
  140. package/types/taro.runtime.d.ts +9 -0
@@ -0,0 +1,354 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace openQzonePublish {
5
+ interface Option {
6
+ /** 传递的文字内容 */
7
+ text: string
8
+ /** 传递的视频/图片内容,显示顺序为元素下标顺序 */
9
+ media: Media[]
10
+ /** 说说小尾巴跳转到的页面路径,不填则默认跳到主页 */
11
+ path: string
12
+ /** 说说小尾巴显示的文案,不填则默认显示小程序的简介文案 */
13
+ footnote: string
14
+ }
15
+ type Media = {
16
+ /** 图片填"photo",视频填"video" */
17
+ type: MediaType
18
+ /** 文件路径,必须为本地文件 */
19
+ path: string
20
+ }
21
+ type MediaType = 'photo' | 'video'
22
+ }
23
+
24
+ namespace getQQRunData {
25
+ interface Option {
26
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
27
+ complete?: (res: TaroGeneral.CallbackResult) => void
28
+ /** 接口调用失败的回调函数 */
29
+ fail?: (res: TaroGeneral.CallbackResult) => void
30
+ /** 接口调用成功的回调函数 */
31
+ success?: (result: SuccessCallbackResult) => void
32
+ }
33
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
34
+ /**
35
+ * 包括敏感数据在内的完整用户信息的加密数据,详细见加密数据解密算法。
36
+ */
37
+ encryptedData: string
38
+ /**
39
+ * 加密算法的初始向量,详细见加密数据解密算法
40
+ */
41
+ iv: string
42
+ }
43
+ }
44
+
45
+ namespace setOfficialDress {
46
+ interface Option {
47
+ /** 方法名,设置头像填"setAvatar",其他方法后续开放 */
48
+ action: string
49
+ /** openid,给自己设置头像填"self" */
50
+ uin: string
51
+ /** 物品id */
52
+ item_id?: string
53
+ /** 设置头像"setAvatar"此处不用填 */
54
+ busi_info?: string
55
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
56
+ complete?: (res: TaroGeneral.CallbackResult) => void
57
+ /** 接口调用失败的回调函数 */
58
+ fail?: (res: TaroGeneral.CallbackResult) => void
59
+ /** 接口调用成功的回调函数 */
60
+ success?: (res: TaroGeneral.CallbackResult) => void
61
+ }
62
+ }
63
+
64
+ namespace setCustomDress {
65
+ interface Option {
66
+ /** 方法名,设置头像填"uploadAvatar",其他方法后续开放 */
67
+ action: string
68
+ /** 素材路径,必须为本地文件,路径为 wxfile:// 的形式 */
69
+ path: string
70
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
71
+ complete?: (res: TaroGeneral.CallbackResult) => void
72
+ /** 接口调用失败的回调函数 */
73
+ fail?: (res: TaroGeneral.CallbackResult) => void
74
+ /** 接口调用成功的回调函数 */
75
+ success?: (res: TaroGeneral.CallbackResult) => void
76
+ }
77
+ }
78
+
79
+ namespace updateQQApp {
80
+ interface Option {
81
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
82
+ complete?: (res: TaroGeneral.CallbackResult) => void
83
+ /** 接口调用失败的回调函数 */
84
+ fail?: (res: TaroGeneral.CallbackResult) => void
85
+ /** 接口调用成功的回调函数 */
86
+ success?: (res: TaroGeneral.CallbackResult) => void
87
+ }
88
+ }
89
+
90
+ namespace addRecentColorSign {
91
+ interface Option {
92
+ /**
93
+ * 做为点击最近彩签打开的小程序页面的启动参数,如 a=1&b=2
94
+ * 默认值:当前页面的查询参数
95
+ */
96
+ query?: string
97
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
98
+ complete?: (res: TaroGeneral.CallbackResult) => void
99
+ /** 接口调用失败的回调函数 */
100
+ fail?: (res: TaroGeneral.CallbackResult) => void
101
+ /** 接口调用成功的回调函数 */
102
+ success?: (res: TaroGeneral.CallbackResult) => void
103
+ }
104
+ }
105
+
106
+ namespace getGuildInfo {
107
+ interface Option {
108
+ /** 频道id */
109
+ open_guild_id: string
110
+ /** 子频道Id */
111
+ channel_id?: string
112
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
113
+ complete?: (res: TaroGeneral.CallbackResult) => void
114
+ /** 接口调用失败的回调函数 */
115
+ fail?: (res: TaroGeneral.CallbackResult) => void
116
+ /** 接口调用成功的回调函数 */
117
+ success?: (res: SuccessCallbackResult) => void
118
+ }
119
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
120
+ /** 加密之后的数据,需要解密 */
121
+ encryptedData: string
122
+ /** 对称解密算法初始向量(base64) */
123
+ iv: string
124
+ /** 签名(base64) */
125
+ signature: string
126
+ }
127
+ }
128
+
129
+ namespace applyAddToMyApps {
130
+ interface Option {
131
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
132
+ complete?: (res: TaroGeneral.CallbackResult) => void
133
+ /** 接口调用失败的回调函数 */
134
+ fail?: (res: TaroGeneral.CallbackResult) => void
135
+ /** 接口调用成功的回调函数 */
136
+ success?: (res: SuccessCallbackResult) => void
137
+ }
138
+ interface SuccessCallbackResult {
139
+ /** true 代表用户选择了同意 */
140
+ confirm: boolean
141
+ /** true 代表用户选择了不同意 */
142
+ cancel: boolean
143
+ }
144
+ }
145
+
146
+ namespace isAddedToMyApps {
147
+ interface Option {
148
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
149
+ complete?: (res: TaroGeneral.CallbackResult) => void
150
+ /** 接口调用失败的回调函数 */
151
+ fail?: (res: TaroGeneral.CallbackResult) => void
152
+ /** 接口调用成功的回调函数 */
153
+ success?: (res: SuccessCallbackResult) => void
154
+ }
155
+ interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
156
+ /** true 代表用户已经添加,false 则还没添加 */
157
+ isAdded: boolean
158
+ }
159
+ }
160
+
161
+ interface TaroStatic {
162
+ /**
163
+ * 此接口可打开手Q说说发表界面,并将文字内容和图片/视频内容传递到手Q说说发表界面。
164
+ * @supported qq
165
+ * @example
166
+ * ```tsx
167
+ * Taro.openQzonePublish({
168
+ * footnote: '使用同款滤镜',
169
+ * path: 'pages/index/index',
170
+ * text: '我爱中国',
171
+ * media: [
172
+ * {
173
+ * type: 'photo',
174
+ * path: 'qqfile://1.png'
175
+ * },
176
+ * {
177
+ * type: 'video',
178
+ * path: 'qqfile://2.mp4'
179
+ * }
180
+ * ]
181
+ * })
182
+ * ```
183
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_openQzonePublish.html
184
+ */
185
+ openQzonePublish(option: openQzonePublish.Option): void
186
+ /**
187
+ * 获取用户过去三十天QQ运动步数。需要先调用 qq.login 接口。步数信息会在用户主动进入小程序时更新。
188
+ * @supported qq
189
+ * @example
190
+ * ```tsx
191
+ * Taro.getQQRunData({
192
+ * success(res) {
193
+ * // 拿 encryptedData 到开发者后台解密开放数据
194
+ * const encryptedData = res.encryptedData
195
+ * }
196
+ * })
197
+ * ```
198
+ *
199
+ * **开放数据 JSON 结构**
200
+ * 敏感数据有两种获取方式,一是使用 加密数据解密算法 。 获取得到的开放数据为以下 json 结构:
201
+ *
202
+ * ```json
203
+ * {
204
+ * "stepInfoList": [
205
+ * {
206
+ * "timestamp": 1445866601,
207
+ * "step": 100
208
+ * },
209
+ * {
210
+ * "timestamp": 1445876601,
211
+ * "step": 120
212
+ * }
213
+ * ]
214
+ * }
215
+ * ```
216
+ * * stepInfoList 中,每一项结构如下:
217
+ *
218
+ * | 属性 | 类型 | 说明 |
219
+ * | --- | ---- | --- |
220
+ * | timestamp | number | 时间戳,表示数据对应的时间 |
221
+ * | step | number | QQ运动步数 |
222
+ *
223
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_sport.html
224
+ */
225
+ getQQRunData(option: getQQRunData.Option): void
226
+ /**
227
+ * QQ美化平台内测阶段,仅被邀请的商户可使用此接口。
228
+ * @supported qq
229
+ * @example
230
+ * ```tsx
231
+ * Taro.setOfficialDress({
232
+ * action: "setAvatar",
233
+ * uin: "self",
234
+ * item_id: "2740",
235
+ * success(res) {
236
+ * console.log("success"+res);
237
+ * },
238
+ * fail(res) {
239
+ * console.log("fail"+res);
240
+ * }
241
+ * })
242
+ * ```
243
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/personalize.html#qq-setofficialdress
244
+ */
245
+ setOfficialDress(option: setOfficialDress.Option): void
246
+ /**
247
+ * QQ美化平台内测阶段,仅被邀请的商户可使用此接口。
248
+ * @supported qq
249
+ * @example
250
+ * ```tsx
251
+ * Taro.setCustomDress({
252
+ * action: "uploadAvatar",
253
+ * path:"wxfile://images/1.png"
254
+ * success(res) {
255
+ * console.log("success"+res);
256
+ * },
257
+ * fail(res) {
258
+ * console.log("fail"+res);
259
+ * }
260
+ * })
261
+ * ```
262
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/personalize.html#qq-setcustomdress
263
+ */
264
+ setCustomDress(option: setCustomDress.Option): void
265
+ /**
266
+ * 更新 QQ 版本
267
+ * @supported qq
268
+ * @example
269
+ * ```tsx
270
+ * Taro.updateQQApp({
271
+ * success: function(res) {
272
+ * console.log('updateQQApp success',res)
273
+ * },
274
+ * fail: function(err) {
275
+ * console.log('updateQQApp fail',err)
276
+ * },
277
+ * complete: function(res) {
278
+ * console.log('updateQQApp info',res)
279
+ * }
280
+ * })
281
+ * ```
282
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_updateQQ.html#qq-updateqqapp
283
+ */
284
+ updateQQApp(option: updateQQApp.Option): void
285
+ /**
286
+ * 添加当前小程序页面到最近浏览彩签,需要授权基础库 1.20.0 开始支持。
287
+ * 提示:在手 Q 8.9.0 前的版本,当系统未授予手 Q 悬浮穿权限时,每次调用该接口都会弹出系统授权窗口。自手 Q 8.9.0 起交互调整如下:
288
+ * 1. 系统没有授予手 Q 悬浮窗权限时,接口执行 fail 回调函数并附带 ”No floating window permission“的错误信息,开发者可针对此信息在业务代码里弹窗提示用户手动授予手 Q 悬浮窗权限。
289
+ * 2. 安卓系统部分机型存在获取悬浮窗权限不准确情况。
290
+ * @supported qq
291
+ * @example
292
+ * ```tsx
293
+ * Taro.addRecentColorSign({
294
+ * query: 'a=1&b=2',
295
+ * success(res) {
296
+ * console.log('addRecentColorSign success: ', res)
297
+ * },
298
+ * fail(err) {
299
+ * console.log('addRecentColorSign fail: ', err)
300
+ * },
301
+ * complete(res) {
302
+ * console.log('addRecentColorSign complete: ', res)
303
+ * }
304
+ * })
305
+ * ```
306
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addColorSign.html#qq-addrecentcolorsign
307
+ */
308
+ addRecentColorSign(option: addRecentColorSign.Option): void
309
+ /**
310
+ * 获取频道信息与当前人身份(FOR 机器人服务入口)
311
+ * @supported qq
312
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_guild.html
313
+ */
314
+ getGuildInfo(option: getGuildInfo.Option): void
315
+ /**
316
+ * 申请用户将本小程序添加到下拉页面中“我的小程序”当中,手Q8.9.13及以上版本支持
317
+ * @supported qq
318
+ * @example
319
+ * ```tsx
320
+ * Taro.applyAddToMyApps({
321
+ * success(res) {
322
+ * if (res.confirm) {
323
+ * // 用户同意添加
324
+ * }
325
+ * if (res.cancel) {
326
+ * // 用户不同意添加
327
+ * }
328
+ * // 原则上,confirm和cancel是互斥的
329
+ * }
330
+ * })
331
+ * ```
332
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addToMyApps.html#qq-applyaddtomyapps
333
+ */
334
+ applyAddToMyApps(option: applyAddToMyApps.Option): void
335
+ /**
336
+ * 查询用户是否已经将本小程序添加到下拉页面中“我的小程序”当中,手Q8.9.13及以上版本支持,建议使用qq.applyAddToMyApps之前先调用qq.isAddedToMyApps来作前置判断
337
+ * @supported qq
338
+ * @example
339
+ * ```tsx
340
+ * Taro.isAddedToMyApps({
341
+ * success(res) {
342
+ * if (res.isAdded) {
343
+ * // 用户已经添加
344
+ * } else {
345
+ * // 用户还未添加
346
+ * }
347
+ * }
348
+ * })
349
+ * ```
350
+ * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addToMyApps.html#qq-isaddedtomyapps
351
+ */
352
+ isAddedToMyApps(option: isAddedToMyApps.Option): void
353
+ }
354
+ }
@@ -0,0 +1,324 @@
1
+ import Taro from '../../index'
2
+
3
+ declare module '../../index' {
4
+ namespace switchTab {
5
+ interface Option {
6
+ /** 需要跳转的 tabBar 页面的路径(需在 app.json 的 [tabBar](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#tabbar) 字段定义的页面),路径后不能带参数。 */
7
+ url: string
8
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
9
+ complete?: (res: TaroGeneral.CallbackResult) => void
10
+ /** 接口调用失败的回调函数 */
11
+ fail?: (res: TaroGeneral.CallbackResult) => void
12
+ /** 接口调用成功的回调函数 */
13
+ success?: (res: TaroGeneral.CallbackResult) => void
14
+ }
15
+ }
16
+
17
+ namespace reLaunch {
18
+ interface Option {
19
+ /** 需要跳转的应用内页面路径,路径后可以带参数。参数与路径之间使用?分隔,参数键与参数值用=相连,不同参数用&分隔;如 'path?key=value&key2=value2' */
20
+ url: string
21
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
22
+ complete?: (res: TaroGeneral.CallbackResult) => void
23
+ /** 接口调用失败的回调函数 */
24
+ fail?: (res: TaroGeneral.CallbackResult) => void
25
+ /** 接口调用成功的回调函数 */
26
+ success?: (res: TaroGeneral.CallbackResult) => void
27
+ }
28
+ }
29
+
30
+ namespace redirectTo {
31
+ interface Option {
32
+ /** 需要跳转的应用内非 tabBar 的页面的路径, 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */
33
+ url: string
34
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
35
+ complete?: (res: TaroGeneral.CallbackResult) => void
36
+ /** 接口调用失败的回调函数 */
37
+ fail?: (res: TaroGeneral.CallbackResult) => void
38
+ /** 接口调用成功的回调函数 */
39
+ success?: (res: TaroGeneral.CallbackResult) => void
40
+ }
41
+ }
42
+
43
+ namespace navigateTo {
44
+ interface Option {
45
+ /** 需要跳转的应用内非 tabBar 的页面的路径, 路径后可以带参数。参数与路径之间使用 `?` 分隔,参数键与参数值用 `=` 相连,不同参数用 `&` 分隔;如 'path?key=value&key2=value2' */
46
+ url: string
47
+ /** 页面间通信接口,用于监听被打开页面发送到当前页面的数据。 */
48
+ events?: TaroGeneral.IAnyObject
49
+ /** 2.29.2 自定义路由类型 */
50
+ routeType?: string
51
+ /** 3.4.0 自定义路由配置 */
52
+ routeConfig?: TaroGeneral.IAnyObject
53
+ /** 3.4.0 自定义路由参数 */
54
+ routeOptions?: TaroGeneral.IAnyObject
55
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
56
+ complete?: (res: TaroGeneral.CallbackResult) => void
57
+ /** 接口调用失败的回调函数 */
58
+ fail?: (res: TaroGeneral.CallbackResult) => void
59
+ /** 接口调用成功的回调函数 */
60
+ success?: (res: TaroGeneral.CallbackResult & { eventChannel: EventChannel }) => void
61
+ }
62
+ }
63
+
64
+ namespace navigateBack {
65
+ interface Option {
66
+ /** 接口调用结束的回调函数(调用成功、失败都会执行) */
67
+ complete?: (res: TaroGeneral.CallbackResult) => void
68
+ /** 返回的页面数,如果 delta 大于现有页面数,则返回到首页。 */
69
+ delta?: number
70
+ /** 接口调用失败的回调函数 */
71
+ fail?: (res: TaroGeneral.CallbackResult) => void
72
+ /** 接口调用成功的回调函数 */
73
+ success?: (res: TaroGeneral.CallbackResult) => void
74
+ }
75
+ }
76
+
77
+ /** 页面间事件通信通道
78
+ * @supported weapp
79
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.html
80
+ */
81
+ interface EventChannel {
82
+ /** 触发一个事件
83
+ * @supported weapp
84
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.emit.html
85
+ */
86
+ emit(
87
+ /** 事件名称 */
88
+ eventName: string,
89
+ /** 事件参数 */
90
+ ...args: any
91
+ ): void
92
+ /** 持续监听一个事件
93
+ * @supported weapp
94
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.on.html
95
+ */
96
+ on(
97
+ /** 事件名称 */
98
+ eventName: string,
99
+ /** 事件监听函数 */
100
+ fn: TaroGeneral.EventCallback,
101
+ ): void
102
+ /** 监听一个事件一次,触发后失效
103
+ * @supported weapp
104
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.once.html
105
+ */
106
+ once(
107
+ /** 事件名称 */
108
+ eventName: string,
109
+ /** 事件监听函数 */
110
+ fn: TaroGeneral.EventCallback,
111
+ ): void
112
+ /** 取消监听一个事件。给出第二个参数时,只取消给出的监听函数,否则取消所有监听函数
113
+ * @supported weapp
114
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/EventChannel.off.html
115
+ */
116
+ off(
117
+ /** 事件名称 */
118
+ eventName: string,
119
+ /** 事件监听函数 */
120
+ fn: TaroGeneral.EventCallback,
121
+ ): void
122
+ }
123
+
124
+ namespace router {
125
+ type CustomRouteBuilder = (routeContext: CustomRouteContext, routeOptions: Record<string, any>) => CustomRouteConfig
126
+
127
+ interface SharedValue<T> {
128
+ value: T
129
+ }
130
+
131
+ interface CustomRouteContext {
132
+ // 动画控制器,影响推入页面的进入和退出过渡效果
133
+ primaryAnimation: SharedValue<number>
134
+ // 动画控制器状态
135
+ primaryAnimationStatus: SharedValue<number>
136
+ // 动画控制器,影响栈顶页面的推出过渡效果
137
+ secondaryAnimation: SharedValue<number>
138
+ // 动画控制器状态
139
+ secondaryAnimationStatus: SharedValue<number>
140
+ // 当前路由进度由手势控制
141
+ userGestureInProgress: SharedValue<number>
142
+ // 手势开始控制路由
143
+ startUserGesture: () => void
144
+ // 手势不再控制路由
145
+ stopUserGesture: () => void
146
+ // 返回上一级,效果同 wx.navigateBack
147
+ didPop: () => void
148
+ }
149
+
150
+ interface CustomRouteConfig {
151
+ // 下一个页面推入后,不显示前一个页面
152
+ opaque?: boolean
153
+ // 是否保持前一个页面状态
154
+ maintainState?: boolean
155
+ // 页面推入动画时长,单位 ms
156
+ transitionDuration?: number
157
+ // 页面推出动画时长,单位 ms
158
+ reverseTransitionDuration?: number
159
+ // 遮罩层背景色,支持 rgba() 和 #RRGGBBAA 写法
160
+ barrierColor?: string
161
+ // 点击遮罩层返回上一页
162
+ barrierDismissible?: boolean
163
+ // 无障碍语义
164
+ barrierLabel?: string
165
+ // 是否与下一个页面联动,决定当前页 secondaryAnimation 是否生效
166
+ canTransitionTo?: boolean
167
+ // 是否与前一个页面联动,决定前一个页 secondaryAnimation 是否生效
168
+ canTransitionFrom?: boolean
169
+ // 处理当前页的进入/退出动画,返回 StyleObject
170
+ handlePrimaryAnimation?: RouteAnimationHandler
171
+ // 处理当前页的压入/压出动画,返回 StyleObject
172
+ handleSecondaryAnimation?: RouteAnimationHandler
173
+ // 处理上一级页面的压入/压出动画,返回 StyleObject 基础库 <3.0.0> 起支持
174
+ handlePreviousPageAnimation?: RouteAnimationHandler
175
+ // 页面进入时是否采用 snapshot 模式优化动画性能 基础库 <3.2.0> 起支持
176
+ allowEnterRouteSnapshotting?: boolean
177
+ // 页面退出时是否采用 snapshot 模式优化动画性能 基础库 <3.2.0> 起支持
178
+ allowExitRouteSnapshotting?: boolean
179
+ // 右滑返回时,可拖动范围是否撑满屏幕,基础库 <3.2.0> 起支持,常用于半屏弹窗
180
+ fullscreenDrag?: boolean
181
+ // 返回手势方向 基础库 <3.4.0> 起支持
182
+ popGestureDirection?: 'horizontal' | 'vertical' | 'multi'
183
+ }
184
+
185
+ type RouteAnimationHandler = () => { [key: string] : any}
186
+
187
+ /** 自定义路由
188
+ * @supported weapp
189
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/router/wx.router.html
190
+ */
191
+ interface router {
192
+ /** 添加自定义路由配置
193
+ * @supported weapp
194
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/router/base/router.addRouteBuilder.html
195
+ */
196
+ addRouteBuilder(
197
+ /** 路由类型 */
198
+ routeType: string,
199
+ /** 路由动画定义函数 */
200
+ routeBuilder: CustomRouteBuilder
201
+ ): void
202
+ /** 获取页面对应的自定义路由上下文对象
203
+ * @supported weapp
204
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/router/base/router.getRouteContext.html
205
+ */
206
+ getRouteContext(
207
+ /** 页面/自定义组件实例 */
208
+ instance: TaroGeneral.IAnyObject
209
+ ): CustomRouteContext
210
+ /** 移除自定义路由配置
211
+ * @supported weapp
212
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/router/base/router.removeRouteBuilder.html
213
+ */
214
+ removeRouteBuilder(
215
+ /** 路由类型 */
216
+ routeType: string,
217
+ ): void
218
+ }
219
+ }
220
+
221
+ interface TaroStatic {
222
+ /** 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面
223
+ * @supported weapp, h5, rn, tt, harmony_hybrid
224
+ * @example
225
+ * ```json
226
+ * {
227
+ * "tabBar": {
228
+ * "list": [{
229
+ * "pagePath": "index",
230
+ * "text": "首页"
231
+ * },{
232
+ * "pagePath": "other",
233
+ * "text": "其他"
234
+ * }]
235
+ * }
236
+ * }
237
+ * ```
238
+ *
239
+ * ```tsx
240
+ * Taro.switchTab({
241
+ * url: '/index'
242
+ * })
243
+ * ```
244
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.switchTab.html
245
+ */
246
+ switchTab(option: switchTab.Option): Promise<TaroGeneral.CallbackResult>
247
+
248
+ /** 关闭所有页面,打开到应用内的某个页面
249
+ * @supported weapp, h5, rn, tt, harmony, harmony_hybrid
250
+ * @example
251
+ * ```tsx
252
+ * Taro.reLaunch({
253
+ * url: 'test?id=1'
254
+ * })
255
+ * ```
256
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.reLaunch.html
257
+ */
258
+ reLaunch(option: reLaunch.Option): Promise<TaroGeneral.CallbackResult>
259
+
260
+ /** 关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。
261
+ * @supported weapp, h5, rn, tt, harmony, harmony_hybrid
262
+ * @h5 未针对 tabbar 页面做限制处理
263
+ * @example
264
+ * ```tsx
265
+ * Taro.redirectTo({
266
+ * url: 'test?id=1'
267
+ * })
268
+ * ```
269
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.redirectTo.html
270
+ */
271
+ redirectTo(option: redirectTo.Option): Promise<TaroGeneral.CallbackResult>
272
+
273
+ /** 保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 Taro.navigateBack 可以返回到原页面。小程序中页面栈最多十层。
274
+ * @supported weapp, h5, rn, tt, harmony, harmony_hybrid
275
+ * @h5 未针对 tabbar 页面做限制处理
276
+ * @example
277
+ * ```tsx
278
+ * Taro.navigateTo({
279
+ * url: 'test?id=1',
280
+ * events: {
281
+ * // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
282
+ * acceptDataFromOpenedPage: function(data) {
283
+ * console.log(data)
284
+ * },
285
+ * someEvent: function(data) {
286
+ * console.log(data)
287
+ * }
288
+ * ...
289
+ * },
290
+ * success: function (res) {
291
+ * // 通过eventChannel向被打开页面传送数据
292
+ * res.eventChannel.emit('acceptDataFromOpenerPage', { data: 'test' })
293
+ * }
294
+ * })
295
+ * ```
296
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html
297
+ */
298
+ navigateTo(option: navigateTo.Option): Promise<TaroGeneral.CallbackResult>
299
+
300
+ /** 关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages 获取当前的页面栈,决定需要返回几层。
301
+ * @supported weapp, h5, rn, tt, harmony, harmony_hybrid
302
+ * @h5 若入参 delta 大于现有页面数时,返回应用打开的第一个页面(如果想要返回首页请使用 reLaunch 方法)。
303
+ * @example
304
+ * ```tsx
305
+ * // 注意:调用 navigateTo 跳转时,调用该方法的页面会被加入堆栈,而 redirectTo 方法则不会。见下方示例代码
306
+ * // 此处是A页面
307
+ * Taro.navigateTo({
308
+ * url: 'B?id=1'
309
+ * })
310
+ * // 此处是B页面
311
+ * Taro.navigateTo({
312
+ * url: 'C?id=1'
313
+ * })
314
+ * // 在C页面内 navigateBack,将返回A页面
315
+ * Taro.navigateBack({
316
+ * delta: 2
317
+ * })
318
+ * ```
319
+ * @see https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateBack.html
320
+ */
321
+ navigateBack(option?: navigateBack.Option): Promise<TaroGeneral.CallbackResult>
322
+ router: router.router
323
+ }
324
+ }