@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.
- package/README.md +12 -0
- package/dist/index.js +147 -0
- package/dist/index.js.map +1 -0
- package/index.js +9 -0
- package/package.json +86 -0
- package/types/api/ad/index.d.ts +197 -0
- package/types/api/ai/face.d.ts +133 -0
- package/types/api/ai/inference.d.ts +129 -0
- package/types/api/ai/visionkit.d.ts +874 -0
- package/types/api/alipay/index.d.ts +69 -0
- package/types/api/base/crypto.d.ts +104 -0
- package/types/api/base/debug.d.ts +329 -0
- package/types/api/base/env.d.ts +19 -0
- package/types/api/base/index.d.ts +102 -0
- package/types/api/base/performance.d.ts +258 -0
- package/types/api/base/system.d.ts +742 -0
- package/types/api/base/update.d.ts +130 -0
- package/types/api/base/weapp/app-event.d.ts +265 -0
- package/types/api/base/weapp/life-cycle.d.ts +155 -0
- package/types/api/canvas/index.d.ts +2162 -0
- package/types/api/cloud/index.d.ts +2622 -0
- package/types/api/data-analysis/index.d.ts +122 -0
- package/types/api/device/accelerometer.d.ts +102 -0
- package/types/api/device/accessibility.d.ts +26 -0
- package/types/api/device/battery.d.ts +46 -0
- package/types/api/device/bluetooth-ble.d.ts +601 -0
- package/types/api/device/bluetooth-peripheral.d.ts +430 -0
- package/types/api/device/bluetooth.d.ts +463 -0
- package/types/api/device/calendar.d.ts +98 -0
- package/types/api/device/clipboard.d.ts +81 -0
- package/types/api/device/compass.d.ts +105 -0
- package/types/api/device/contact.d.ts +110 -0
- package/types/api/device/gyroscope.d.ts +85 -0
- package/types/api/device/iBeacon.d.ts +168 -0
- package/types/api/device/keyboard.d.ts +97 -0
- package/types/api/device/memory.d.ts +52 -0
- package/types/api/device/motion.d.ts +88 -0
- package/types/api/device/network.d.ts +172 -0
- package/types/api/device/nfc.d.ts +1238 -0
- package/types/api/device/phone.d.ts +30 -0
- package/types/api/device/scan.d.ts +111 -0
- package/types/api/device/screen.d.ts +217 -0
- package/types/api/device/sms.d.ts +26 -0
- package/types/api/device/vibrate.d.ts +51 -0
- package/types/api/device/wifi.d.ts +301 -0
- package/types/api/ext/index.d.ts +64 -0
- package/types/api/files/index.d.ts +1472 -0
- package/types/api/framework/index.d.ts +51 -0
- package/types/api/location/index.d.ts +517 -0
- package/types/api/media/audio.d.ts +1013 -0
- package/types/api/media/background-audio.d.ts +291 -0
- package/types/api/media/camera.d.ts +207 -0
- package/types/api/media/editor.d.ts +239 -0
- package/types/api/media/image.d.ts +469 -0
- package/types/api/media/live.d.ts +461 -0
- package/types/api/media/map.d.ts +638 -0
- package/types/api/media/media-recorder.d.ts +117 -0
- package/types/api/media/recorder.d.ts +317 -0
- package/types/api/media/video-decoder.d.ts +117 -0
- package/types/api/media/video-processing.d.ts +84 -0
- package/types/api/media/video.d.ts +527 -0
- package/types/api/media/voip.d.ts +393 -0
- package/types/api/navigate/index.d.ts +327 -0
- package/types/api/network/download.d.ts +173 -0
- package/types/api/network/mdns.d.ts +191 -0
- package/types/api/network/request.d.ts +480 -0
- package/types/api/network/tcp.d.ts +181 -0
- package/types/api/network/udp.d.ts +218 -0
- package/types/api/network/upload.d.ts +201 -0
- package/types/api/network/websocket.d.ts +383 -0
- package/types/api/open-api/account.d.ts +51 -0
- package/types/api/open-api/address.d.ts +68 -0
- package/types/api/open-api/authorize.d.ts +80 -0
- package/types/api/open-api/card.d.ts +110 -0
- package/types/api/open-api/channels.d.ts +225 -0
- package/types/api/open-api/customer-service.d.ts +45 -0
- package/types/api/open-api/device-voip.d.ts +103 -0
- package/types/api/open-api/facial.d.ts +98 -0
- package/types/api/open-api/favorites.d.ts +101 -0
- package/types/api/open-api/group.d.ts +59 -0
- package/types/api/open-api/invoice.d.ts +87 -0
- package/types/api/open-api/license-plate.d.ts +27 -0
- package/types/api/open-api/login.d.ts +115 -0
- package/types/api/open-api/my-miniprogram.d.ts +28 -0
- package/types/api/open-api/privacy.d.ts +107 -0
- package/types/api/open-api/redpackage.d.ts +24 -0
- package/types/api/open-api/settings.d.ts +174 -0
- package/types/api/open-api/soter.d.ts +184 -0
- package/types/api/open-api/sticker.d.ts +83 -0
- package/types/api/open-api/subscribe-message.d.ts +305 -0
- package/types/api/open-api/user-info.d.ts +182 -0
- package/types/api/open-api/werun.d.ts +101 -0
- package/types/api/payment/index.d.ts +119 -0
- package/types/api/qq/index.d.ts +354 -0
- package/types/api/route/index.d.ts +324 -0
- package/types/api/share/index.d.ts +354 -0
- package/types/api/skyline/index.d.ts +345 -0
- package/types/api/storage/background-fetch.d.ts +131 -0
- package/types/api/storage/cache-manager.d.ts +249 -0
- package/types/api/storage/index.d.ts +405 -0
- package/types/api/swan/bookshelf.d.ts +307 -0
- package/types/api/swan/download-package.d.ts +80 -0
- package/types/api/swan/index.d.ts +251 -0
- package/types/api/swan/pay.d.ts +139 -0
- package/types/api/taro.extend.d.ts +233 -0
- package/types/api/taro.hooks.d.ts +148 -0
- package/types/api/ui/animation.d.ts +427 -0
- package/types/api/ui/background.d.ts +69 -0
- package/types/api/ui/custom-component.d.ts +23 -0
- package/types/api/ui/fonts.d.ts +77 -0
- package/types/api/ui/interaction.d.ts +281 -0
- package/types/api/ui/menu.d.ts +29 -0
- package/types/api/ui/navigation-bar.d.ts +130 -0
- package/types/api/ui/pull-down-refresh.d.ts +50 -0
- package/types/api/ui/scroll.d.ts +114 -0
- package/types/api/ui/sticky.d.ts +32 -0
- package/types/api/ui/tab-bar.d.ts +196 -0
- package/types/api/ui/window.d.ts +71 -0
- package/types/api/worker/index.d.ts +83 -0
- package/types/api/wxml/index.d.ts +540 -0
- package/types/compile/compiler.d.ts +32 -0
- package/types/compile/config/h5.d.ts +134 -0
- package/types/compile/config/harmony.d.ts +118 -0
- package/types/compile/config/index.d.ts +8 -0
- package/types/compile/config/manifest.d.ts +155 -0
- package/types/compile/config/mini.d.ts +118 -0
- package/types/compile/config/plugin.d.ts +34 -0
- package/types/compile/config/project.d.ts +338 -0
- package/types/compile/config/rn.d.ts +85 -0
- package/types/compile/config/util.d.ts +179 -0
- package/types/compile/hooks.d.ts +13 -0
- package/types/compile/index.d.ts +11 -0
- package/types/compile/viteCompilerContext.d.ts +167 -0
- package/types/global.d.ts +428 -0
- package/types/index.d.ts +190 -0
- package/types/taro.api.d.ts +130 -0
- package/types/taro.component.d.ts +168 -0
- package/types/taro.config.d.ts +712 -0
- package/types/taro.lifecycle.d.ts +220 -0
- package/types/taro.runtime.d.ts +9 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Interface } from 'node:readline'
|
|
2
|
+
import Taro from '../../index'
|
|
3
|
+
|
|
4
|
+
declare module '../../index' {
|
|
5
|
+
|
|
6
|
+
namespace requestPolymerPayment {
|
|
7
|
+
interface Option {
|
|
8
|
+
/** 订单信息 */
|
|
9
|
+
orderInfo: OrderInfo
|
|
10
|
+
/** 接口调用成功的回调函数 */
|
|
11
|
+
success?: (res: TaroGeneral.CallbackResult) => any
|
|
12
|
+
/** 接口调用失败的回调函数 */
|
|
13
|
+
fail?: (err: FailCallbackResult) => any
|
|
14
|
+
/** 接口调用结束的回调函数(调用成功、失败都会执行) */
|
|
15
|
+
complete?: (res: TaroGeneral.CallbackResult) => any
|
|
16
|
+
}
|
|
17
|
+
interface OrderInfo {
|
|
18
|
+
/** 跳转百度收银台支付必带参数之一,是百度收银台的财务结算凭证,与账号绑定的结算协议一一对应,每笔交易将结算到 dealId 对应的协议主体。
|
|
19
|
+
* 详见[核心参数获取与组装](https://smartprogram.baidu.com/docs/develop/function/parameter/)。
|
|
20
|
+
*/
|
|
21
|
+
dealId: string
|
|
22
|
+
/** 支付能力开通后分配的支付 appKey,用以表示应用身份的唯一 ID ,在应用审核通过后进行分配,一经分配后不会发生更改,来唯一确定一个应用。
|
|
23
|
+
* 详见[核心参数获取与组装](https://smartprogram.baidu.com/docs/develop/function/parameter/)。
|
|
24
|
+
*/
|
|
25
|
+
appKey: string
|
|
26
|
+
/** 订单金额(单位:人民币分)。注:小程序测试包测试金额不可超过 1000 分 */
|
|
27
|
+
totalAmount: string
|
|
28
|
+
/** 小程序开发者系统创建的唯一订单 ID ,当支付状态发生变化时,会通过此订单 ID 通知开发者。 */
|
|
29
|
+
tpOrderId: string
|
|
30
|
+
/** 通知开发者支付状态的回调地址,必须是合法的 URL ,与开发者平台填写的支付回调地址作用一致,未填写的以平台回调地址为准 */
|
|
31
|
+
notifyUrl?: string
|
|
32
|
+
/** 订单的名称。 */
|
|
33
|
+
dealTitle: string
|
|
34
|
+
/** 用于区分验签字段范围,signFieldsRange 的值:0:原验签字段 appKey+dealId+tpOrderId;1:包含 totalAmount 的验签,验签字段包括appKey+dealId+tpOrderId+totalAmount。固定值为 1 。 */
|
|
35
|
+
signFieldsRange: string
|
|
36
|
+
/** 对appKey+dealId+totalAmount+tpOrderId进行 RSA 加密后的签名,防止订单被伪造。
|
|
37
|
+
* 签名过程见[签名与验签](https://smartprogram.baidu.com/docs/develop/function/sign_v2/)。
|
|
38
|
+
*/
|
|
39
|
+
rsaSign: string
|
|
40
|
+
/** 订单详细信息,需要是一个可解析为 JSON Object 的字符串。
|
|
41
|
+
* 字段内容见: [bizInfo 组装](https://smartprogram.baidu.com/docs/develop/function/parameter/#%E9%80%9A%E7%94%A8%E5%8F%82%E6%95%B0%E7%BB%84%E8%A3%85)。
|
|
42
|
+
*/
|
|
43
|
+
bizInfo?: string
|
|
44
|
+
/** 当前页面 path。Web 态小程序支付成功后跳回的页面路径,例如:'/pages/payResult/payResult' */
|
|
45
|
+
payResultUrl?: string
|
|
46
|
+
/**
|
|
47
|
+
* 内嵌支付组件返回的支付信息加密 key,与[内嵌支付组件](https://smartprogram.baidu.com/docs/develop/component/inline_payment_panel)配套使用,此值不传或者传空时默认调起支付面板。
|
|
48
|
+
*/
|
|
49
|
+
inlinePaySign?: string
|
|
50
|
+
/** 平台营销信息,此处传可使用平台券的 spuid,支持通过英文逗号分割传入多个 spuid 值,仅与百度合作平台类目券的开发者需要填写 */
|
|
51
|
+
promotionTag?: string
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface FailCallbackResult extends TaroGeneral.CallbackResult {
|
|
55
|
+
/** 错误码 */
|
|
56
|
+
errCode: number
|
|
57
|
+
/** 详细错误信息。
|
|
58
|
+
* 注: 目前仅在内嵌支付组件调起 swan.requestPolymerPayment 时,选择数字人民币 APP 渠道支付且用户未下载数字人民币 APP 时,返回具体错误信息 data。
|
|
59
|
+
*/
|
|
60
|
+
data: DetailFailData
|
|
61
|
+
}
|
|
62
|
+
interface DetailFailData {
|
|
63
|
+
/** 详细错误码。20014 表示【未下载数字人民币 APP】 */
|
|
64
|
+
subErrCode: number
|
|
65
|
+
/** 详细错误信息 */
|
|
66
|
+
subErrMsg: string
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
namespace getOptimalPriceInfo {
|
|
71
|
+
interface Option {
|
|
72
|
+
/** 商品信息 */
|
|
73
|
+
productsInfo: ProductInfo[]
|
|
74
|
+
/** 接口调用成功的回调函数 */
|
|
75
|
+
success?: (res: SuccessCallbackResult) => any
|
|
76
|
+
/** 接口调用失败的回调函数 */
|
|
77
|
+
fail?: (err: TaroGeneral.CallbackResult) => any
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
interface ProductInfo {
|
|
81
|
+
/** 支付的 appKey */
|
|
82
|
+
appKey: string
|
|
83
|
+
/** 商品信息 */
|
|
84
|
+
products: Product[]
|
|
85
|
+
}
|
|
86
|
+
interface Product {
|
|
87
|
+
/** 商品单价(原价) */
|
|
88
|
+
amount: number
|
|
89
|
+
/** 商品标识 */
|
|
90
|
+
promotionTag?: string
|
|
91
|
+
/** 开发者自定义商品 ID,在success回调中,会与减免信息一起返回。*/
|
|
92
|
+
productId: string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface SuccessCallbackResult extends TaroGeneral.CallbackResult {
|
|
96
|
+
/** 商品信息 */
|
|
97
|
+
productsInfo: ProductInfoSuccess[]
|
|
98
|
+
}
|
|
99
|
+
interface ProductInfoSuccess {
|
|
100
|
+
/** 支付的 appKey */
|
|
101
|
+
appKey: string
|
|
102
|
+
/** 减免后的商品信息 */
|
|
103
|
+
products: ProductSuccess[]
|
|
104
|
+
}
|
|
105
|
+
interface ProductSuccess {
|
|
106
|
+
/** 商品单价(原价) */
|
|
107
|
+
amount: number
|
|
108
|
+
/** 开发者自定义商品 ID */
|
|
109
|
+
productId: string
|
|
110
|
+
/** 商品标识 */
|
|
111
|
+
promotionTag: string
|
|
112
|
+
/** 百度平台券减免金额 */
|
|
113
|
+
reduceAmount: number
|
|
114
|
+
/** 百度平台券减免后金额 */
|
|
115
|
+
afterPayAmount: number
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
interface TaroStatic {
|
|
120
|
+
/**
|
|
121
|
+
* 1)百度收银台,聚合了主流的百度钱包、微信、支付宝、网银等多种支付渠道,方便开发者一站式快速接入多种支付渠道,让百度用户能在智能小程序场景下,直接完成支付、交易闭环,提升用户支付体验的同时,提高智能小程序的订单转化率。
|
|
122
|
+
* 2)上述支付渠道在 C 端收银台有两种展示方式,开发者可以选择其中一种实现。
|
|
123
|
+
* 方式一:将支付渠道内嵌在小程序提单页面中,实现方式参考文档[inline-payment-panel内嵌支付组件](https://smartprogram.baidu.com/docs/develop/component/inline_payment_panel/)。
|
|
124
|
+
* 方式二:在用户确认订单后,调起收银台半屏面板承载支付渠道,实现方式参考文档调起[百度收银台](https://smartprogram.baidu.com/docs/develop/function/tune_up_2.0/#%E7%99%BE%E5%BA%A6%E6%94%B6%E9%93%B6%E5%8F%B0%E6%8E%A5%E5%8F%A32-0-%E8%AF%B4%E6%98%8E)。
|
|
125
|
+
*
|
|
126
|
+
* Web 态说明:为了保证用户交易行为全流程闭环体验,在 Web 态下调用该方法会做打开百度 App 对应小程序页面的降级处理。
|
|
127
|
+
* @supported swan
|
|
128
|
+
* @see https://smartprogram.baidu.com/docs/develop/api/open/payment_swan-requestPolymerPayment/
|
|
129
|
+
*/
|
|
130
|
+
requestPolymerPayment(option: requestPolymerPayment.Option): void
|
|
131
|
+
/** 获取商品使用百度平台券后的价格
|
|
132
|
+
* 通过百度收银台支付的商品,用户在支付时可以享受百度平台券提供的优惠。
|
|
133
|
+
* 使用 API swan.getOptimalPriceInfo 可以提前获知用户在支付时享受的优惠价格。(当用户有多张平台券时,按照平台最优优惠价格计算,与支付时默认选中的优惠券对应的优惠一致)
|
|
134
|
+
* @supported swan
|
|
135
|
+
* @see https://smartprogram.baidu.com/docs/develop/api/open/payment_swan-getOptimalPriceInfo/
|
|
136
|
+
*/
|
|
137
|
+
getOptimalPriceInfo(option: getOptimalPriceInfo.Option): void
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
|
|
3
|
+
import Taro from '../index'
|
|
4
|
+
|
|
5
|
+
declare module '../index' {
|
|
6
|
+
namespace getAppInfo {
|
|
7
|
+
/** 应用信息 */
|
|
8
|
+
interface AppInfo {
|
|
9
|
+
platform: string
|
|
10
|
+
taroVersion: string
|
|
11
|
+
designWidth: number | ((size?: string | number) => number)
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
namespace getCurrentInstance {
|
|
16
|
+
interface Current {
|
|
17
|
+
app: AppInstance | null
|
|
18
|
+
router: RouterInfo | null
|
|
19
|
+
page: PageInstance | null
|
|
20
|
+
onReady: string
|
|
21
|
+
onHide: string
|
|
22
|
+
onShow: string
|
|
23
|
+
preloadData?: Record<any, any>
|
|
24
|
+
/**
|
|
25
|
+
* RN 私有对象 navigationRef,用于使用底层接口控制路由
|
|
26
|
+
*/
|
|
27
|
+
rnNavigationRef?: React.RefObject<any>
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
namespace setGlobalDataPlugin {
|
|
32
|
+
/** Vue3 插件,用于设置 `getApp()` 中的全局变量 */
|
|
33
|
+
interface Plugin {
|
|
34
|
+
install(app: any, data: any): void
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** @ignore */
|
|
39
|
+
interface TARO_ENV_TYPE {
|
|
40
|
+
[TaroGeneral.ENV_TYPE.WEAPP]: TaroGeneral.ENV_TYPE.WEAPP
|
|
41
|
+
[TaroGeneral.ENV_TYPE.SWAN]: TaroGeneral.ENV_TYPE.SWAN
|
|
42
|
+
[TaroGeneral.ENV_TYPE.ALIPAY]: TaroGeneral.ENV_TYPE.ALIPAY
|
|
43
|
+
[TaroGeneral.ENV_TYPE.TT]: TaroGeneral.ENV_TYPE.TT
|
|
44
|
+
[TaroGeneral.ENV_TYPE.QQ]: TaroGeneral.ENV_TYPE.QQ
|
|
45
|
+
[TaroGeneral.ENV_TYPE.JD]: TaroGeneral.ENV_TYPE.JD
|
|
46
|
+
[TaroGeneral.ENV_TYPE.WEB]: TaroGeneral.ENV_TYPE.WEB
|
|
47
|
+
[TaroGeneral.ENV_TYPE.RN]: TaroGeneral.ENV_TYPE.RN
|
|
48
|
+
[TaroGeneral.ENV_TYPE.HARMONY]: TaroGeneral.ENV_TYPE.HARMONY
|
|
49
|
+
[TaroGeneral.ENV_TYPE.QUICKAPP]: TaroGeneral.ENV_TYPE.QUICKAPP
|
|
50
|
+
[TaroGeneral.ENV_TYPE.HARMONYHYBRID]: TaroGeneral.ENV_TYPE.HARMONYHYBRID
|
|
51
|
+
[TaroGeneral.ENV_TYPE.ASCF]: TaroGeneral.ENV_TYPE.ASCF
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
namespace interceptorify {
|
|
55
|
+
type promisifyApi<T, R> = (requestParams: T) => Promise<R>
|
|
56
|
+
interface InterceptorifyChain<T, R> {
|
|
57
|
+
requestParams: T
|
|
58
|
+
proceed: promisifyApi<T, R>
|
|
59
|
+
}
|
|
60
|
+
type InterceptorifyInterceptor<T, R> = (chain: InterceptorifyChain<T, R>) => Promise<R>
|
|
61
|
+
interface Interceptorify<T, R> {
|
|
62
|
+
request(requestParams: T): Promise<R>
|
|
63
|
+
addInterceptor(interceptor: InterceptorifyInterceptor<T, R>): void
|
|
64
|
+
cleanInterceptors(): void
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
interface TaroStatic {
|
|
69
|
+
/** @ignore */
|
|
70
|
+
Events: {
|
|
71
|
+
new (): TaroGeneral.Events
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** 事件中心
|
|
75
|
+
* @supported global
|
|
76
|
+
*/
|
|
77
|
+
eventCenter: TaroGeneral.Events
|
|
78
|
+
|
|
79
|
+
/** @ignore */
|
|
80
|
+
ENV_TYPE: TARO_ENV_TYPE
|
|
81
|
+
|
|
82
|
+
/** 获取环境变量
|
|
83
|
+
* @supported global
|
|
84
|
+
*/
|
|
85
|
+
getEnv(): TaroGeneral.ENV_TYPE
|
|
86
|
+
|
|
87
|
+
/** 尺寸转换
|
|
88
|
+
* @supported global
|
|
89
|
+
*/
|
|
90
|
+
pxTransform(size: number): string
|
|
91
|
+
|
|
92
|
+
/** 尺寸转换初始化
|
|
93
|
+
* @supported global
|
|
94
|
+
*/
|
|
95
|
+
initPxTransform(config: {
|
|
96
|
+
baseFontSize?: number
|
|
97
|
+
deviceRatio?: TaroGeneral.TDeviceRatio
|
|
98
|
+
designWidth?: number | ((size?: string | number) => number)
|
|
99
|
+
targetUnit?: string
|
|
100
|
+
unitPrecision?: number
|
|
101
|
+
}): void
|
|
102
|
+
|
|
103
|
+
/** 小程序获取和 Taro 相关的 App 信息
|
|
104
|
+
* @supported weapp, alipay, jd, qq, swan, tt, h5, harmony, harmony_hybrid
|
|
105
|
+
*/
|
|
106
|
+
getAppInfo(): getAppInfo.AppInfo
|
|
107
|
+
|
|
108
|
+
getEnvInfoSync(): {
|
|
109
|
+
/** 小程序信息 */
|
|
110
|
+
microapp: {
|
|
111
|
+
/** 小程序版本号 */
|
|
112
|
+
mpVersion: string
|
|
113
|
+
/** 小程序环境 */
|
|
114
|
+
envType: string
|
|
115
|
+
/** 小程序 appId */
|
|
116
|
+
appId: string
|
|
117
|
+
}
|
|
118
|
+
/** 插件信息 */
|
|
119
|
+
plugin: Record<string, unknown>
|
|
120
|
+
/** 通用参数 */
|
|
121
|
+
common: {
|
|
122
|
+
/** 用户数据存储的路径 */
|
|
123
|
+
USER_DATA_PATH: string
|
|
124
|
+
/** 校验白名单属性中的 appInfoLaunchFrom 后返回额外信息 */
|
|
125
|
+
location: string | undefined
|
|
126
|
+
launchFrom: string | undefined
|
|
127
|
+
schema: string | undefined
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** 小程序引用插件 JS 接口
|
|
132
|
+
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp
|
|
133
|
+
*/
|
|
134
|
+
requirePlugin: {
|
|
135
|
+
(pluginName: string): any
|
|
136
|
+
/** @supported weapp */
|
|
137
|
+
(pluginName: string, success?: (mod: any) => any, error?: (e: { mod: any; errMsg: string }) => any): any;
|
|
138
|
+
/** @supported weapp */
|
|
139
|
+
async?: (pluginName: string) => Promise<any>
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** 获取当前页面实例
|
|
143
|
+
* @supported global
|
|
144
|
+
*/
|
|
145
|
+
getCurrentInstance(): getCurrentInstance.Current
|
|
146
|
+
|
|
147
|
+
/** @ignore */
|
|
148
|
+
Current: getCurrentInstance.Current
|
|
149
|
+
|
|
150
|
+
/** Vue3 插件,用于设置 `getApp()` 中的全局变量
|
|
151
|
+
* @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp, harmony_hybrid
|
|
152
|
+
* @example
|
|
153
|
+
* ```js
|
|
154
|
+
* // 使用插件
|
|
155
|
+
* const App = createApp(...)
|
|
156
|
+
* App.use(setGlobalDataPlugin, {
|
|
157
|
+
* xxx: 999
|
|
158
|
+
* })
|
|
159
|
+
* // 获取全局变量
|
|
160
|
+
* Taro.getApp().xxx
|
|
161
|
+
* ```
|
|
162
|
+
*/
|
|
163
|
+
setGlobalDataPlugin: setGlobalDataPlugin.Plugin
|
|
164
|
+
|
|
165
|
+
/** 获取自定义 TabBar 对应的 React 或 Vue 组件实例
|
|
166
|
+
* @supported weapp, jd
|
|
167
|
+
* @param page 小程序页面对象,可以通过 Taro.getCurrentInstance().page 获取
|
|
168
|
+
*/
|
|
169
|
+
getTabBar<T>(page: getCurrentInstance.Current['page']): T | undefined
|
|
170
|
+
|
|
171
|
+
/** 获取当前页面渲染引擎类型
|
|
172
|
+
* @supported weapp
|
|
173
|
+
*/
|
|
174
|
+
getRenderer(): 'webview' | 'skyline'
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* 包裹 promisify api 的洋葱圈模型
|
|
178
|
+
* @supported global
|
|
179
|
+
* @param promisifyApi
|
|
180
|
+
* @example
|
|
181
|
+
* ```tsx
|
|
182
|
+
* // 创建实例
|
|
183
|
+
* const modalInterceptorify = interceptorify(taro.showModal)
|
|
184
|
+
* // 添加拦截器
|
|
185
|
+
* modalInterceptorify.addInterceptor(async function (chain) {
|
|
186
|
+
* const res = await chain.proceed({
|
|
187
|
+
* ...chain.requestParams,
|
|
188
|
+
* title: 'interceptor1'
|
|
189
|
+
* })
|
|
190
|
+
* return res
|
|
191
|
+
* })
|
|
192
|
+
* modalInterceptorify.addInterceptor(async function (chain) {
|
|
193
|
+
* const res = await chain.proceed({
|
|
194
|
+
* ...chain.requestParams,
|
|
195
|
+
* content: 'interceptor2'
|
|
196
|
+
* })
|
|
197
|
+
* return res
|
|
198
|
+
* })
|
|
199
|
+
* // 使用
|
|
200
|
+
* modalInterceptorify.request({})
|
|
201
|
+
* ```
|
|
202
|
+
* @example
|
|
203
|
+
* ```tsx
|
|
204
|
+
* // 创建实例
|
|
205
|
+
* const fetchDataInterceptorify = interceptorify(taro.request)
|
|
206
|
+
* // 添加拦截器
|
|
207
|
+
* fetchDataInterceptorify.addInterceptor(async function (chain) {
|
|
208
|
+
* taro.showLoading({
|
|
209
|
+
* title: 'Loading...'
|
|
210
|
+
* })
|
|
211
|
+
* const res = await chain.proceed(chain.requestParams)
|
|
212
|
+
* taro.hideLoading()
|
|
213
|
+
* return res
|
|
214
|
+
* })
|
|
215
|
+
* fetchDataInterceptorify.addInterceptor(async function (chain) {
|
|
216
|
+
* const params = chain.requestParams
|
|
217
|
+
* const res = await chain.proceed({
|
|
218
|
+
* url: 'http://httpbin.org' + params.url,
|
|
219
|
+
* })
|
|
220
|
+
* return res.data
|
|
221
|
+
* })
|
|
222
|
+
* // 使用
|
|
223
|
+
* fetchDataInterceptorify.request({
|
|
224
|
+
* url: '/ip'
|
|
225
|
+
* }).then((res) => {
|
|
226
|
+
* // log my ip
|
|
227
|
+
* console.log(res.origin)
|
|
228
|
+
* })
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
interceptorify<T, R>(api: interceptorify.promisifyApi<T, R>): interceptorify.Interceptorify<T, R>
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import Taro from '../index'
|
|
2
|
+
|
|
3
|
+
declare module '../index' {
|
|
4
|
+
interface TaroStatic {
|
|
5
|
+
/**
|
|
6
|
+
* 页面展示时的回调。
|
|
7
|
+
* @supported global
|
|
8
|
+
*/
|
|
9
|
+
useDidShow(callback: (options?: getLaunchOptionsSync.LaunchOptions) => void): void
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 页面隐藏时的回调。
|
|
13
|
+
* @supported global
|
|
14
|
+
*/
|
|
15
|
+
useDidHide(callback: () => void): void
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 下拉刷新时的回调。
|
|
19
|
+
* @supported global
|
|
20
|
+
*/
|
|
21
|
+
usePullDownRefresh(callback: () => void): void
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 上拉触底时的回调。
|
|
25
|
+
* @supported global
|
|
26
|
+
*/
|
|
27
|
+
useReachBottom(callback: () => void): void
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 页面滚动时的回调。
|
|
31
|
+
* @supported global
|
|
32
|
+
*/
|
|
33
|
+
usePageScroll(callback: (payload: PageScrollObject) => void): void
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* 页面尺寸改变时的回调。
|
|
37
|
+
* @supported global
|
|
38
|
+
*/
|
|
39
|
+
useResize(callback: (payload: PageResizeObject) => void): void
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* 页面转发时的回调。
|
|
43
|
+
* @supported weapp
|
|
44
|
+
*/
|
|
45
|
+
useShareAppMessage(callback: (payload: ShareAppMessageObject) => ShareAppMessageReturn): void
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 当前是 tab 页时,tab 被点击时的回调。
|
|
49
|
+
* @supported weapp, h5, rn, harmony_hybrid
|
|
50
|
+
*/
|
|
51
|
+
useTabItemTap(callback: (payload: TabItemTapObject) => void): void
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* 用户点击右上角菜单“收藏”按钮时的回调。
|
|
55
|
+
* @supported weapp
|
|
56
|
+
*/
|
|
57
|
+
useAddToFavorites(callback: (payload: AddToFavoritesObject) => AddToFavoritesReturnObject): void
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 用户点击右上角菜单“分享到朋友圈”按钮时的回调。
|
|
61
|
+
* @supported weapp
|
|
62
|
+
*/
|
|
63
|
+
useShareTimeline(callback: () => ShareTimelineReturnObject): void
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 页面销毁前保留状态回调
|
|
67
|
+
* @supported weapp
|
|
68
|
+
*/
|
|
69
|
+
useSaveExitState(callback: () => {
|
|
70
|
+
data: Record<any, any>
|
|
71
|
+
expireTimeStamp?: number
|
|
72
|
+
}): void
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 小程序初始化完成时的回调。
|
|
76
|
+
* @supported weapp, h5, harmony_hybrid
|
|
77
|
+
*/
|
|
78
|
+
useLaunch(callback: (options: getLaunchOptionsSync.LaunchOptions) => void): void
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 小程序发生脚本错误或 API 调用报错时触发的回调。
|
|
82
|
+
* @supported weapp, h5, harmony_hybrid
|
|
83
|
+
*/
|
|
84
|
+
useError(callback: (error: string) => void): void
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* 小程序有未处理的 Promise reject 时触发。也可以使用 Taro.onUnhandledRejection 绑定监听。
|
|
88
|
+
* @supported weapp, alipay, h5, harmony_hybrid
|
|
89
|
+
*/
|
|
90
|
+
useUnhandledRejection(callback: (error: { reason: Error, promise: Promise<Error> }) => void): void
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 小程序要打开的页面不存在时触发的回调。
|
|
94
|
+
* @supported weapp, h5, harmony_hybrid
|
|
95
|
+
* @h5 多页面模式不支持该方法
|
|
96
|
+
*/
|
|
97
|
+
usePageNotFound(callback: (res: { path: string, query: Record<any, any>, isEntryPage: boolean, [key: string]: any }) => void): void
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 页面加载完成时的回调。
|
|
101
|
+
* @supported weapp, h5, harmony_hybrid, harmony
|
|
102
|
+
*/
|
|
103
|
+
useLoad<T extends {} = Record<string, any>>(callback: (param: T) => void): void
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* 页面卸载时的回调。
|
|
107
|
+
* @supported weapp, h5, harmony_hybrid, harmony
|
|
108
|
+
*/
|
|
109
|
+
useUnload(callback: () => void): void
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 页面初次渲染完成的回调。
|
|
113
|
+
* 此时页面已经准备妥当,可以和视图层进行交互。
|
|
114
|
+
* @supported weapp, h5, harmony_hybrid, harmony
|
|
115
|
+
*/
|
|
116
|
+
useReady(callback: () => void): void
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* 获取当前路由参数。
|
|
120
|
+
* @supported global
|
|
121
|
+
*/
|
|
122
|
+
useRouter<TParams extends Partial<Record<string, string>> = Partial<Record<string, string>>>(dynamic?: boolean): RouterInfo<TParams>
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 导航栏的标题被点击时的回调。
|
|
126
|
+
* @supported alipay
|
|
127
|
+
*/
|
|
128
|
+
useTitleClick(callback: () => void): void
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 导航栏的额外图标被点击时的回调。
|
|
132
|
+
* @supported alipay
|
|
133
|
+
*/
|
|
134
|
+
useOptionMenuClick(callback: () => void): void
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 键盘高度变化时的回调。
|
|
138
|
+
* @supported alipay
|
|
139
|
+
*/
|
|
140
|
+
useKeyboardHeight(callback: (payload: { height: number }) => void): void
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 下拉中断时的回调。
|
|
144
|
+
* @supported alipay, h5, harmony_hybrid
|
|
145
|
+
*/
|
|
146
|
+
usePullIntercept(callback: () => void): void
|
|
147
|
+
}
|
|
148
|
+
}
|