diff --git a/docs/apis/ai/visionkit/VKBodyAnchor.md b/docs/apis/ai/visionkit/VKBodyAnchor.md new file mode 100644 index 000000000000..3d8f57a59418 --- /dev/null +++ b/docs/apis/ai/visionkit/VKBodyAnchor.md @@ -0,0 +1,66 @@ +--- +title: VKBodyAnchor +sidebar_label: VKBodyAnchor +--- + +人体 anchor + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKBodyAnchor.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| id | `number` | 唯一标识 | +| type | `5` | 类型 | +| detectId | `number` | 识别序号 | +| size | `ISize` | 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | +| origin | `IOrigin` | 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | +| confidence | `number[]` | 关键点的置信度 | +| points | `IPoint[]` | 关键点 | +| score | `number` | 总体置信值 | + +## 参数 + +### IType + +类型 + +| 参数 | 说明 | +| --- | --- | +| 5 | 人体 | + +### ISize + +相对视窗的尺寸 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| width | `number` | 宽度 | +| height | `number` | 高度 | + +### IOrigin + +相对视窗的位置信息 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 横坐标 | +| y | `number` | 纵坐标 | + +### IPoint + +关键点 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 横坐标 | +| y | `number` | 纵坐标 | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| VKBodyAnchor | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKDepthAnchor.md b/docs/apis/ai/visionkit/VKDepthAnchor.md new file mode 100644 index 000000000000..701cc8ce5678 --- /dev/null +++ b/docs/apis/ai/visionkit/VKDepthAnchor.md @@ -0,0 +1,44 @@ +--- +title: VKDepthAnchor +sidebar_label: VKDepthAnchor +--- + +depth anchor + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKDepthAnchor.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| id | `number` | 唯一标识 | +| type | `8` | 类型 | +| size | `ISize` | 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | +| depthArray | `number[]` | 包含深度信息的数组 | + +## 参数 + +### IType + +类型 + +| 参数 | 说明 | +| --- | --- | +| 8 | DEPTH | + +### ISize + +相对视窗的尺寸 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| width | `number` | 宽度 | +| height | `number` | 高度 | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| VKDepthAnchor | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKFaceAnchor.md b/docs/apis/ai/visionkit/VKFaceAnchor.md new file mode 100644 index 000000000000..09d4bc44e7c9 --- /dev/null +++ b/docs/apis/ai/visionkit/VKFaceAnchor.md @@ -0,0 +1,66 @@ +--- +title: VKFaceAnchor +sidebar_label: VKFaceAnchor +--- + +人脸 anchor + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFaceAnchor.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| id | `number` | 唯一标识 | +| type | `3` | 类型 | +| detectId | `number` | 识别序号 | +| origin | `IOrigin` | 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | +| size | `ISize` | 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | +| points | `IPoint[]` | 人脸 106 个关键点的坐标 | +| angle | `number[]` | 人脸角度信息 | +| confidence | `number` | 关键点的置信度 | + +## 参数 + +### IType + +类型 + +| 参数 | 说明 | +| --- | --- | +| 3 | 人脸 | + +### ISize + +相对视窗的尺寸 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| width | `number` | 宽度 | +| height | `number` | 高度 | + +### IOrigin + +相对视窗的位置信息 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 横坐标 | +| y | `number` | 纵坐标 | + +### IPoint + +关键点 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 横坐标 | +| y | `number` | 纵坐标 | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| VKFaceAnchor | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKFrame.md b/docs/apis/ai/visionkit/VKFrame.md index a3caa5bccbeb..d9ae075d9603 100644 --- a/docs/apis/ai/visionkit/VKFrame.md +++ b/docs/apis/ai/visionkit/VKFrame.md @@ -25,13 +25,32 @@ vision kit 会话对象 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraTexture.html) ```tsx -(ctx: WebGLRenderingContext) => getCameraTextureResult +(ctx: WebGLRenderingContext) => IGetCameraTextureResult ``` | 参数 | 类型 | | --- | --- | | ctx | `WebGLRenderingContext` | +### getCameraBuffer + +获取当前帧 rgba buffer。iOS 端微信在 v8.0.20 开始支持,安卓端微信在 v8.0.30 开始支持。 +按 aspect-fill 规则裁剪,此接口要求在创建 VKSession 对象时必须传入 gl 参数。 +此接口仅建议拿来做帧分析使用,上屏请使用 getCameraTexture 来代替。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraBuffer.html) + +```tsx +(widht: number, height: number) => ArrayBuffer +``` + +| 参数 | 类型 | +| --- | --- | +| widht | `number` | +| height | `number` | + ### getDisplayTransform 获取纹理调整矩阵。默认获取到的纹理是未经裁剪调整的纹理,此矩阵可用于在着色器中根据帧对象尺寸对纹理进行裁剪 @@ -46,7 +65,7 @@ vision kit 会话对象 ## 参数 -### getCameraTextureResult +### IGetCameraTextureResult 帧纹理对象 @@ -61,4 +80,5 @@ vision kit 会话对象 | :---: | :---: | :---: | :---: | :---: | | VKFrame | ✔️ | | | | | VKFrame.getCameraTexture | ✔️ | | | | +| VKFrame.getCameraBuffer | ✔️ | | | | | VKFrame.getDisplayTransform | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKHandAnchor.md b/docs/apis/ai/visionkit/VKHandAnchor.md new file mode 100644 index 000000000000..f19616fa19d9 --- /dev/null +++ b/docs/apis/ai/visionkit/VKHandAnchor.md @@ -0,0 +1,93 @@ +--- +title: VKHandAnchor +sidebar_label: VKHandAnchor +--- + +手势 anchor + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKHandAnchor.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| id | `number` | 唯一标识 | +| type | `7` | 类型 | +| detectId | `number` | 识别序号 | +| size | `ISize` | 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | +| origin | `IOrigin` | 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | +| confidence | `number[]` | 关键点的置信度 | +| points | `IPoint[]` | 关键点 | +| score | `number` | 总体置信值 | +| gesture | keyof IGesture or -1 | 手势分类, 返回整数 -1 到 18, -1 表示无效手势 | + +## 参数 + +### IType + +类型 + +| 参数 | 说明 | +| --- | --- | +| 7 | 手势 | + +### ISize + +相对视窗的尺寸 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| width | `number` | 宽度 | +| height | `number` | 高度 | + +### IOrigin + +相对视窗的位置信息 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 横坐标 | +| y | `number` | 纵坐标 | + +### IPoint + +关键点 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 横坐标 | +| y | `number` | 纵坐标 | + +### IGesture + +手势分类 + +| 参数 | 说明 | +| --- | --- | +| 0 | 单手比心 | +| 1 | 布(数字5) | +| 2 | 剪刀(数字2) | +| 3 | 握拳 | +| 4 | 数字1 | +| 5 | 热爱 | +| 6 | 点赞 | +| 7 | 数字3 | +| 8 | 摇滚 | +| 9 | 数字6 | +| 10 | 数字8 | +| 11 | 双手抱拳(恭喜发财) | +| 12 | 数字4 | +| 13 | 比ok | +| 14 | 不喜欢(踩) | +| 15 | 双手比心 | +| 16 | 祈祷(双手合十) | +| 17 | 双手抱拳 | +| 18 | 无手势动作 | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| VKHandAnchor | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKMarkerAnchor.md b/docs/apis/ai/visionkit/VKMarkerAnchor.md new file mode 100644 index 000000000000..dcf1a20a161e --- /dev/null +++ b/docs/apis/ai/visionkit/VKMarkerAnchor.md @@ -0,0 +1,36 @@ +--- +title: VKMarkerAnchor +sidebar_label: VKMarkerAnchor +--- + +marker anchor + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKMarkerAnchor.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| id | `number` | 唯一标识 | +| type | `1` | 类型 | +| transform | `Float32Array` | 包含位置、旋转、放缩信息的矩阵,以列为主序 | +| markerId | `number` | marker id | +| path | `string` | 图片路径 | + +## 参数 + +### IType + +类型 + +| 参数 | 说明 | +| --- | --- | +| 1 | marker | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| VKMarkerAnchor | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKOCRAnchor.md b/docs/apis/ai/visionkit/VKOCRAnchor.md new file mode 100644 index 000000000000..184694c57878 --- /dev/null +++ b/docs/apis/ai/visionkit/VKOCRAnchor.md @@ -0,0 +1,34 @@ +--- +title: VKOCRAnchor +sidebar_label: VKOCRAnchor +--- + +OCR anchor + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOCRAnchor.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| id | `number` | 唯一标识 | +| type | `6` | 类型 | +| text | `string` | 识别的文字结果 | + +## 参数 + +### IType + +类型 + +| 参数 | 说明 | +| --- | --- | +| 6 | OCR | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| VKOCRAnchor | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKOSDAnchor.md b/docs/apis/ai/visionkit/VKOSDAnchor.md new file mode 100644 index 000000000000..2262986e8d21 --- /dev/null +++ b/docs/apis/ai/visionkit/VKOSDAnchor.md @@ -0,0 +1,55 @@ +--- +title: VKOSDAnchor +sidebar_label: VKOSDAnchor +--- + +OSD anchor + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOSDAnchor.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| id | `number` | 唯一标识 | +| type | `2` | 类型 | +| markerId | `number` | marker id | +| size | `ISize` | 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | +| path | `string` | 图片路径 | +| origin | `IOrigin` | 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 | + +## 参数 + +### IType + +类型 + +| 参数 | 说明 | +| --- | --- | +| 2 | OSD | + +### ISize + +相对视窗的尺寸 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| width | `number` | 宽度 | +| height | `number` | 高度 | + +### IOrigin + +相对视窗的位置信息 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 横坐标 | +| y | `number` | 纵坐标 | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| VKOSDAnchor | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKPlaneAnchor.md b/docs/apis/ai/visionkit/VKPlaneAnchor.md new file mode 100644 index 000000000000..70fcb21498e1 --- /dev/null +++ b/docs/apis/ai/visionkit/VKPlaneAnchor.md @@ -0,0 +1,45 @@ +--- +title: VKPlaneAnchor +sidebar_label: VKPlaneAnchor +--- + +平面 anchor,只有 v2 版本支持 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKPlaneAnchor.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| id | `number` | 唯一标识 | +| type | `0` | 类型 | +| transform | `Float32Array` | 包含位置、旋转、放缩信息的矩阵,以列为主序 | +| size | `ISize` | 尺寸 | +| alignment | `number` | 方向 | + +## 参数 + +### IType + +类型 + +| 参数 | 说明 | +| --- | --- | +| 0 | 平面 | + +### ISize + +相对视窗的尺寸 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| width | `number` | 宽度 | +| height | `number` | 高度 | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| VKPlaneAnchor | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/VKSession.md b/docs/apis/ai/visionkit/VKSession.md index 64bd189974ed..e06e8549f380 100644 --- a/docs/apis/ai/visionkit/VKSession.md +++ b/docs/apis/ai/visionkit/VKSession.md @@ -13,9 +13,41 @@ vision kit 会话对象 | 参数 | 类型 | 说明 | | --- | --- | --- | -| state | `keyof State` | 会话状态 | -| config | `Config` | 会话配置 | -| cameraSize | `Size` | 相机尺寸 | +| state | `keyof IState` | 会话状态 | +| config | `IConfig` | 会话配置 | +| cameraSize | `ISize` | 相机尺寸 | + +### addMarker + +添加一个 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.addMarker.html) + +```tsx +(path: string) => number +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| path | `string` | 图片路径,目前只支持本地用户图片 | + +### addOSDMarker + +添加一个 OSD marker(one-shot detection marker),要求调 Taro.createVKSession 时传入的 track.OSD 为 true + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.addOSDMarker.html) + +```tsx +(path: string) => number +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| path | `string` | 图片路径,目前只支持本地用户图片 | ### cancelAnimationFrame @@ -45,6 +77,94 @@ vision kit 会话对象 () => void ``` +### detectBody + +静态图像人体关键点检测。当 Taro.createVKSession 参数传入 {track: {body: {mode: 2} } } 时可用。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectBody.html) + +```tsx +(option: IDetectBodyOption) => void +``` + +| 参数 | 类型 | +| --- | --- | +| option | `IDetectBodyOption` | + +### detectDepth + +深度识别。当 Taro.createVKSession 参数传入 {track: {depth: {mode: 2} } } 时可用。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectDepth.html) + +```tsx +(option: IDetectDepthOption) => void +``` + +| 参数 | 类型 | +| --- | --- | +| option | `IDetectDepthOption` | + +### detectFace + +静态图像人脸关键点检测。当 Taro.createVKSession 参数传入 {track: {face: {mode: 2} } } 时可用。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectFace.html) + +```tsx +(option: IDetectFaceOption) => void +``` + +| 参数 | 类型 | +| --- | --- | +| option | `IDetectFaceOption` | + +### detectHand + +静态图像手势关键点检测。当 Taro.createVKSession 参数传入 {track: {hand: {mode: 2} } } 时可用。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectHand.html) + +```tsx +(option: IDetectHandOption) => void +``` + +| 参数 | 类型 | +| --- | --- | +| option | `IDetectHandOption` | + +### getAllMarker + +获取所有 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getAllMarker.html) + +```tsx +() => IMarker[] +``` + +### getAllOSDMarker + +获取所有 OSD marker,要求调 Taro.createVKSession 时传入的 track.OSD 为 true + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getAllOSDMarker.html) + +```tsx +() => IOSDMarker[] +``` + ### getVKFrame 获取帧对象,每调用一次都会触发一次帧分析过程 @@ -73,7 +193,7 @@ vision kit 会话对象 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.hitTest.html) ```tsx -(x: number, y: number, reset?: boolean) => hitTestResult[] +(x: number, y: number, reset?: boolean) => IHitTestResult[] ``` | 参数 | 类型 | 说明 | @@ -91,13 +211,13 @@ vision kit 会话对象 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.off.html) ```tsx -(eventName: string, fn: Function) => void +(eventName: string, fn: TaroGeneral.EventCallback) => void ``` | 参数 | 类型 | 说明 | | --- | --- | --- | | eventName | `string` | 事件名称 | -| fn | `Function` | 事件监听函数 | +| fn | `TaroGeneral.EventCallback` | 事件监听函数 | ### on @@ -108,13 +228,45 @@ vision kit 会话对象 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.on.html) ```tsx -(eventName: string, fn: Function) => void +(eventName: string, fn: TaroGeneral.EventCallback) => void ``` | 参数 | 类型 | 说明 | | --- | --- | --- | | eventName | `string` | 事件名称 | -| fn | `Function` | 事件监听函数 | +| fn | `TaroGeneral.EventCallback` | 事件监听函数 | + +### removeMarker + +删除一个 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.removeMarker.html) + +```tsx +(markerId: number) => number +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| markerId | `number` | marker id | + +### removeOSDMarker + +删除一个 OSD marker,要求调 Taro.createVKSession 时传入的 track.OSD 为 true + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.removeOSDMarker.html) + +```tsx +(markerId: number) => number +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| markerId | `number` | marker id | ### requestAnimationFrame @@ -125,12 +277,28 @@ vision kit 会话对象 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.requestAnimationFrame.html) ```tsx -(callback: Function) => number +(callback: TaroGeneral.TFunc) => number ``` | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `Function` | 执行函数 | +| callback | `TaroGeneral.TFunc` | 执行函数 | + +### runOCR + +静态图像 OCR 检测。当 Taro.createVKSession 参数传入 {track: {OCR: {mode: 2} } } 时可用。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.runOCR.html) + +```tsx +(option: IRunOCROption) => void +``` + +| 参数 | 类型 | +| --- | --- | +| option | `IRunOCROption` | ### start @@ -141,12 +309,12 @@ vision kit 会话对象 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.start.html) ```tsx -(callback: (status: keyof StartStatus) => void) => void +(callback: (status: keyof IStartStatus) => void) => void ``` | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `(status: keyof StartStatus) => void` | 开启会话回调 | +| callback | `(status: keyof IStartStatus) => void` | 开启会话回调 | ### stop @@ -160,9 +328,41 @@ vision kit 会话对象 () => void ``` +### update3DMode + +开启 3D 模式 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.update3DMode.html) + +```tsx +(open3d: boolean) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| open3d | `boolean` | 是否开启 | + +### updateOSDThreshold + +更新 OSD 识别精确度,要求调 Taro.createVKSession 时传入的 track.OSD 为 true + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.updateOSDThreshold.html) + +```tsx +(threshold: number) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| threshold | `number` | 阈值 | + ## 参数 -### State +### IState state 的合法值 @@ -171,17 +371,27 @@ state 的合法值 | 0 | 不可用 | | 1 | 运行中 | | 2 | 暂停中 | +| 3 | 初始化中 | -### Config +### IConfig 会话配置 | 参数 | 类型 | 说明 | | --- | --- | --- | -| version | `keyof version` | 不可用 | -| track | `track` | 运行中 | - -### version +| version | `keyof IVersion` | 不可用 | +| track | `ITrack` | 运行中 | +| marker | `boolean` | marker 跟踪配置,基础库(3.0.0)开始允许同时支持v2的水平面检测能力 | +| OSD | `boolean` | OSD 跟踪配置 | +| depth | `IDepth` | 深度识别配置 | +| face | `IFace` | 人脸检测配置。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。 | +| OCR | `IOCR` | OCR 检测配置。 | +| body | `IBody` | 人体检测配置。 | +| hand | `IHand` | 手势检测配置。 | +| threeDof | `boolean` | 提供基础AR功能,输出相机旋转的3个自由度的位姿,利用手机陀螺仪传感器,实现快速稳定的AR定位能力,适用于简单AR场景。 | +| gl | `WebGLRenderingContext` | 绑定的 WebGLRenderingContext 对象 | + +### IVersion vision kit 版本 @@ -190,23 +400,23 @@ vision kit 版本 | v1 | 旧版本 | | v2 | v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 | -### track +### ITrack 跟踪配置 | 参数 | 类型 | 说明 | | --- | --- | --- | -| plane | `plane` | 平面跟踪配置 | +| plane | `IPlane` | 平面跟踪配置 | -### plane +### IPlane 平面跟踪配置 | 参数 | 类型 | 说明 | | --- | --- | --- | -| mode | `keyof PlaneMode` | 平面跟踪配置模式 | +| mode | `keyof IPlaneMode` | 平面跟踪配置模式 | -### PlaneMode +### IPlaneMode 平面跟踪配置模式合法值 @@ -216,7 +426,92 @@ vision kit 版本 | 2 | 检测纵向平面,只有 v2 版本支持 | | 3 | 检测横向和纵向平面,只有 v2 版本支持 | -### Size +### IDepth + +深度识别配置 + +| 参数 | 类型 | +| --- | --- | +| mode | `keyof IDepthMode` | + +### IDepthMode + +深度识别模式 + +| 参数 | 说明 | +| --- | --- | +| 1 | 通过摄像头实时检测 | +| 2 | 静态图片检测 | + +### IFace + +人脸检测模式 + +| 参数 | 类型 | +| --- | --- | +| mode | `keyof IFaceMode` | + +### IFaceMode + +人脸检测模式 + +| 参数 | 说明 | +| --- | --- | +| 1 | 通过摄像头实时检测 | +| 2 | 静态图片检测 | + +### IOCR + +OCR 检测配置 + +| 参数 | 类型 | +| --- | --- | +| mode | `keyof IOCRMode` | + +### IOCRMode + +OCR 检测模式 + +| 参数 | 说明 | +| --- | --- | +| 1 | 通过摄像头实时检测 | +| 2 | 静态图片检测 | + +### IBody + +人体检测模式 + +| 参数 | 类型 | +| --- | --- | +| mode | `keyof IBodyMode` | + +### IBodyMode + +人体检测模式 + +| 参数 | 说明 | +| --- | --- | +| 1 | 通过摄像头实时检测 | +| 2 | 静态图片检测 | + +### IHand + +手势检测配置 + +| 参数 | 类型 | +| --- | --- | +| mode | `keyof IHandMode` | + +### IHandMode + +手势检测模式 + +| 参数 | 说明 | +| --- | --- | +| 1 | 通过摄像头实时检测 | +| 2 | 静态图片检测 | + +### ISize 相机尺寸 @@ -225,7 +520,99 @@ vision kit 版本 | width | `number` | 宽度 | | height | `number` | 高度 | -### hitTestResult +### IDetectBodyOption + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| frameBuffer | `ArrayBuffer` | 是 | 人脸图像像素点数据,每四项表示一个像素点的 RGBA | +| width | `number` | 是 | 图像宽度 | +| height | `number` | 是 | 图像高度 | +| scoreThreshold | `number` | 否 | 评分阈值。正常情况传入 0.8 即可。默认值 0.8 | +| sourceType | `keyof ISourceType` | 否 | 图像源类型。正常情况传入 1 即可。当输入的图片是来自一个连续视频的每一帧图像时,sourceType 传入 0 会得到更优的效果。默认值1 | + +### ISourceType + +图像源类型。 + +| 参数 | 说明 | +| --- | --- | +| 1 | 表示输入的图片是随机的图片 | +| 0 | 表示输入的图片是来自一个连续视频的每一帧图像 | + +### IDetectDepthOption + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| frameBuffer | `ArrayBuffer` | 人需要识别深度的图像像素点数据,每四项表示一个像素点的 RGBA | +| width | `number` | 图像宽度 | +| height | `number` | 图像高度 | + +### IDetectFaceOption + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| frameBuffer | `ArrayBuffer` | 是 | 人脸图像像素点数据,每四项表示一个像素点的 RGBA | +| width | `number` | 是 | 图像宽度 | +| height | `number` | 是 | 图像高度 | +| scoreThreshold | `number` | 否 | 评分阈值。正常情况传入 0.8 即可。默认值 0.8 | +| sourceType | `keyof ISourceType` | 否 | 图像源类型。正常情况传入 1 即可。当输入的图片是来自一个连续视频的每一帧图像时,sourceType 传入 0 会得到更优的效果。默认值1 | +| modelModel | `keyof IModelModel` | 否 | 算法模型类型。正常情况传入 1 即可。0、1、2 分别表示小、中、大模型,模型越大识别准确率越高,但资源占用也越高。建议根据用户设备性能进行选择。 | + +### IModelModel + +算法模型类型 + +| 参数 | 说明 | +| --- | --- | +| 0 | 小模型 | +| 1 | 中模型 | +| 2 | 大模型 | + +### IDetectHandOption + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| frameBuffer | `ArrayBuffer` | 是 | 人脸图像像素点数据,每四项表示一个像素点的 RGBA | +| width | `number` | 是 | 图像宽度 | +| height | `number` | 是 | 图像高度 | +| scoreThreshold | `number` | 否 | 评分阈值。正常情况传入 0.8 即可。默认值0.8 | +| algoMode | `keyof IAlgoMode` | 否 | 算法检测模式 | + +### IAlgoMode + +算法检测模式 + +| 参数 | 说明 | +| --- | --- | +| 0 | 检测模式,输出框和点 | +| 1 | 手势模式,输出框和手势分类 | +| 2 | 结合0和1模式,输出框、点、手势分类 | + +### IMarker + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| markerId | `number` | marker id | +| path | `string` | 图片路径 | + +### IOSDMarker + +OSD marker + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| markerId | `number` | marker id | +| path | `string` | 图片路径 | + +### IRunOCROption + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| frameBuffer | `ArrayBuffer` | 待识别图像的像素点数据,每四项表示一个像素点的 RGBA | +| width | `number` | 图像宽度 | +| height | `number` | 图像高度 | + +### IHitTestResult hitTest 检测结果 @@ -233,7 +620,7 @@ hitTest 检测结果 | --- | --- | --- | | transform | `Float32Array` | 包含位置、旋转、放缩信息的矩阵,以列为主序 | -### StartStatus +### IStartStatus start status 的合法值 @@ -253,12 +640,25 @@ start status 的合法值 | API | 微信小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | | VKSession | ✔️ | | | | +| VKSession.addMarker | ✔️ | | | | +| VKSession.addOSDMarker | ✔️ | | | | | VKSession.cancelAnimationFrame | ✔️ | | | | | VKSession.destroy | ✔️ | | | | +| VKSession.detectBody | ✔️ | | | | +| VKSession.detectDepth | ✔️ | | | | +| VKSession.detectFace | ✔️ | | | | +| VKSession.detectHand | ✔️ | | | | +| VKSession.getAllMarker | ✔️ | | | | +| VKSession.getAllOSDMarker | ✔️ | | | | | VKSession.getVKFrame | ✔️ | | | | | VKSession.hitTest | ✔️ | | | | | VKSession.off | ✔️ | | | | | VKSession.on | ✔️ | | | | +| VKSession.removeMarker | ✔️ | | | | +| VKSession.removeOSDMarker | ✔️ | | | | | VKSession.requestAnimationFrame | ✔️ | | | | +| VKSession.runOCR | ✔️ | | | | | VKSession.start | ✔️ | | | | | VKSession.stop | ✔️ | | | | +| VKSession.update3DMode | ✔️ | | | | +| VKSession.updateOSDThreshold | ✔️ | | | | diff --git a/docs/apis/ai/visionkit/createVKSession.md b/docs/apis/ai/visionkit/createVKSession.md index 69b52f3f267e..fa5fa1fb8c28 100644 --- a/docs/apis/ai/visionkit/createVKSession.md +++ b/docs/apis/ai/visionkit/createVKSession.md @@ -12,16 +12,16 @@ sidebar_label: createVKSession ## 类型 ```tsx -(version: keyof Version) => VKSession +(version: keyof IVersion) => VKSession ``` ## 参数 | 参数 | 类型 | | --- | --- | -| version | `keyof Version` | +| version | `keyof IVersion` | -### Version +### IVersion vision kit 版本 @@ -30,23 +30,23 @@ vision kit 版本 | v1 | 旧版本 | | v2 | v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 | -### Track +### ITrack 跟踪配置 | 参数 | 类型 | 说明 | | --- | --- | --- | -| plane | `Plane` | 平面跟踪配置 | +| plane | `IPlane` | 平面跟踪配置 | -### Plane +### IPlane 平面跟踪配置 | 参数 | 类型 | 说明 | | --- | --- | --- | -| mode | `keyof PlaneMode` | 平面跟踪配置模式 | +| mode | `keyof IPlaneMode` | 平面跟踪配置模式 | -### PlaneMode +### IPlaneMode 平面跟踪配置模式合法值 diff --git a/docs/apis/ai/visionkit/isVKSupport.md b/docs/apis/ai/visionkit/isVKSupport.md index 2a90d529133d..144da2a59213 100644 --- a/docs/apis/ai/visionkit/isVKSupport.md +++ b/docs/apis/ai/visionkit/isVKSupport.md @@ -12,16 +12,16 @@ sidebar_label: isVKSupport ## 类型 ```tsx -(version: keyof Version) => boolean +(version: keyof IVersion) => boolean ``` ## 参数 | 参数 | 类型 | | --- | --- | -| version | `keyof Version` | +| version | `keyof IVersion` | -### Version +### IVersion vision kit 版本 diff --git a/docs/apis/base/performance/Performance.md b/docs/apis/base/performance/Performance.md index 4b54dc1ff4dd..c3f4c49c33b1 100644 --- a/docs/apis/base/performance/Performance.md +++ b/docs/apis/base/performance/Performance.md @@ -20,12 +20,12 @@ Performance 对象,用于获取性能数据及创建性能监听器 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.createObserver.html) ```tsx -(callback: Function) => PerformanceObserver +(callback: TaroGeneral.TFunc) => PerformanceObserver ``` | 参数 | 类型 | | --- | --- | -| callback | `Function` | +| callback | `TaroGeneral.TFunc` | ### getEntries diff --git a/docs/apis/base/performance/preloadAssets.md b/docs/apis/base/performance/preloadAssets.md index d90380f1d75e..d5055fb15c66 100644 --- a/docs/apis/base/performance/preloadAssets.md +++ b/docs/apis/base/performance/preloadAssets.md @@ -39,7 +39,7 @@ sidebar_label: preloadAssets | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| data | `AssetsObjectType[]` | 是 | | +| data | `AssetsObject[]` | 是 | | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/canvas/Canvas.md b/docs/apis/canvas/Canvas.md index e3ca90861782..e958966800d4 100644 --- a/docs/apis/canvas/Canvas.md +++ b/docs/apis/canvas/Canvas.md @@ -18,7 +18,7 @@ Canvas 实例,可通过 SelectorQuery 获取。 取消由 requestAnimationFrame 添加到计划中的动画帧请求。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.cancelAnimationFrame.html) @@ -46,7 +46,7 @@ Canvas 实例,可通过 SelectorQuery 获取。 创建一个图片对象。 支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.createImage.html) @@ -74,7 +74,7 @@ Canvas 实例,可通过 SelectorQuery 获取。 支持获取 2D 和 WebGL 绘图上下文 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.getContext.html) @@ -119,14 +119,31 @@ Canvas 实例,可通过 SelectorQuery 获取。 | type | `string` | 图片格式,默认为 image/png | | encoderOptions | `number` | 在指定图片格式为 image/jpeg 或 image/webp的情况下,可以从 0 到 1 的区间内选择图片的质量。如果超出取值范围,将会使用默认值 0.92。其他参数会被忽略。 | +### toTempFilePath + +把当前画布指定区域保存为图片 + +支持情况: + +> [参考文档](https://opendocs.alipay.com/mini/api/toTempFilePath?pathHash=e79fe218) + +```tsx +(oprion: Option) => void +``` + +| 参数 | 类型 | +| --- | --- | +| oprion | `Option` | + ## API 支持度 -| API | 微信小程序 | H5 | React Native | Harmony | -| :---: | :---: | :---: | :---: | :---: | -| Canvas.cancelAnimationFrame | ✔️ | | | | -| Canvas.createImageData | ✔️ | | | | -| Canvas.createImage | ✔️ | | | | -| Canvas.createPath2D | ✔️ | | | | -| Canvas.getContext | ✔️ | | | | -| Canvas.requestAnimationFrame | ✔️ | | | | -| Canvas.toDataURL | ✔️ | | | | +| API | 微信小程序 | 支付宝小程序 | 抖音小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| Canvas.cancelAnimationFrame | ✔️ | ✔️ | ✔️ | | | | +| Canvas.createImageData | ✔️ | | | | | | +| Canvas.createImage | ✔️ | ✔️ | ✔️ | | | | +| Canvas.createPath2D | ✔️ | | | | | | +| Canvas.getContext | ✔️ | ✔️ | ✔️ | | | | +| Canvas.requestAnimationFrame | ✔️ | | | | | | +| Canvas.toDataURL | ✔️ | | | | | | +| Canvas.toTempFilePath | | ✔️ | | | | | diff --git a/docs/apis/canvas/CanvasContext.md b/docs/apis/canvas/CanvasContext.md index 0d674fb9f38b..f46b7188ae28 100644 --- a/docs/apis/canvas/CanvasContext.md +++ b/docs/apis/canvas/CanvasContext.md @@ -39,12 +39,12 @@ canvas 组件的绘图上下文 - 红色: 起始弧度 (0) - 蓝色: 终止弧度 (1.5 * Math.PI) -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.arc.html) ```tsx -(x: number, y: number, r: number, sAngle: number, eAngle: number, counterclockwise?: boolean) => void +(x: number, y: number, r: number, sAngle: number, eAngle: number, counterclockwise?: boolean, anticlockwise?: boolean) => void ``` | 参数 | 类型 | 说明 | @@ -55,6 +55,7 @@ canvas 组件的绘图上下文 | sAngle | `number` | 起始弧度,单位弧度(在3点钟方向) | | eAngle | `number` | 终止弧度 | | counterclockwise | `boolean` | 弧度的方向是否是逆时针 | +| anticlockwise | `boolean` | 弧度的方向是否是逆时针
API 支持度: tt | #### 示例代码 @@ -102,7 +103,7 @@ ctx.draw() 根据控制点和半径绘制圆弧路径。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.arcTo.html) @@ -125,7 +126,7 @@ ctx.draw() - 在最开始的时候相当于调用了一次 `beginPath`。 - 同一个路径内的多次 `setFillStyle`、`setStrokeStyle`、`setLineWidth`等设置,以最后一次设置为准。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.beginPath.html) @@ -164,7 +165,7 @@ ctx.draw() - 蓝色:两个控制点(20, 100) (200, 100) - 绿色:终止点(200, 20) -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.bezierCurveTo.html) @@ -224,7 +225,7 @@ ctx.draw() 清除画布上在该矩形区域内的内容 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.clearRect.html) @@ -259,7 +260,7 @@ ctx.draw() 从原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内(不能访问画布上的其他区域)。可以在使用 `clip` 方法前通过使用 `save` 方法对当前画布区域进行保存,并在以后的任意时间通过`restore`方法对其进行恢复。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.clip.html) @@ -289,7 +290,7 @@ Taro.downloadFile({ 关闭一个路径。会连接起点和终点。如果关闭路径后没有调用 `fill` 或者 `stroke` 并开启了新的路径,那之前的路径将不会被渲染。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.closePath.html) @@ -335,7 +336,7 @@ ctx.draw() 创建一个圆形的渐变颜色。起点在圆心,终点在圆环。返回的`CanvasGradient`对象需要使用 [CanvasGradient.addColorStop()](/docs/apis/canvas/CanvasGradient#addcolorstop) 来指定渐变点,至少要两个。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createCircularGradient.html) @@ -367,7 +368,7 @@ ctx.draw() 创建一个线性的渐变颜色。返回的`CanvasGradient`对象需要使用 [CanvasGradient.addColorStop()](/docs/apis/canvas/CanvasGradient#addcolorstop) 来指定渐变点,至少要两个。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createLinearGradient.html) @@ -400,7 +401,7 @@ ctx.draw() 对指定的图像创建模式的方法,可在指定的方向上重复元图像 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createPattern.html) @@ -417,20 +418,21 @@ ctx.draw() 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。 -支持情况: +支持情况: > H5: 第二次调用 draw 前需要等待上一次 draw 调用结束后再调用,否则新的一次 draw 调用栈不会清空而导致结果异常。 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.draw.html) ```tsx -(reserve?: boolean, callback?: (...args: any[]) => any) => void | Promise +(reserve?: boolean, callback?: (...args: any[]) => any, useHardwareAccelerate?: boolean) => void | Promise ``` | 参数 | 类型 | 说明 | | --- | --- | --- | | reserve | `boolean` | 本次绘制是否接着上一次绘制。即 reserve 参数为 false,则在本次调用绘制之前 native 层会先清空画布再继续绘制;若 reserve 参数为 true,则保留当前画布上的内容,本次调用 drawCanvas 绘制的内容覆盖在上面,默认 false。 | | callback | `(...args: any[]) => any` | 绘制完成后执行的回调函数 | +| useHardwareAccelerate | `boolean` | 是否使用硬件加速
API 支持度: jd | #### 示例代码 @@ -546,7 +548,7 @@ Taro.chooseImage({ 对当前路径中的内容进行填充。默认的填充色为黑色。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fill.html) @@ -596,7 +598,7 @@ ctx.draw() 填充一个矩形。用 [`setFillStyle`](/docs/apis/canvas/CanvasContext#setfillstyle) 设置矩形的填充色,如果没设置默认是黑色。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fillRect.html) @@ -624,7 +626,7 @@ ctx.draw() 在画布上绘制被填充的文本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.fillText.html) @@ -653,7 +655,7 @@ ctx.draw() 增加一个新点,然后创建一条从上次指定点到目标点的线。用 `stroke` 方法来画线条 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.lineTo.html) @@ -679,9 +681,9 @@ ctx.draw() ### measureText -测量文本尺寸信息。目前仅返回文本宽度。同步接口。 +测量文本尺寸信息。目前仅返回文本宽度(width)。同步接口。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.measureText.html) @@ -697,7 +699,7 @@ ctx.draw() 把路径移动到画布中的指定点,不创建线条。用 `stroke` 方法来画线条 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.moveTo.html) @@ -732,7 +734,7 @@ ctx.draw() - 蓝色:控制点(20, 100) - 绿色:终止点(200, 20) -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.quadraticCurveTo.html) @@ -786,7 +788,7 @@ ctx.draw() 创建一个矩形路径。需要用 [`fill`](/docs/apis/canvas/CanvasContext#fill) 或者 [`stroke`](/docs/apis/canvas/CanvasContext#stroke) 方法将矩形真正的画到 `canvas` 中 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.rect.html) @@ -811,11 +813,23 @@ ctx.fill() ctx.draw() ``` +### reset + +重置绘图上下文状态 + +支持情况: + +> [参考文档](https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/reset) + +```tsx +() => void +``` + ### restore 恢复之前保存的绘图上下文 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.restore.html) @@ -841,7 +855,7 @@ ctx.draw() 以原点为中心顺时针旋转当前坐标轴。多次调用旋转的角度会叠加。原点可以用 `translate` 方法修改。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.rotate.html) @@ -869,7 +883,7 @@ ctx.draw() 保存绘图上下文。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.save.html) @@ -895,7 +909,7 @@ ctx.draw() 在调用后,之后创建的路径其横纵坐标会被缩放。多次调用倍数会相乘。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.scale.html) @@ -924,7 +938,7 @@ ctx.draw() 设置填充色。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setFillStyle.html) @@ -949,7 +963,7 @@ ctx.draw() 设置字体的字号 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setFontSize.html) @@ -980,7 +994,7 @@ ctx.draw() 设置全局画笔透明度。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setGlobalAlpha.html) @@ -1010,7 +1024,7 @@ ctx.draw() 设置线条的端点样式 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineCap.html) @@ -1055,7 +1069,7 @@ ctx.draw() 设置虚线样式。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineDash.html) @@ -1084,7 +1098,7 @@ ctx.draw() 设置线条的交点样式 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineJoin.html) @@ -1133,7 +1147,7 @@ ctx.draw() 设置线条的宽度 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setLineWidth.html) @@ -1175,7 +1189,7 @@ ctx.draw() 设置最大斜接长度。斜接长度指的是在两条线交汇处内角和外角之间的距离。当 [CanvasContext.setLineJoin()](/docs/apis/canvas/CanvasContext#setlinejoin) 为 miter 时才有效。超过最大倾斜长度的,连接处将以 lineJoin 为 bevel 来显示。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setMiterLimit.html) @@ -1230,7 +1244,7 @@ ctx.draw() 设定阴影样式。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setShadow.html) @@ -1259,7 +1273,7 @@ ctx.draw() 设置描边颜色。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setStrokeStyle.html) @@ -1284,7 +1298,7 @@ ctx.draw() 设置文字的对齐 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTextAlign.html) @@ -1307,18 +1321,20 @@ ctx.stroke() ctx.setFontSize(15) ctx.setTextAlign('left') ctx.fillText('textAlign=left', 150, 60) +await ctx.draw(true) ctx.setTextAlign('center') ctx.fillText('textAlign=center', 150, 80) +await ctx.draw(true) ctx.setTextAlign('right') ctx.fillText('textAlign=right', 150, 100) -ctx.draw() +await ctx.draw(true) ``` ### setTextBaseline 设置文字的竖直对齐 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTextBaseline.html) @@ -1341,33 +1357,36 @@ ctx.stroke() ctx.setFontSize(20) ctx.setTextBaseline('top') ctx.fillText('top', 5, 75) +await ctx.draw(true) ctx.setTextBaseline('middle') ctx.fillText('middle', 50, 75) +await ctx.draw(true) ctx.setTextBaseline('bottom') ctx.fillText('bottom', 120, 75) +await ctx.draw(true) ctx.setTextBaseline('normal') ctx.fillText('normal', 200, 75) -ctx.draw() +await ctx.draw(true) ``` ### setTransform 使用矩阵重新设置(覆盖)当前变换的方法 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTransform.html) ```tsx -(scaleX: number, scaleY: number, skewX: number, skewY: number, translateX: number, translateY: number) => void +{ (scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number): void; (scaleX: number, skewY: number, skewX: number, scaleY: number, translateX: number, translateY: number): void; (scaleX: number, scaleY: number, skewX: number, skewY: number, translateX: number, translateY: ... ``` | 参数 | 类型 | 说明 | | --- | --- | --- | | scaleX | `number` | 水平缩放 | -| scaleY | `number` | 垂直缩放 | | skewX | `number` | 水平倾斜 | | skewY | `number` | 垂直倾斜 | +| scaleY | `number` | 垂直缩放 | | translateX | `number` | 水平移动 | | translateY | `number` | 垂直移动 | @@ -1375,7 +1394,7 @@ ctx.draw() 画出当前路径的边框。默认颜色色为黑色。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.stroke.html) @@ -1423,7 +1442,7 @@ ctx.draw() 画一个矩形(非填充)。 用 [`setStrokeStyle`](/docs/apis/canvas/CanvasContext#setstrokestyle) 设置矩形线条的颜色,如果没设置默认是黑色。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeRect.html) @@ -1451,7 +1470,7 @@ ctx.draw() 给定的 (x, y) 位置绘制文本描边的方法 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeText.html) @@ -1469,21 +1488,22 @@ ctx.draw() ### transform 使用矩阵多次叠加当前变换的方法 +使用矩阵叠加当前变换。矩阵由方法的参数进行描述,可以缩放、旋转、移动和倾斜上下文 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.transform.html) ```tsx -(scaleX: number, scaleY: number, skewX: number, skewY: number, translateX: number, translateY: number) => void +{ (scaleX: number, skewX: number, skewY: number, scaleY: number, translateX: number, translateY: number): void; (scaleX: number, skewY: number, skewX: number, scaleY: number, translateX: number, translateY: number): void; (scaleX: number, scaleY: number, skewX: number, skewY: number, translateX: number, translateY: ... ``` | 参数 | 类型 | 说明 | | --- | --- | --- | | scaleX | `number` | 水平缩放 | -| scaleY | `number` | 垂直缩放 | | skewX | `number` | 水平倾斜 | | skewY | `number` | 垂直倾斜 | +| scaleY | `number` | 垂直缩放 | | translateX | `number` | 水平移动 | | translateY | `number` | 垂直移动 | @@ -1491,7 +1511,7 @@ ctx.draw() 对当前坐标系的原点 (0, 0) 进行变换。默认的坐标系原点为页面左上角。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.translate.html) @@ -1565,54 +1585,58 @@ ctx.draw() | 参数 | 说明 | | --- | --- | -| top | 顶部对齐 | -| bottom | 底部对齐 | -| middle | 居中对齐 | -| normal | | +| top | 顶部对齐
API 支持度: weapp, alipay, swan, jd, qq, tt, h5 | +| bottom | 底部对齐
API 支持度: weapp, alipay, swan, jd, qq, tt, h5 | +| middle | 居中对齐
API 支持度: weapp, alipay, swan, jd, qq, tt, h5 | +| normal |
API 支持度: weapp, alipay, swan, jd, qq, tt, h5 | +| hanging | 文本基线为悬挂基线。
API 支持度: alipay, tt, h5 | +| alphabetic | 文本基线是标准的字母基线
API 支持度: alipay, tt, h5 | +| ideographic | 文字基线是表意字基线。如果字符本身超出了alphabetic 基线,那么ideograhpic基线位置在字符本身的底部。
API 支持度: alipay, tt, h5 | ## API 支持度 -| API | 微信小程序 | H5 | React Native | Harmony | -| :---: | :---: | :---: | :---: | :---: | -| CanvasContext.arc | ✔️ | ✔️ | | | -| CanvasContext.arcTo | ✔️ | ✔️ | | | -| CanvasContext.beginPath | ✔️ | ✔️ | | | -| CanvasContext.bezierCurveTo | ✔️ | ✔️ | | | -| CanvasContext.clearRect | ✔️ | ✔️ | | | -| CanvasContext.clip | ✔️ | ✔️ | | | -| CanvasContext.closePath | ✔️ | ✔️ | | | -| CanvasContext.createCircularGradient | ✔️ | ✔️ | | | -| CanvasContext.createLinearGradient | ✔️ | ✔️ | | | -| CanvasContext.createPattern | ✔️ | ✔️ | | | -| CanvasContext.draw | ✔️ | ✔️(第二次调用 draw 前需要等待上一次 draw 调用结束后再调用,否则新的一次 draw 调用栈不会清空而导致结果异常。) | | | -| CanvasContext.drawImage | ✔️ | ✔️ | | | -| CanvasContext.fill | ✔️ | ✔️ | | | -| CanvasContext.fillRect | ✔️ | ✔️ | | | -| CanvasContext.fillText | ✔️ | ✔️ | | | -| CanvasContext.lineTo | ✔️ | ✔️ | | | -| CanvasContext.measureText | ✔️ | ✔️ | | | -| CanvasContext.moveTo | ✔️ | ✔️ | | | -| CanvasContext.quadraticCurveTo | ✔️ | ✔️ | | | -| CanvasContext.rect | ✔️ | ✔️ | | | -| CanvasContext.restore | ✔️ | ✔️ | | | -| CanvasContext.rotate | ✔️ | ✔️ | | | -| CanvasContext.save | ✔️ | ✔️ | | | -| CanvasContext.scale | ✔️ | ✔️ | | | -| CanvasContext.setFillStyle | ✔️ | ✔️ | | | -| CanvasContext.setFontSize | ✔️ | ✔️ | | | -| CanvasContext.setGlobalAlpha | ✔️ | ✔️ | | | -| CanvasContext.setLineCap | ✔️ | ✔️ | | | -| CanvasContext.setLineDash | ✔️ | ✔️ | | | -| CanvasContext.setLineJoin | ✔️ | ✔️ | | | -| CanvasContext.setLineWidth | ✔️ | ✔️ | | | -| CanvasContext.setMiterLimit | ✔️ | ✔️ | | | -| CanvasContext.setShadow | ✔️ | ✔️ | | | -| CanvasContext.setStrokeStyle | ✔️ | ✔️ | | | -| CanvasContext.setTextAlign | ✔️ | ✔️ | | | -| CanvasContext.setTextBaseline | ✔️ | ✔️ | | | -| CanvasContext.setTransform | ✔️ | ✔️ | | | -| CanvasContext.stroke | ✔️ | ✔️ | | | -| CanvasContext.strokeRect | ✔️ | ✔️ | | | -| CanvasContext.strokeText | ✔️ | ✔️ | | | -| CanvasContext.transform | ✔️ | ✔️ | | | -| CanvasContext.translate | ✔️ | ✔️ | | | +| API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| CanvasContext.arc | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.arcTo | ✔️ | | ✔️ | | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.beginPath | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.bezierCurveTo | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.clearRect | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.clip | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.closePath | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.createCircularGradient | ✔️ | ✔️ | ✔️ | | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.createLinearGradient | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.createPattern | ✔️ | | ✔️ | | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.draw | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️(第二次调用 draw 前需要等待上一次 draw 调用结束后再调用,否则新的一次 draw 调用栈不会清空而导致结果异常。) | | | +| CanvasContext.drawImage | ✔️ | | | | | | ✔️ | | | +| CanvasContext.fill | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.fillRect | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.fillText | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.lineTo | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.measureText | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.moveTo | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.quadraticCurveTo | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.rect | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.reset | | | | | | | ✔️ | | | +| CanvasContext.restore | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.rotate | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.save | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.scale | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setFillStyle | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setFontSize | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setGlobalAlpha | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setLineCap | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setLineDash | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setLineJoin | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setLineWidth | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setMiterLimit | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setShadow | ✔️ | ✔️ | ✔️ | | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setStrokeStyle | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setTextAlign | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setTextBaseline | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.setTransform | ✔️ | ✔️ | | ✔️ | | ✔️ | ✔️ | | | +| CanvasContext.stroke | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.strokeRect | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.strokeText | ✔️ | ✔️ | ✔️ | | ✔️ | ✔️ | ✔️ | | | +| CanvasContext.transform | ✔️ | | | ✔️ | | ✔️ | ✔️ | | | +| CanvasContext.translate | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | diff --git a/docs/apis/canvas/CanvasGradient.md b/docs/apis/canvas/CanvasGradient.md index 74617c8ed14f..d195f96d4b7b 100644 --- a/docs/apis/canvas/CanvasGradient.md +++ b/docs/apis/canvas/CanvasGradient.md @@ -15,7 +15,7 @@ sidebar_label: CanvasGradient 添加颜色的渐变点。小于最小 stop 的部分会按最小 stop 的 color 来渲染,大于最大 stop 的部分会按最大 stop 的 color 来渲染 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasGradient.addColorStop.html) @@ -49,7 +49,7 @@ ctx.draw() ## API 支持度 -| API | 微信小程序 | H5 | React Native | Harmony | -| :---: | :---: | :---: | :---: | :---: | -| CanvasGradient | ✔️ | | | | -| CanvasGradient.addColorStop | ✔️ | | | | +| API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| CanvasGradient | ✔️ | | | | | | | | | +| CanvasGradient.addColorStop | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | diff --git a/docs/apis/canvas/Image.md b/docs/apis/canvas/Image.md index 9fa93b98c31e..a0c37fe15455 100644 --- a/docs/apis/canvas/Image.md +++ b/docs/apis/canvas/Image.md @@ -16,7 +16,7 @@ sidebar_label: Image | src | `string` | 图片的 URL | | height | `number` | 图片的真实高度 | | width | `number` | 图片的真实宽度 | -| referrerPolicy | `string` | origin: 发送完整的referrer; no-referrer: 不发送。

格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本 | +| referrerPolicy | `string` | origin: 发送完整的referrer; no-referrer: 不发送。

格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本
API 支持度: weapp | | onerror | `(...args: any[]) => any` | 图片加载发生错误后触发的回调函数 | | onload | `(...args: any[]) => any` | 图片加载完成后触发的回调函数 | @@ -25,3 +25,4 @@ sidebar_label: Image | API | 微信小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | | Image | ✔️ | | | | +| Image.referrerPolicy | ✔️ | | | | diff --git a/docs/apis/canvas/OffscreenCanvas.md b/docs/apis/canvas/OffscreenCanvas.md index 8bb6d441d590..ffb742763558 100644 --- a/docs/apis/canvas/OffscreenCanvas.md +++ b/docs/apis/canvas/OffscreenCanvas.md @@ -11,6 +11,11 @@ sidebar_label: OffscreenCanvas ## 方法 +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| width | `number` | 画布宽度 | +| height | `number` | 画布高度 | + ### createImage 创建一个图片对象。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法 @@ -31,22 +36,22 @@ sidebar_label: OffscreenCanvas > 当前仅支持获取 WebGL 绘图上下文 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.getContext.html) ```tsx -(contextType: string) => RenderingContext +(contextType: "webgl" | "2d") => RenderingContext ``` | 参数 | 类型 | | --- | --- | -| contextType | `string` | +| contextType | "webgl" or "2d" | ## API 支持度 -| API | 微信小程序 | H5 | React Native | Harmony | -| :---: | :---: | :---: | :---: | :---: | -| OffscreenCanvas | ✔️ | | | | -| OffscreenCanvas.createImage | ✔️ | | | | -| OffscreenCanvas.getContext | ✔️ | | | | +| API | 微信小程序 | 抖音小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | +| OffscreenCanvas | ✔️ | | | | | +| OffscreenCanvas.createImage | ✔️ | | | | | +| OffscreenCanvas.getContext | ✔️ | ✔️ | | | | diff --git a/docs/apis/canvas/Path2D.md b/docs/apis/canvas/Path2D.md index 3762887b6f9e..80cad7ef185f 100644 --- a/docs/apis/canvas/Path2D.md +++ b/docs/apis/canvas/Path2D.md @@ -8,3 +8,186 @@ Canvas 2D API 的接口 Path2D 用来声明路径,此路径稍后会被CanvasR 支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Path2D.html) + +## 方法 + +### addPath + +添加路径到当前路径。 + +支持情况: + +```tsx +(path: Path2D) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| path | `Path2D` | 添加的 Path2D 路径 | + +### arc + +添加一段圆弧路径 + +支持情况: + +```tsx +(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterclockwise: boolean) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 圆心横坐标 | +| y | `number` | 圆心纵坐标 | +| radius | `number` | 圆形半径,必须为正数 | +| startAngle | `number` | 圆弧开始角度 | +| endAngle | `number` | 圆弧结束角度 | +| counterclockwise | `boolean` | 是否逆时针绘制。如果传 true, 则会从 endAngle 开始绘制到 startAngle | + +### arcTo + +通过给定控制点添加一段圆弧路径 + +支持情况: + +```tsx +(x1: number, y1: number, x2: number, y2: number, radius: number) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x1 | `number` | 第一个控制点横坐标 | +| y1 | `number` | 第一个控制点纵坐标 | +| x2 | `number` | 第二个控制点横坐标 | +| y2 | `number` | 第二个控制点纵坐标 | +| radius | `number` | 圆形半径,必须为非负数 | + +### bezierCurveTo + +添加三次贝塞尔曲线路径 + +支持情况: + +```tsx +(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| cp1x | `number` | 第一个控制点横坐标 | +| cp1y | `number` | 第一个控制点纵坐标 | +| cp2x | `number` | 第二个控制点横坐标 | +| cp2y | `number` | 第二个控制点纵坐标 | +| x | `number` | 结束点横坐标 | +| y | `number` | 结束点纵坐标 | + +### closePath + +闭合路径到起点 + +支持情况: + +```tsx +() => void +``` + +### ellipse + +添加椭圆弧路径 + +支持情况: + +```tsx +(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise: boolean) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 椭圆圆心横坐标 | +| y | `number` | 椭圆圆心纵坐标 | +| radiusX | `number` | 椭圆长轴半径,必须为非负数 | +| radiusY | `number` | 椭圆短轴半径,必须为非负数 | +| rotation | `number` | 椭圆旋转角度 | +| startAngle | `number` | 圆弧开始角度 | +| endAngle | `number` | 圆弧结束角度 | +| counterclockwise | `boolean` | 是否逆时针绘制。如果传 true, 则会从 endAngle 开始绘制到 startAngle | + +### lineTo + +添加直线路径 + +支持情况: + +```tsx +(x: number, y: number) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 结束点横坐标 | +| y | `number` | 结束点纵坐标 | + +### moveTo + +移动路径开始点 + +支持情况: + +```tsx +(x: number, y: number) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 横坐标 | +| y | `number` | 纵坐标 | + +### quadraticCurveTo + +添加二次贝塞尔曲线路径 + +支持情况: + +```tsx +(cpx: number, cpy: number, x: number, y: number) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| cpx | `number` | 控制点横坐标 | +| cpy | `number` | 控制点纵坐标 | +| x | `number` | 结束点横坐标 | +| y | `number` | 结束点纵坐标 | + +### rect + +添加方形路径 + +支持情况: + +```tsx +(x: number, y: number, width: number, height: number) => void +``` + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| x | `number` | 开始点横坐标 | +| y | `number` | 开始点纵坐标 | +| width | `number` | 方形宽度,正数向右,负数向左 | +| height | `number` | 方形高度,正数向下,负数向上 | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| Path2D | ✔️ | | | | +| Path2D.addPath | ✔️ | | | | +| Path2D.arc | ✔️ | | | | +| Path2D.arcTo | ✔️ | | | | +| Path2D.bezierCurveTo | ✔️ | | | | +| Path2D.closePath | ✔️ | | | | +| Path2D.ellipse | ✔️ | | | | +| Path2D.lineTo | ✔️ | | | | +| Path2D.moveTo | ✔️ | | | | +| Path2D.quadraticCurveTo | ✔️ | | | | +| Path2D.rect | ✔️ | | | | diff --git a/docs/apis/canvas/RenderingContext.md b/docs/apis/canvas/RenderingContext.md index b8d9eba1547c..844e5db63540 100644 --- a/docs/apis/canvas/RenderingContext.md +++ b/docs/apis/canvas/RenderingContext.md @@ -9,7 +9,8 @@ Canvas 绘图上下文。 - 通过 Canvas.getContext('2d') 接口可以获取 CanvasRenderingContext2D 对象,实现了 [HTML Canvas 2D Context](https://www.w3.org/TR/2dcontext/) 定义的属性、方法。 - 通过 Canvas.getContext('webgl') 或 OffscreenCanvas.getContext('webgl') 接口可以获取 WebGLRenderingContext 对象,实现了 [WebGL 1.0](https://www.khronos.org/registry/webgl/specs/latest/1.0/) 定义的所有属性、方法、常量。 +- CanvasRenderingContext2D 的 drawImage 方法 2.10.0 起支持传入通过 SelectorQuery 获取的 video 对象,2.29.0 起支持传入开启了自定义渲染的 LivePusherContext 对象。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html) diff --git a/docs/apis/canvas/canvasGetImageData.md b/docs/apis/canvas/canvasGetImageData.md index 803373779699..3c6b3db1658f 100644 --- a/docs/apis/canvas/canvasGetImageData.md +++ b/docs/apis/canvas/canvasGetImageData.md @@ -5,7 +5,7 @@ sidebar_label: canvasGetImageData 获取 canvas 区域隐含的像素数据。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasGetImageData.html) diff --git a/docs/apis/canvas/canvasPutImageData.md b/docs/apis/canvas/canvasPutImageData.md index 8d99e3290f2b..3ff4eac3dc00 100644 --- a/docs/apis/canvas/canvasPutImageData.md +++ b/docs/apis/canvas/canvasPutImageData.md @@ -5,7 +5,7 @@ sidebar_label: canvasPutImageData 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 `` 组件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasPutImageData.html) diff --git a/docs/apis/canvas/canvasToTempFilePath.md b/docs/apis/canvas/canvasToTempFilePath.md index af4e33eeff0a..8042351ba26c 100644 --- a/docs/apis/canvas/canvasToTempFilePath.md +++ b/docs/apis/canvas/canvasToTempFilePath.md @@ -9,7 +9,7 @@ sidebar_label: canvasToTempFilePath 1. `tip`: 在 `draw` 回调里调用该方法才能保证图片导出成功。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html) @@ -46,10 +46,11 @@ sidebar_label: canvasToTempFilePath ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| tempFilePath | `string` | 生成文件的临时路径 | -| errMsg | `string` | 调用结果 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| tempFilePath | `string` | 是 | 生成文件的临时路径 | +| apFilePath | `string` | 否 | 图片路径(本地临时文件)。
API 支持度: alipay | +| errMsg | `string` | 是 | 调用结果 | ### FileType diff --git a/docs/apis/canvas/createCanvasContext.md b/docs/apis/canvas/createCanvasContext.md index db341dbfc505..47a91885359c 100644 --- a/docs/apis/canvas/createCanvasContext.md +++ b/docs/apis/canvas/createCanvasContext.md @@ -7,7 +7,7 @@ sidebar_label: createCanvasContext **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 ``;另外,Web 端需要在 `useReady` 回调中执行它,否则会因为底层 canvas 渲染出来之前而去获取 CanvasContext,导致其底层的 context 为 `undefined`,从而不能正常绘图。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createCanvasContext.html) diff --git a/docs/apis/canvas/createOffscreenCanvas.md b/docs/apis/canvas/createOffscreenCanvas.md index cb2043677a96..ad0ff698d165 100644 --- a/docs/apis/canvas/createOffscreenCanvas.md +++ b/docs/apis/canvas/createOffscreenCanvas.md @@ -5,7 +5,7 @@ sidebar_label: createOffscreenCanvas 创建离屏 canvas 实例 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html @@ -33,4 +33,28 @@ sidebar_label: createOffscreenCanvas | type | "webgl" or "2d" | `: 'webgl'` | 否 | 创建的离屏 canvas 类型 | | height | `number` | | 否 | 画布高度 | | width | `number` | | 否 | 画布宽度 | -| component | `TaroGeneral.IAnyObject` | | 否 | 在自定义组件下,当前组件实例的 this,以操作组件内 [canvas](/docs/components/canvas) 组件 | +| compInst | `TaroGeneral.IAnyObject` | | 否 | 在自定义组件下,当前组件实例的 this,以操作组件内 [canvas](/docs/components/canvas) 组件 | + +## 示例代码 + +```tsx +// 创建离屏 2D canvas 实例 +const canvas = Taro.createOffscreenCanvas({type: '2d', width: 300, height: 150}) +// 获取 context。注意这里必须要与创建时的 type 一致 +const context = canvas.getContext('2d') + +// 创建一个图片 +const image = canvas.createImage() +// 等待图片加载 +await new Promise(resolve => { + image.onload = resolve + image.src = IMAGE_URL // 要加载的图片 url +}) + +// 把图片画到离屏 canvas 上 +context.clearRect(0, 0, 300, 150) +context.drawImage(image, 0, 0, 300, 150) + +// 获取画完后的数据 +const imgData = context.getImageData(0, 0, 300, 150) +``` diff --git a/docs/apis/canvas/toTempFilePath.md b/docs/apis/canvas/toTempFilePath.md new file mode 100644 index 000000000000..e356a5bb39d4 --- /dev/null +++ b/docs/apis/canvas/toTempFilePath.md @@ -0,0 +1,35 @@ +--- +title: toTempFilePath +sidebar_label: toTempFilePath +--- + +## 参数 + +### Option + +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| x | `number` | | 否 | 指定的画布区域的左上角横坐标 | +| y | `number` | | 否 | 指定的画布区域的左上角纵坐标 | +| width | `number` | | 否 | 指定的画布区域的宽度 | +| height | `number` | | 否 | 指定的画布区域的高度 | +| destHeight | `number` | | 否 | 输出的图片的高度 | +| destWidth | `number` | | 否 | 输出的图片的宽度 | +| fileType | `keyof FileType` | `"png"` | 否 | 目标文件的类型 | +| quality | `number` | | 否 | 图片的质量,目前仅对 jpg 有效。取值范围为 (0, 1],不在范围内时当作 1.0 处理。 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(result: SuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | + +### FileType + +| 参数 | 说明 | +| --- | --- | +| jpg | jpg 图片 | +| png | png 图片 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| tempFilePath | `string` | 生成文件的临时路径 | diff --git a/docs/apis/data-analysis/getCommonConfig.md b/docs/apis/data-analysis/getCommonConfig.md new file mode 100644 index 000000000000..ccaca1977951 --- /dev/null +++ b/docs/apis/data-analysis/getCommonConfig.md @@ -0,0 +1,59 @@ +--- +title: Taro.getCommonConfig(option) +sidebar_label: getCommonConfig +--- + +给定实验参数数组,获取对应的实验参数值 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/data-analysis/wx.getCommonConfig.html) + +## 类型 + +```tsx +(option: Option) => Promise +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| keys | `string[]` | 否 | 需要获取的数据指标的对象数组,每个string的格式约定:配置类型_分表key | +| mode | 0 or 1 | 是 | 0:通用配置模式 1:实验模式, 参数与返回结果的使用等效于接口wx.getExptInfoSync | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| errcode | `number` | 错误码 | +| errmsg | `string` | 错误信息 | +| conf_type | `number` | 配置类型, 1-表类型 2-kv类型 | +| conf | `string` | 根据conf_type来确定conf内容, conf_type为1时conf是一个json数组, 类似"[{xxx},{xxx}]", 每一项对应表类型每一行配置内容, 其中conf_type为2时conf是一个json对象,类似"{xxxx}" | +| expire_sec | `number` | 过期时间,单位秒. 0表示当次有效 | + +## 示例代码 + +```tsx +Taro.getCommonConfig({ + keys:["key1", "key2"], + mode: 0, + success: (res) => { + console.log("success") + console.log(res) + }, + fail: (res) => { + console.log("fail") + console.log(res) + } +}) +``` diff --git a/docs/apis/data-analysis/reportAnalytics.md b/docs/apis/data-analysis/reportAnalytics.md index 211219abbcd7..c73848865c72 100644 --- a/docs/apis/data-analysis/reportAnalytics.md +++ b/docs/apis/data-analysis/reportAnalytics.md @@ -5,7 +5,7 @@ sidebar_label: reportAnalytics 自定义分析数据上报接口。使用前,需要在小程序管理后台自定义分析中新建事件,配置好事件名与字段。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/data-analysis/wx.reportAnalytics.html) diff --git a/docs/apis/device/accelerometer/offAccelerometerChange.md b/docs/apis/device/accelerometer/offAccelerometerChange.md index 3a2804c18ae8..4dadacc7dc52 100644 --- a/docs/apis/device/accelerometer/offAccelerometerChange.md +++ b/docs/apis/device/accelerometer/offAccelerometerChange.md @@ -5,18 +5,18 @@ sidebar_label: offAccelerometerChange 取消监听加速度数据事件,参数为空,则取消所有的事件监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.offAccelerometerChange.html) ## 类型 ```tsx -(callback?: (...args: any[]) => any) => void +(callback?: Callback) => void ``` ## 参数 | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `(...args: any[]) => any` | 加速度数据事件的回调函数 | +| callback | `Callback` | 加速度数据事件的回调函数 | diff --git a/docs/apis/device/accelerometer/onAccelerometerChange.md b/docs/apis/device/accelerometer/onAccelerometerChange.md index e10c8beb6ec2..f2f4da2692eb 100644 --- a/docs/apis/device/accelerometer/onAccelerometerChange.md +++ b/docs/apis/device/accelerometer/onAccelerometerChange.md @@ -5,7 +5,7 @@ sidebar_label: onAccelerometerChange 监听加速度数据,频率:5次/秒,接口调用后会自动开始监听,可使用 `Taro.stopAccelerometer` 停止监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.onAccelerometerChange.html) diff --git a/docs/apis/device/accelerometer/startAccelerometer.md b/docs/apis/device/accelerometer/startAccelerometer.md index fef25d91e338..68e062742ba6 100644 --- a/docs/apis/device/accelerometer/startAccelerometer.md +++ b/docs/apis/device/accelerometer/startAccelerometer.md @@ -5,7 +5,7 @@ sidebar_label: startAccelerometer 开始监听加速度数据。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.startAccelerometer.html) diff --git a/docs/apis/device/accelerometer/stopAccelerometer.md b/docs/apis/device/accelerometer/stopAccelerometer.md index d5b519c3a81e..0e3fa7b7e939 100644 --- a/docs/apis/device/accelerometer/stopAccelerometer.md +++ b/docs/apis/device/accelerometer/stopAccelerometer.md @@ -5,7 +5,7 @@ sidebar_label: stopAccelerometer 停止监听加速度数据。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.stopAccelerometer.html) diff --git a/docs/apis/device/accessibility/checkIsOpenAccessibility.md b/docs/apis/device/accessibility/checkIsOpenAccessibility.md index 518011bdd70a..a65a07837a21 100644 --- a/docs/apis/device/accessibility/checkIsOpenAccessibility.md +++ b/docs/apis/device/accessibility/checkIsOpenAccessibility.md @@ -5,7 +5,7 @@ sidebar_label: checkIsOpenAccessibility 检测是否开启视觉无障碍功能。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/accessibility/wx.checkIsOpenAccessibility.html) diff --git a/docs/apis/device/battery/getBatteryInfo.md b/docs/apis/device/battery/getBatteryInfo.md index 33f0be388bb8..f285d96ed474 100644 --- a/docs/apis/device/battery/getBatteryInfo.md +++ b/docs/apis/device/battery/getBatteryInfo.md @@ -5,7 +5,7 @@ sidebar_label: getBatteryInfo 获取设备电量。同步 API Taro.getBatteryInfoSync 在 iOS 上不可用。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/battery/wx.getBatteryInfo.html) diff --git a/docs/apis/device/battery/getBatteryInfoSync.md b/docs/apis/device/battery/getBatteryInfoSync.md index 1f41e39a8122..82f54498f9d5 100644 --- a/docs/apis/device/battery/getBatteryInfoSync.md +++ b/docs/apis/device/battery/getBatteryInfoSync.md @@ -5,7 +5,7 @@ sidebar_label: getBatteryInfoSync Taro.getBatteryInfo 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/battery/wx.getBatteryInfoSync.html) @@ -22,4 +22,4 @@ Taro.getBatteryInfo 的同步版本 | 参数 | 类型 | 说明 | | --- | --- | --- | | isCharging | `boolean` | 是否正在充电中 | -| level | `string` | 设备电量,范围 1 - 100 | +| level | `number` | 设备电量,范围 1 - 100 | diff --git a/docs/apis/device/bluetooth-ble/closeBLEConnection.md b/docs/apis/device/bluetooth-ble/closeBLEConnection.md index 63610940ffc6..0aef19a87148 100644 --- a/docs/apis/device/bluetooth-ble/closeBLEConnection.md +++ b/docs/apis/device/bluetooth-ble/closeBLEConnection.md @@ -5,7 +5,7 @@ sidebar_label: closeBLEConnection 断开与低功耗蓝牙设备的连接。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.closeBLEConnection.html) diff --git a/docs/apis/device/bluetooth-ble/createBLEConnection.md b/docs/apis/device/bluetooth-ble/createBLEConnection.md index d4f2b89b04a8..fd8144e619de 100644 --- a/docs/apis/device/bluetooth-ble/createBLEConnection.md +++ b/docs/apis/device/bluetooth-ble/createBLEConnection.md @@ -12,7 +12,7 @@ sidebar_label: createBLEConnection - 蓝牙连接随时可能断开,建议监听 Taro.onBLEConnectionStateChange 回调事件,当蓝牙设备断开时按需执行重连操作 - 若对未连接的设备或已断开连接的设备调用数据读写操作的接口,会返回 10006 错误,建议进行重连操作。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.createBLEConnection.html) diff --git a/docs/apis/device/bluetooth-ble/getBLEDeviceCharacteristics.md b/docs/apis/device/bluetooth-ble/getBLEDeviceCharacteristics.md index 2494b53bb17f..27c5a16b31a3 100644 --- a/docs/apis/device/bluetooth-ble/getBLEDeviceCharacteristics.md +++ b/docs/apis/device/bluetooth-ble/getBLEDeviceCharacteristics.md @@ -5,7 +5,7 @@ sidebar_label: getBLEDeviceCharacteristics 获取蓝牙设备某个服务中所有特征值(characteristic)。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceCharacteristics.html) @@ -57,6 +57,8 @@ sidebar_label: getBLEDeviceCharacteristics | notify | `boolean` | 该特征值是否支持 notify 操作 | | read | `boolean` | 该特征值是否支持 read 操作 | | write | `boolean` | 该特征值是否支持 write 操作 | +| writeNoResponse | `boolean` | 该特征是否支持无回复写操作 | +| writeDefault | `boolean` | 该特征是否支持有回复写操作 | ## 示例代码 diff --git a/docs/apis/device/bluetooth-ble/getBLEDeviceRSSI.md b/docs/apis/device/bluetooth-ble/getBLEDeviceRSSI.md index 72e67ddfd2d8..27817493e820 100644 --- a/docs/apis/device/bluetooth-ble/getBLEDeviceRSSI.md +++ b/docs/apis/device/bluetooth-ble/getBLEDeviceRSSI.md @@ -5,7 +5,7 @@ sidebar_label: getBLEDeviceRSSI 获取蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI)。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceRSSI.html) diff --git a/docs/apis/device/bluetooth-ble/getBLEDeviceServices.md b/docs/apis/device/bluetooth-ble/getBLEDeviceServices.md index ebc7a35539cb..edaeea821220 100644 --- a/docs/apis/device/bluetooth-ble/getBLEDeviceServices.md +++ b/docs/apis/device/bluetooth-ble/getBLEDeviceServices.md @@ -5,7 +5,7 @@ sidebar_label: getBLEDeviceServices 获取蓝牙设备所有服务(service)。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceServices.html) diff --git a/docs/apis/device/bluetooth-ble/getBLEMTU.md b/docs/apis/device/bluetooth-ble/getBLEMTU.md index 15e02b1d2274..e3d8471008b6 100644 --- a/docs/apis/device/bluetooth-ble/getBLEMTU.md +++ b/docs/apis/device/bluetooth-ble/getBLEMTU.md @@ -9,7 +9,7 @@ sidebar_label: getBLEMTU - 小程序中 MTU 为 ATT_MTU,包含 Op-Code 和 Attribute Handle 的长度,实际可以传输的数据长度为 ATT_MTU - 3 - iOS 系统中 MTU 为固定值;安卓系统中,MTU 会在系统协商成功之后发生改变,建议使用 [Taro.onBLEMTUChange](/docs/apis/device/bluetooth-ble/onBLEMTUChange) 监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEMTU.html) @@ -30,7 +30,7 @@ sidebar_label: getBLEMTU | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | | deviceId | `string` | | 是 | 蓝牙设备 id | -| writeType | `keyof WriteType` | `"write"` | 是 | 写模式 (iOS 特有参数) | +| writeType | `keyof WriteType` | `"write"` | 否 | 写模式 (iOS 特有参数) | | complete | `(res: TaroGeneral.BluetoothError) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.BluetoothError) => void` | | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/bluetooth-ble/notifyBLECharacteristicValueChange.md b/docs/apis/device/bluetooth-ble/notifyBLECharacteristicValueChange.md index 2c6cb5907022..ac2f59534828 100644 --- a/docs/apis/device/bluetooth-ble/notifyBLECharacteristicValueChange.md +++ b/docs/apis/device/bluetooth-ble/notifyBLECharacteristicValueChange.md @@ -11,7 +11,7 @@ sidebar_label: notifyBLECharacteristicValueChange - 订阅操作成功后需要设备主动更新特征值的 value,才会触发 Taro.onBLECharacteristicValueChange 回调。 - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.notifyBLECharacteristicValueChange.html) @@ -35,15 +35,18 @@ sidebar_label: notifyBLECharacteristicValueChange ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| characteristicId | `string` | 是 | 蓝牙特征值的 uuid | -| deviceId | `string` | 是 | 蓝牙设备 id | -| serviceId | `string` | 是 | 蓝牙特征值对应服务的 uuid | -| state | `boolean` | 是 | 是否启用 notify | -| complete | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用失败的回调函数 | -| success | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| characteristicId | `string` | | 是 | 蓝牙特征值的 uuid | +| deviceId | `string` | | 是 | 蓝牙设备 id | +| serviceId | `string` | | 是 | 蓝牙特征值对应服务的 uuid | +| state | `boolean` | | 是 | 是否启用 notify | +| type | `keyof Type` | `"indication"` | 否 | 设置特征订阅类型,有效值有 notification 和 indication | +| complete | `(res: TaroGeneral.BluetoothError) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.BluetoothError) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.BluetoothError) => void` | | 否 | 接口调用成功的回调函数 | + +### Type ## 示例代码 diff --git a/docs/apis/device/bluetooth-ble/offBLECharacteristicValueChange.md b/docs/apis/device/bluetooth-ble/offBLECharacteristicValueChange.md index 0596efeb90dd..a91e92ea10b8 100644 --- a/docs/apis/device/bluetooth-ble/offBLECharacteristicValueChange.md +++ b/docs/apis/device/bluetooth-ble/offBLECharacteristicValueChange.md @@ -5,7 +5,7 @@ sidebar_label: offBLECharacteristicValueChange 取消监听蓝牙低功耗设备的特征值变化事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLECharacteristicValueChange.html) diff --git a/docs/apis/device/bluetooth-ble/offBLEConnectionStateChange.md b/docs/apis/device/bluetooth-ble/offBLEConnectionStateChange.md index a92896c9a965..9277cc48a735 100644 --- a/docs/apis/device/bluetooth-ble/offBLEConnectionStateChange.md +++ b/docs/apis/device/bluetooth-ble/offBLEConnectionStateChange.md @@ -5,14 +5,14 @@ sidebar_label: offBLEConnectionStateChange 取消监听蓝牙低功耗连接状态的改变事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html) ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/bluetooth-ble/offBLEMTUChange.md b/docs/apis/device/bluetooth-ble/offBLEMTUChange.md index dca88e2d4fa6..a37526dbc229 100644 --- a/docs/apis/device/bluetooth-ble/offBLEMTUChange.md +++ b/docs/apis/device/bluetooth-ble/offBLEMTUChange.md @@ -12,7 +12,7 @@ sidebar_label: offBLEMTUChange ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/bluetooth-ble/onBLECharacteristicValueChange.md b/docs/apis/device/bluetooth-ble/onBLECharacteristicValueChange.md index 3f90eeadebe4..3f1e7ed28348 100644 --- a/docs/apis/device/bluetooth-ble/onBLECharacteristicValueChange.md +++ b/docs/apis/device/bluetooth-ble/onBLECharacteristicValueChange.md @@ -5,7 +5,7 @@ sidebar_label: onBLECharacteristicValueChange 监听低功耗蓝牙设备的特征值变化事件。必须先启用 `notifyBLECharacteristicValueChange` 接口才能接收到设备推送的 notification。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLECharacteristicValueChange.html) diff --git a/docs/apis/device/bluetooth-ble/onBLEConnectionStateChange.md b/docs/apis/device/bluetooth-ble/onBLEConnectionStateChange.md index 31ff531ed139..a72cb29bd223 100644 --- a/docs/apis/device/bluetooth-ble/onBLEConnectionStateChange.md +++ b/docs/apis/device/bluetooth-ble/onBLEConnectionStateChange.md @@ -5,7 +5,7 @@ sidebar_label: onBLEConnectionStateChange 监听低功耗蓝牙连接状态的改变事件。包括开发者主动连接或断开连接,设备丢失,连接异常断开等等 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLEConnectionStateChange.html) diff --git a/docs/apis/device/bluetooth-ble/readBLECharacteristicValue.md b/docs/apis/device/bluetooth-ble/readBLECharacteristicValue.md index e83f3949ec23..9762482baec2 100644 --- a/docs/apis/device/bluetooth-ble/readBLECharacteristicValue.md +++ b/docs/apis/device/bluetooth-ble/readBLECharacteristicValue.md @@ -9,7 +9,7 @@ sidebar_label: readBLECharacteristicValue - 并行调用多次会存在读失败的可能性。 - 接口读取到的信息需要在 `onBLECharacteristicValueChange` 方法注册的回调中获取。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.readBLECharacteristicValue.html) diff --git a/docs/apis/device/bluetooth-ble/setBLEMTU.md b/docs/apis/device/bluetooth-ble/setBLEMTU.md index 1298dcbd6ad2..be59baf428c2 100644 --- a/docs/apis/device/bluetooth-ble/setBLEMTU.md +++ b/docs/apis/device/bluetooth-ble/setBLEMTU.md @@ -5,7 +5,10 @@ sidebar_label: setBLEMTU 协商设置蓝牙低功耗的最大传输单元 (Maximum Transmission Unit, MTU) -支持情况: +- 需在 Taro.createBLEConnection 调用成功后调用 +- 仅安卓系统 5.1 以上版本有效,iOS 因系统限制不支持。 + +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.setBLEMTU.html) diff --git a/docs/apis/device/bluetooth-ble/writeBLECharacteristicValue.md b/docs/apis/device/bluetooth-ble/writeBLECharacteristicValue.md index 93499548cb37..9ed0a53bde6e 100644 --- a/docs/apis/device/bluetooth-ble/writeBLECharacteristicValue.md +++ b/docs/apis/device/bluetooth-ble/writeBLECharacteristicValue.md @@ -11,7 +11,7 @@ sidebar_label: writeBLECharacteristicValue - 若单次写入数据过长,iOS 上存在系统不会有任何回调的情况(包括错误回调)。 - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.writeBLECharacteristicValue.html) @@ -41,10 +41,18 @@ sidebar_label: writeBLECharacteristicValue | deviceId | `string` | 是 | 蓝牙设备 id | | serviceId | `string` | 是 | 蓝牙特征值对应服务的 uuid | | value | `ArrayBuffer` | 是 | 蓝牙设备特征值对应的二进制值 | +| writeType | `keyof WriteType` | 否 | 蓝牙特征值的写模式设置,有两种模式,iOS 优先 write,安卓优先 writeNoResponse 。(基础库 2.22.0 开始支持) | | complete | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用失败的回调函数 | | success | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用成功的回调函数 | +### WriteType + +| 参数 | 说明 | +| --- | --- | +| write | 强制回复写,不支持时报错 | +| writeNoResponse | 强制无回复写,不支持时报错 | + ## 示例代码 ```tsx diff --git a/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer.md b/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer.md index 49034eb44d6c..baa352964ab7 100644 --- a/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer.md +++ b/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer.md @@ -15,7 +15,7 @@ sidebar_label: BLEPeripheralServer 添加服务 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.addService.html) @@ -47,12 +47,12 @@ sidebar_label: BLEPeripheralServer 取消监听已连接的设备请求读当前外围设备的特征值事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicReadRequest.html) ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` | 参数 | 类型 | 说明 | @@ -63,12 +63,12 @@ sidebar_label: BLEPeripheralServer 取消监听特征订阅事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicSubscribed.html) ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` | 参数 | 类型 | 说明 | @@ -84,7 +84,7 @@ sidebar_label: BLEPeripheralServer > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicUnsubscribed.html) ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` | 参数 | 类型 | 说明 | @@ -95,12 +95,12 @@ sidebar_label: BLEPeripheralServer 取消监听已连接的设备请求写当前外围设备的特征值事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicWriteRequest.html) ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` | 参数 | 类型 | 说明 | @@ -113,7 +113,7 @@ sidebar_label: BLEPeripheralServer 收到该消息后需要立刻调用 [writeCharacteristicValue](/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer#writecharacteristicvalue) 写回数据,否则主机不会收到响应。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicReadRequest.html) @@ -129,7 +129,7 @@ sidebar_label: BLEPeripheralServer 监听特征订阅事件,仅 iOS 支持 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicSubscribed.html) @@ -145,7 +145,7 @@ sidebar_label: BLEPeripheralServer 监听取消特征订阅事件,仅 iOS 支持 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicUnsubscribed.html) @@ -161,7 +161,7 @@ sidebar_label: BLEPeripheralServer 监听已连接的设备请求写当前外围设备的特征值事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicWriteRequest.html) @@ -177,7 +177,7 @@ sidebar_label: BLEPeripheralServer 移除服务 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.removeService.html) @@ -193,7 +193,7 @@ sidebar_label: BLEPeripheralServer 开始广播本地创建的外围设备 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.startAdvertising.html) @@ -209,7 +209,7 @@ sidebar_label: BLEPeripheralServer 停止广播 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.stopAdvertising.html) @@ -225,7 +225,7 @@ sidebar_label: BLEPeripheralServer 往指定特征写入二进制数据值,并通知已连接的主机,从机的特征值已发生变化,该接口会处理是走回包还是走订阅 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html) @@ -259,13 +259,13 @@ sidebar_label: BLEPeripheralServer #### characteristic -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| uuid | `string` | characteristic 的 UUID | -| properties | `properties` | 特征支持的操作 | -| permission | `characteristicPermission` | 特征权限 | -| value | `ArrayBuffer` | 特征对应的二进制值 | -| descriptors | `descriptor[]` | 描述符数据 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| uuid | `string` | 是 | characteristic 的 UUID | +| properties | `properties` | 否 | 特征支持的操作 | +| permission | `characteristicPermission` | 否 | 特征权限 | +| value | `ArrayBuffer` | 否 | 特征对应的二进制值 | +| descriptors | `descriptor[]` | 否 | 描述符数据 | #### properties @@ -294,11 +294,11 @@ sidebar_label: BLEPeripheralServer 描述符数据 -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| uuid | `string` | Descriptor 的 UUID | -| permission | `descriptorPermission` | 描述符的权限 | -| value | `ArrayBuffer` | 描述符数据 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| uuid | `string` | 是 | Descriptor 的 UUID | +| permission | `descriptorPermission` | 否 | 描述符的权限 | +| value | `ArrayBuffer` | 是 | 描述符数据 | #### descriptorPermission @@ -498,20 +498,20 @@ sidebar_label: BLEPeripheralServer ## API 支持度 -| API | 微信小程序 | H5 | React Native | Harmony | -| :---: | :---: | :---: | :---: | :---: | -| BLEPeripheralServer | ✔️ | | | | -| BLEPeripheralServer.addService | ✔️ | | | | -| BLEPeripheralServer.close | ✔️ | | | | -| BLEPeripheralServer.offCharacteristicReadRequest | ✔️ | | | | -| BLEPeripheralServer.offCharacteristicSubscribed | ✔️ | | | | -| BLEPeripheralServer.offCharacteristicUnsubscribed | ✔️ | | | | -| BLEPeripheralServer.offCharacteristicWriteRequest | ✔️ | | | | -| BLEPeripheralServer.onCharacteristicReadRequest | ✔️ | | | | -| BLEPeripheralServer.onCharacteristicSubscribed | ✔️ | | | | -| BLEPeripheralServer.onCharacteristicUnsubscribed | ✔️ | | | | -| BLEPeripheralServer.onCharacteristicWriteRequest | ✔️ | | | | -| BLEPeripheralServer.removeService | ✔️ | | | | -| BLEPeripheralServer.startAdvertising | ✔️ | | | | -| BLEPeripheralServer.stopAdvertising | ✔️ | | | | -| BLEPeripheralServer.writeCharacteristicValue | ✔️ | | | | +| API | 微信小程序 | 京东小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | +| BLEPeripheralServer | ✔️ | | | | | +| BLEPeripheralServer.addService | ✔️ | ✔️ | | | | +| BLEPeripheralServer.close | ✔️ | | | | | +| BLEPeripheralServer.offCharacteristicReadRequest | ✔️ | ✔️ | | | | +| BLEPeripheralServer.offCharacteristicSubscribed | ✔️ | ✔️ | | | | +| BLEPeripheralServer.offCharacteristicUnsubscribed | ✔️ | | | | | +| BLEPeripheralServer.offCharacteristicWriteRequest | ✔️ | ✔️ | | | | +| BLEPeripheralServer.onCharacteristicReadRequest | ✔️ | ✔️ | | | | +| BLEPeripheralServer.onCharacteristicSubscribed | ✔️ | ✔️ | | | | +| BLEPeripheralServer.onCharacteristicUnsubscribed | ✔️ | ✔️ | | | | +| BLEPeripheralServer.onCharacteristicWriteRequest | ✔️ | ✔️ | | | | +| BLEPeripheralServer.removeService | ✔️ | ✔️ | | | | +| BLEPeripheralServer.startAdvertising | ✔️ | ✔️ | | | | +| BLEPeripheralServer.stopAdvertising | ✔️ | ✔️ | | | | +| BLEPeripheralServer.writeCharacteristicValue | ✔️ | ✔️ | | | | diff --git a/docs/apis/device/bluetooth-peripheral/createBLEPeripheralServer.md b/docs/apis/device/bluetooth-peripheral/createBLEPeripheralServer.md index 198bd345ca50..88a0f9a571c8 100644 --- a/docs/apis/device/bluetooth-peripheral/createBLEPeripheralServer.md +++ b/docs/apis/device/bluetooth-peripheral/createBLEPeripheralServer.md @@ -5,7 +5,7 @@ sidebar_label: createBLEPeripheralServer 建立本地作为蓝牙低功耗外围设备的服务端,可创建多个 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.createBLEPeripheralServer.html) diff --git a/docs/apis/device/bluetooth-peripheral/offBLEPeripheralConnectionStateChanged.md b/docs/apis/device/bluetooth-peripheral/offBLEPeripheralConnectionStateChanged.md index 5d75b9165f86..690cf2b0dccd 100644 --- a/docs/apis/device/bluetooth-peripheral/offBLEPeripheralConnectionStateChanged.md +++ b/docs/apis/device/bluetooth-peripheral/offBLEPeripheralConnectionStateChanged.md @@ -5,14 +5,14 @@ sidebar_label: offBLEPeripheralConnectionStateChanged 取消监听当前外围设备被连接或断开连接事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.offBLEPeripheralConnectionStateChanged.html) ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/bluetooth-peripheral/onBLEPeripheralConnectionStateChanged.md b/docs/apis/device/bluetooth-peripheral/onBLEPeripheralConnectionStateChanged.md index d62801d5d48d..0e9b34d09c51 100644 --- a/docs/apis/device/bluetooth-peripheral/onBLEPeripheralConnectionStateChanged.md +++ b/docs/apis/device/bluetooth-peripheral/onBLEPeripheralConnectionStateChanged.md @@ -5,7 +5,7 @@ sidebar_label: onBLEPeripheralConnectionStateChanged 监听当前外围设备被连接或断开连接事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.onBLEPeripheralConnectionStateChanged.html) @@ -39,4 +39,4 @@ sidebar_label: onBLEPeripheralConnectionStateChanged | --- | --- | --- | | deviceId | `string` | 蓝牙设备 id | | serverId | `string` | server 的 UUID | -| connected | `string` | 连接目前状态 | +| connected | `boolean` | 连接目前状态 | diff --git a/docs/apis/device/bluetooth/closeBluetoothAdapter.md b/docs/apis/device/bluetooth/closeBluetoothAdapter.md index 72f042fbd950..c34f93061dbb 100644 --- a/docs/apis/device/bluetooth/closeBluetoothAdapter.md +++ b/docs/apis/device/bluetooth/closeBluetoothAdapter.md @@ -5,7 +5,7 @@ sidebar_label: closeBluetoothAdapter 关闭蓝牙模块。调用该方法将断开所有已建立的连接并释放系统资源。建议在使用蓝牙流程后,与 Taro.openBluetoothAdapter 成对调用。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.closeBluetoothAdapter.html) diff --git a/docs/apis/device/bluetooth/getBluetoothAdapterState.md b/docs/apis/device/bluetooth/getBluetoothAdapterState.md index d5c4c1fcd266..997c9cd689f0 100644 --- a/docs/apis/device/bluetooth/getBluetoothAdapterState.md +++ b/docs/apis/device/bluetooth/getBluetoothAdapterState.md @@ -5,7 +5,7 @@ sidebar_label: getBluetoothAdapterState 获取本机蓝牙适配器状态。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothAdapterState.html) diff --git a/docs/apis/device/bluetooth/getBluetoothDevices.md b/docs/apis/device/bluetooth/getBluetoothDevices.md index 7b93439ce290..275da7ba91e4 100644 --- a/docs/apis/device/bluetooth/getBluetoothDevices.md +++ b/docs/apis/device/bluetooth/getBluetoothDevices.md @@ -9,7 +9,7 @@ sidebar_label: getBluetoothDevices - 该接口获取到的设备列表为**蓝牙模块生效期间所有搜索到的蓝牙设备**,若在蓝牙模块使用流程结束后未及时调用 Taro.closeBluetoothAdapter 释放资源,会存在调用该接口会返回之前的蓝牙使用流程中搜索到的蓝牙设备,可能设备已经不在用户身边,无法连接。 - 蓝牙设备在被搜索到时,系统返回的 name 字段一般为广播包中的 LocalName 字段中的设备名称,而如果与蓝牙设备建立连接,系统返回的 name 字段会改为从蓝牙设备上获取到的 `GattName`。若需要动态改变设备名称并展示,建议使用 `localName` 字段。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getBluetoothDevices.html) @@ -44,15 +44,16 @@ sidebar_label: getBluetoothDevices uuid 对应的的已连接设备列表 -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| RSSI | `number` | 当前蓝牙设备的信号强度 | -| advertisData | `ArrayBuffer` | 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 | -| advertisServiceUUIDs | `string[]` | 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 | -| deviceId | `string` | 用于区分设备的 id | -| localName | `string` | 当前蓝牙设备的广播数据段中的 LocalName 数据段 | -| name | `string` | 蓝牙设备名称,某些设备可能没有 | -| serviceData | `TaroGeneral.IAnyObject` | 当前蓝牙设备的广播数据段中的 ServiceData 数据段 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| RSSI | `number` | 是 | 当前蓝牙设备的信号强度 | +| advertisData | `ArrayBuffer` | 是 | 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 | +| advertisServiceUUIDs | `string[]` | 是 | 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 | +| deviceId | `string` | 是 | 用于区分设备的 id | +| localName | `string` | 是 | 当前蓝牙设备的广播数据段中的 LocalName 数据段 | +| name | `string` | 是 | 蓝牙设备名称,某些设备可能没有 | +| serviceData | `TaroGeneral.IAnyObject` | 是 | 当前蓝牙设备的广播数据段中的 ServiceData 数据段 | +| connectable | `boolean` | 否 | 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) | ## 示例代码 diff --git a/docs/apis/device/bluetooth/getConnectedBluetoothDevices.md b/docs/apis/device/bluetooth/getConnectedBluetoothDevices.md index fa2aa5c5882e..bf959aaf6269 100644 --- a/docs/apis/device/bluetooth/getConnectedBluetoothDevices.md +++ b/docs/apis/device/bluetooth/getConnectedBluetoothDevices.md @@ -5,7 +5,7 @@ sidebar_label: getConnectedBluetoothDevices 根据 uuid 获取处于已连接状态的设备。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.getConnectedBluetoothDevices.html) diff --git a/docs/apis/device/bluetooth/isBluetoothDevicePaired.md b/docs/apis/device/bluetooth/isBluetoothDevicePaired.md index 1b18c7f02f6e..406ffc3cf3d1 100644 --- a/docs/apis/device/bluetooth/isBluetoothDevicePaired.md +++ b/docs/apis/device/bluetooth/isBluetoothDevicePaired.md @@ -12,7 +12,7 @@ sidebar_label: isBluetoothDevicePaired ## 类型 ```tsx -(option: Option) => boolean +(option: Option) => Promise ``` ## 参数 diff --git a/docs/apis/device/bluetooth/offBluetoothAdapterStateChange.md b/docs/apis/device/bluetooth/offBluetoothAdapterStateChange.md index 7fe9980a70f3..a8f829fd3b5e 100644 --- a/docs/apis/device/bluetooth/offBluetoothAdapterStateChange.md +++ b/docs/apis/device/bluetooth/offBluetoothAdapterStateChange.md @@ -5,7 +5,7 @@ sidebar_label: offBluetoothAdapterStateChange 取消监听蓝牙适配器状态变化事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothAdapterStateChange.html) diff --git a/docs/apis/device/bluetooth/offBluetoothDeviceFound.md b/docs/apis/device/bluetooth/offBluetoothDeviceFound.md index 2debec33111c..48c78cd1a033 100644 --- a/docs/apis/device/bluetooth/offBluetoothDeviceFound.md +++ b/docs/apis/device/bluetooth/offBluetoothDeviceFound.md @@ -5,7 +5,7 @@ sidebar_label: offBluetoothDeviceFound 取消监听寻找到新设备的事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothDeviceFound.html) diff --git a/docs/apis/device/bluetooth/onBluetoothAdapterStateChange.md b/docs/apis/device/bluetooth/onBluetoothAdapterStateChange.md index 75626d4fef9d..0684683c49a2 100644 --- a/docs/apis/device/bluetooth/onBluetoothAdapterStateChange.md +++ b/docs/apis/device/bluetooth/onBluetoothAdapterStateChange.md @@ -5,7 +5,7 @@ sidebar_label: onBluetoothAdapterStateChange 监听蓝牙适配器状态变化事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothAdapterStateChange.html) diff --git a/docs/apis/device/bluetooth/onBluetoothDeviceFound.md b/docs/apis/device/bluetooth/onBluetoothDeviceFound.md index 7d432085ab1a..eb1e6784d018 100644 --- a/docs/apis/device/bluetooth/onBluetoothDeviceFound.md +++ b/docs/apis/device/bluetooth/onBluetoothDeviceFound.md @@ -9,7 +9,7 @@ sidebar_label: onBluetoothDeviceFound - 若在 Taro.onBluetoothDeviceFound 回调了某个设备,则此设备会添加到 Taro.getBluetoothDevices 接口获取到的数组中。 - 安卓下部分机型需要有位置权限才能搜索到设备,需留意是否开启了位置权限 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.onBluetoothDeviceFound.html) @@ -47,15 +47,16 @@ sidebar_label: onBluetoothDeviceFound 新搜索到的设备 -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| RSSI | `number` | 当前蓝牙设备的信号强度 | -| advertisData | `ArrayBuffer` | 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 | -| advertisServiceUUIDs | `string[]` | 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 | -| deviceId | `string` | 用于区分设备的 id | -| localName | `string` | 当前蓝牙设备的广播数据段中的 LocalName 数据段 | -| name | `string` | 蓝牙设备名称,某些设备可能没有 | -| serviceData | `TaroGeneral.IAnyObject` | 当前蓝牙设备的广播数据段中的 ServiceData 数据段 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| RSSI | `number` | 是 | 当前蓝牙设备的信号强度,单位 dBm | +| advertisData | `ArrayBuffer` | 是 | 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 | +| advertisServiceUUIDs | `string[]` | 是 | 当前蓝牙设备的广播数据段中的 ServiceUUIDs 数据段 | +| deviceId | `string` | 是 | 用于区分设备的 id | +| localName | `string` | 是 | 当前蓝牙设备的广播数据段中的 LocalName 数据段 | +| name | `string` | 是 | 蓝牙设备名称,某些设备可能没有 | +| serviceData | `TaroGeneral.IAnyObject` | 是 | 当前蓝牙设备的广播数据段中的 ServiceData 数据段 | +| connectable | `boolean` | 否 | 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) | ## 示例代码 diff --git a/docs/apis/device/bluetooth/openBluetoothAdapter.md b/docs/apis/device/bluetooth/openBluetoothAdapter.md index fdf419c285c1..757c8f6ddd73 100644 --- a/docs/apis/device/bluetooth/openBluetoothAdapter.md +++ b/docs/apis/device/bluetooth/openBluetoothAdapter.md @@ -9,7 +9,7 @@ sidebar_label: openBluetoothAdapter - 其他蓝牙相关 API 必须在 Taro.openBluetoothAdapter 调用之后使用。否则 API 会返回错误(errCode=10000)。 - 在用户蓝牙开关未开启或者手机不支持蓝牙功能的情况下,调用 Taro.openBluetoothAdapter 监听手机蓝牙状态的改变,也可以调用蓝牙模块的所有API。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.openBluetoothAdapter.html) @@ -29,10 +29,18 @@ sidebar_label: openBluetoothAdapter | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | +| mode | `keyof Mode` | 否 | 蓝牙模式,可作为主/从设备,仅 iOS 需要。 | | complete | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用失败的回调函数 | | success | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用成功的回调函数 | +### Mode + +| 参数 | 说明 | +| --- | --- | +| central | 主机模式 | +| peripheral | 从机(外围设备)模式 | + ### state object.fail 回调函数返回的 state 参数(仅 iOS) diff --git a/docs/apis/device/bluetooth/startBluetoothDevicesDiscovery.md b/docs/apis/device/bluetooth/startBluetoothDevicesDiscovery.md index 0dd7f1f1f373..366525c6cdaa 100644 --- a/docs/apis/device/bluetooth/startBluetoothDevicesDiscovery.md +++ b/docs/apis/device/bluetooth/startBluetoothDevicesDiscovery.md @@ -5,7 +5,7 @@ sidebar_label: startBluetoothDevicesDiscovery 开始搜寻附近的蓝牙外围设备。**此操作比较耗费系统资源,请在搜索并连接到设备后调用 Taro.stopBluetoothDevicesDiscovery 方法停止搜索。** -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.startBluetoothDevicesDiscovery.html) @@ -36,8 +36,17 @@ sidebar_label: startBluetoothDevicesDiscovery | fail | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用失败的回调函数 | | interval | `number` | 否 | 上报设备的间隔。0 表示找到新设备立即上报,其他数值根据传入的间隔上报。 | | services | `string[]` | 否 | 要搜索的蓝牙设备主 service 的 uuid 列表。某些蓝牙设备会广播自己的主 service 的 uuid。如果设置此参数,则只搜索广播包有对应 uuid 的主服务的蓝牙设备。建议主要通过该参数过滤掉周边不需要处理的其他蓝牙设备。 | +| powerLevel | `keyof PowerLevel` | 否 | 扫描模式,越高扫描越快,也越耗电。仅安卓微信客户端 7.0.12 及以上支持。 | | success | `(res: TaroGeneral.BluetoothError) => void` | 否 | 接口调用成功的回调函数 | +### PowerLevel + +| 参数 | 说明 | +| --- | --- | +| low | 低 | +| medium | 中 | +| high | 高 | + ## 示例代码 ```tsx diff --git a/docs/apis/device/bluetooth/stopBluetoothDevicesDiscovery.md b/docs/apis/device/bluetooth/stopBluetoothDevicesDiscovery.md index bb8392df8ca1..fad00da80c7d 100644 --- a/docs/apis/device/bluetooth/stopBluetoothDevicesDiscovery.md +++ b/docs/apis/device/bluetooth/stopBluetoothDevicesDiscovery.md @@ -5,7 +5,7 @@ sidebar_label: stopBluetoothDevicesDiscovery 停止搜寻附近的蓝牙外围设备。若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.stopBluetoothDevicesDiscovery.html) diff --git a/docs/apis/device/calendar/addPhoneRepeatCalendar.md b/docs/apis/device/calendar/addPhoneRepeatCalendar.md index 89ec8620fd69..c798ea59efa3 100644 --- a/docs/apis/device/calendar/addPhoneRepeatCalendar.md +++ b/docs/apis/device/calendar/addPhoneRepeatCalendar.md @@ -33,8 +33,17 @@ sidebar_label: addPhoneRepeatCalendar | endTime | `string` | | 否 | 结束时间的 unix 时间戳,默认与开始时间相同 | | alarm | `boolean` | `true` | 否 | 是否提醒 | | alarmOffset | `number` | `0` | 否 | 提醒提前量,单位秒,默认 0 表示开始时提醒 | -| repeatInterval | `string` | `"month"` | 否 | 重复周期,默认 month 每月重复 | +| repeatInterval | `keyof RepeatInterval` | `"month"` | 否 | 重复周期,默认 month 每月重复 | | repeatEndTime | `number` | | 否 | 重复周期结束时间的 unix 时间戳,不填表示一直重复 | | complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | | success | `(result: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用成功的回调函数 | + +### RepeatInterval + +| 参数 | 说明 | +| --- | --- | +| day | 每天重复 | +| week | 每周重复 | +| month | 每月重复。该模式日期不能大于 28 日 | +| year | 每年重复 | diff --git a/docs/apis/device/clipboard/getClipboardData.md b/docs/apis/device/clipboard/getClipboardData.md index 10c836903af8..84e16c218a11 100644 --- a/docs/apis/device/clipboard/getClipboardData.md +++ b/docs/apis/device/clipboard/getClipboardData.md @@ -5,7 +5,7 @@ sidebar_label: getClipboardData 获取系统剪贴板内容 -支持情况: +支持情况: > H5: 部分实现 diff --git a/docs/apis/device/clipboard/setClipboardData.md b/docs/apis/device/clipboard/setClipboardData.md index ed8e5be7cc15..a15ef19e07d1 100644 --- a/docs/apis/device/clipboard/setClipboardData.md +++ b/docs/apis/device/clipboard/setClipboardData.md @@ -5,7 +5,7 @@ sidebar_label: setClipboardData 设置系统剪贴板的内容。调用成功后,会弹出 toast 提示"内容已复制",持续 1.5s -支持情况: +支持情况: > H5: 部分实现 diff --git a/docs/apis/device/compass/offCompassChange.md b/docs/apis/device/compass/offCompassChange.md index 2897820a2d0d..8c922ceb0a82 100644 --- a/docs/apis/device/compass/offCompassChange.md +++ b/docs/apis/device/compass/offCompassChange.md @@ -5,18 +5,18 @@ sidebar_label: offCompassChange 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/compass/wx.offCompassChange.html) ## 类型 ```tsx -(callback: (...args: any[]) => any) => void +(callback?: Callback) => void ``` ## 参数 | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `(...args: any[]) => any` | 罗盘数据变化事件的回调函数 | +| callback | `Callback` | 罗盘数据变化事件的回调函数 | diff --git a/docs/apis/device/compass/onCompassChange.md b/docs/apis/device/compass/onCompassChange.md index cbf9043c1898..1c2301d49e38 100644 --- a/docs/apis/device/compass/onCompassChange.md +++ b/docs/apis/device/compass/onCompassChange.md @@ -5,7 +5,7 @@ sidebar_label: onCompassChange 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 Taro.stopCompass 停止监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/compass/wx.onCompassChange.html) diff --git a/docs/apis/device/compass/startCompass.md b/docs/apis/device/compass/startCompass.md index d71cae4b9631..e630dda750a4 100644 --- a/docs/apis/device/compass/startCompass.md +++ b/docs/apis/device/compass/startCompass.md @@ -5,7 +5,7 @@ sidebar_label: startCompass 开始监听罗盘数据 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/compass/wx.startCompass.html) diff --git a/docs/apis/device/compass/stopCompass.md b/docs/apis/device/compass/stopCompass.md index d502ab21af90..3dc24a77146e 100644 --- a/docs/apis/device/compass/stopCompass.md +++ b/docs/apis/device/compass/stopCompass.md @@ -5,7 +5,7 @@ sidebar_label: stopCompass 停止监听罗盘数据 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/compass/wx.stopCompass.html) diff --git a/docs/apis/device/gyroscope/offGyroscopeChange.md b/docs/apis/device/gyroscope/offGyroscopeChange.md index af8fa5a4da91..eaf4095fca02 100644 --- a/docs/apis/device/gyroscope/offGyroscopeChange.md +++ b/docs/apis/device/gyroscope/offGyroscopeChange.md @@ -5,18 +5,18 @@ sidebar_label: offGyroscopeChange 取消监听陀螺仪数据变化事件。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/gyroscope/wx.offGyroscopeChange.html) ## 类型 ```tsx -(callback?: (...args: any[]) => any) => void +(callback?: Callback) => void ``` ## 参数 | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `(...args: any[]) => any` | 陀螺仪数据变化事件的回调函数 | +| callback | `Callback` | 陀螺仪数据变化事件的回调函数 | diff --git a/docs/apis/device/gyroscope/onGyroscopeChange.md b/docs/apis/device/gyroscope/onGyroscopeChange.md index c6acfa58f27f..c9fe43ce4f26 100644 --- a/docs/apis/device/gyroscope/onGyroscopeChange.md +++ b/docs/apis/device/gyroscope/onGyroscopeChange.md @@ -5,7 +5,7 @@ sidebar_label: onGyroscopeChange 监听陀螺仪数据变化事件。频率根据 Taro.startGyroscope() 的 interval 参数。可以使用 Taro.stopGyroscope() 停止监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/gyroscope/wx.onGyroscopeChange.html) diff --git a/docs/apis/device/gyroscope/stopGyroscope.md b/docs/apis/device/gyroscope/stopGyroscope.md index 2c55edfd1ac5..14e4b9d7337a 100644 --- a/docs/apis/device/gyroscope/stopGyroscope.md +++ b/docs/apis/device/gyroscope/stopGyroscope.md @@ -5,7 +5,7 @@ sidebar_label: stopGyroscope 停止监听陀螺仪数据。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/gyroscope/wx.stopGyroscope.html) diff --git a/docs/apis/device/iBeacon/getBeacons.md b/docs/apis/device/iBeacon/getBeacons.md index 9b06d102e8b0..0279b972576b 100644 --- a/docs/apis/device/iBeacon/getBeacons.md +++ b/docs/apis/device/iBeacon/getBeacons.md @@ -5,7 +5,7 @@ sidebar_label: getBeacons 获取所有已搜索到的 iBeacon 设备 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.getBeacons.html) diff --git a/docs/apis/device/iBeacon/offBeaconServiceChange.md b/docs/apis/device/iBeacon/offBeaconServiceChange.md index e6964ccea0e0..3eaa3cd0a579 100644 --- a/docs/apis/device/iBeacon/offBeaconServiceChange.md +++ b/docs/apis/device/iBeacon/offBeaconServiceChange.md @@ -5,7 +5,7 @@ sidebar_label: offBeaconServiceChange 取消监听 iBeacon 服务状态变化事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.offBeaconServiceChange.html) diff --git a/docs/apis/device/iBeacon/offBeaconUpdate.md b/docs/apis/device/iBeacon/offBeaconUpdate.md index c242d16dde40..a7dc98217901 100644 --- a/docs/apis/device/iBeacon/offBeaconUpdate.md +++ b/docs/apis/device/iBeacon/offBeaconUpdate.md @@ -5,7 +5,7 @@ sidebar_label: offBeaconUpdate 取消监听 iBeacon 设备更新事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.offBeaconUpdate.html) diff --git a/docs/apis/device/iBeacon/onBeaconServiceChange.md b/docs/apis/device/iBeacon/onBeaconServiceChange.md index 7ea88d936d29..cdc76c506802 100644 --- a/docs/apis/device/iBeacon/onBeaconServiceChange.md +++ b/docs/apis/device/iBeacon/onBeaconServiceChange.md @@ -5,7 +5,7 @@ sidebar_label: onBeaconServiceChange 监听 iBeacon 服务状态变化事件,仅能注册一个监听 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.onBeaconServiceChange.html) diff --git a/docs/apis/device/iBeacon/onBeaconUpdate.md b/docs/apis/device/iBeacon/onBeaconUpdate.md index e00a4780a089..879b807f43e9 100644 --- a/docs/apis/device/iBeacon/onBeaconUpdate.md +++ b/docs/apis/device/iBeacon/onBeaconUpdate.md @@ -5,7 +5,7 @@ sidebar_label: onBeaconUpdate 监听 iBeacon 设备更新事件,仅能注册一个监听 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.onBeaconUpdate.html) diff --git a/docs/apis/device/iBeacon/startBeaconDiscovery.md b/docs/apis/device/iBeacon/startBeaconDiscovery.md index 36ff49ad7aeb..2a2b386dd103 100644 --- a/docs/apis/device/iBeacon/startBeaconDiscovery.md +++ b/docs/apis/device/iBeacon/startBeaconDiscovery.md @@ -5,7 +5,7 @@ sidebar_label: startBeaconDiscovery 开始搜索附近的 iBeacon 设备 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.startBeaconDiscovery.html) @@ -23,13 +23,13 @@ sidebar_label: startBeaconDiscovery ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| uuids | `string[]` | 是 | iBeacon 设备广播的 uuid 列表 | -| complete | `(res: TaroGeneral.IBeaconError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.IBeaconError) => void` | 否 | 接口调用失败的回调函数 | -| ignoreBluetoothAvailable | `boolean` | 否 | 是否校验蓝牙开关,仅在 iOS 下有效 | -| success | `(res: TaroGeneral.IBeaconError) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| uuids | `string[]` | | 是 | iBeacon 设备广播的 uuid 列表 | +| complete | `(res: TaroGeneral.IBeaconError) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.IBeaconError) => void` | | 否 | 接口调用失败的回调函数 | +| ignoreBluetoothAvailable | `boolean` | `false` | 否 | 是否校验蓝牙开关,仅在 iOS 下有效 | +| success | `(res: TaroGeneral.IBeaconError) => void` | | 否 | 接口调用成功的回调函数 | ## 示例代码 diff --git a/docs/apis/device/iBeacon/stopBeaconDiscovery.md b/docs/apis/device/iBeacon/stopBeaconDiscovery.md index d06273794668..0eb653c62609 100644 --- a/docs/apis/device/iBeacon/stopBeaconDiscovery.md +++ b/docs/apis/device/iBeacon/stopBeaconDiscovery.md @@ -5,7 +5,7 @@ sidebar_label: stopBeaconDiscovery 停止搜索附近的 iBeacon 设备 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.stopBeaconDiscovery.html) diff --git a/docs/apis/device/keyboard/hideKeyboard.md b/docs/apis/device/keyboard/hideKeyboard.md index c9246551f34a..26b57a902c2d 100644 --- a/docs/apis/device/keyboard/hideKeyboard.md +++ b/docs/apis/device/keyboard/hideKeyboard.md @@ -5,7 +5,7 @@ sidebar_label: hideKeyboard 在input、textarea等focus拉起键盘之后,手动调用此接口收起键盘 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.hideKeyboard.html) diff --git a/docs/apis/device/keyboard/offKeyboardHeightChange.md b/docs/apis/device/keyboard/offKeyboardHeightChange.md index 958edea20171..9ded00f741c0 100644 --- a/docs/apis/device/keyboard/offKeyboardHeightChange.md +++ b/docs/apis/device/keyboard/offKeyboardHeightChange.md @@ -5,18 +5,18 @@ sidebar_label: offKeyboardHeightChange 取消监听键盘高度变化事件。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.offKeyboardHeightChange.html) ## 类型 ```tsx -(callback?: (...args: any[]) => any) => void +(callback?: Callback) => void ``` ## 参数 | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `(...args: any[]) => any` | 键盘高度变化事件的回调函数 | +| callback | `Callback` | 键盘高度变化事件的回调函数 | diff --git a/docs/apis/device/keyboard/onKeyboardHeightChange.md b/docs/apis/device/keyboard/onKeyboardHeightChange.md index f61403011329..fe7c4ad1c585 100644 --- a/docs/apis/device/keyboard/onKeyboardHeightChange.md +++ b/docs/apis/device/keyboard/onKeyboardHeightChange.md @@ -5,7 +5,7 @@ sidebar_label: onKeyboardHeightChange 监听键盘高度变化 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.onKeyboardHeightChange.html) diff --git a/docs/apis/device/memory/offMemoryWarning.md b/docs/apis/device/memory/offMemoryWarning.md index 56b087f39e52..dd306b72d141 100644 --- a/docs/apis/device/memory/offMemoryWarning.md +++ b/docs/apis/device/memory/offMemoryWarning.md @@ -5,14 +5,14 @@ sidebar_label: offMemoryWarning 取消监听内存不足告警事件。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/memory/wx.offMemoryWarning.html) ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/memory/onMemoryWarning.md b/docs/apis/device/memory/onMemoryWarning.md index f05c6b827a78..4b26c24f3857 100644 --- a/docs/apis/device/memory/onMemoryWarning.md +++ b/docs/apis/device/memory/onMemoryWarning.md @@ -7,7 +7,7 @@ sidebar_label: onMemoryWarning 当 iOS/Android 向小程序进程发出内存警告时,触发该事件。触发该事件不意味小程序被杀,大部分情况下仅仅是告警,开发者可在收到通知后回收一些不必要资源避免进一步加剧内存紧张。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/performance/wx.onMemoryWarning.html) diff --git a/docs/apis/device/motion/offDeviceMotionChange.md b/docs/apis/device/motion/offDeviceMotionChange.md index 380bd15b6208..d2d2ff32d13b 100644 --- a/docs/apis/device/motion/offDeviceMotionChange.md +++ b/docs/apis/device/motion/offDeviceMotionChange.md @@ -5,18 +5,18 @@ sidebar_label: offDeviceMotionChange 取消监听设备方向变化事件,参数为空,则取消所有的事件监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.offDeviceMotionChange.html) ## 类型 ```tsx -(callback?: (...args: any[]) => any) => void +(callback?: Callback) => void ``` ## 参数 | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `(...args: any[]) => any` | 设备方向变化事件的回调函数 | +| callback | `Callback` | 设备方向变化事件的回调函数 | diff --git a/docs/apis/device/motion/onDeviceMotionChange.md b/docs/apis/device/motion/onDeviceMotionChange.md index c342e7c85188..7cabac2f58fc 100644 --- a/docs/apis/device/motion/onDeviceMotionChange.md +++ b/docs/apis/device/motion/onDeviceMotionChange.md @@ -5,7 +5,7 @@ sidebar_label: onDeviceMotionChange 监听设备方向变化事件。频率根据 Taro.startDeviceMotionListening() 的 interval 参数。可以使用 Taro.stopDeviceMotionListening() 停止监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.onDeviceMotionChange.html) diff --git a/docs/apis/device/motion/startDeviceMotionListening.md b/docs/apis/device/motion/startDeviceMotionListening.md index d4f5f2dc592b..76df360c8bb7 100644 --- a/docs/apis/device/motion/startDeviceMotionListening.md +++ b/docs/apis/device/motion/startDeviceMotionListening.md @@ -5,7 +5,7 @@ sidebar_label: startDeviceMotionListening 开始监听设备方向的变化。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.startDeviceMotionListening.html) diff --git a/docs/apis/device/motion/stopDeviceMotionListening.md b/docs/apis/device/motion/stopDeviceMotionListening.md index 7b42e4cec8bb..f1aae4a537f2 100644 --- a/docs/apis/device/motion/stopDeviceMotionListening.md +++ b/docs/apis/device/motion/stopDeviceMotionListening.md @@ -5,7 +5,7 @@ sidebar_label: stopDeviceMotionListening 停止监听设备方向的变化。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.stopDeviceMotionListening.html) diff --git a/docs/apis/device/network/getLocalIPAddress.md b/docs/apis/device/network/getLocalIPAddress.md index 26919274923a..5e0deb1ce930 100644 --- a/docs/apis/device/network/getLocalIPAddress.md +++ b/docs/apis/device/network/getLocalIPAddress.md @@ -31,10 +31,11 @@ sidebar_label: getLocalIPAddress ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| localip | `string` | 本机局域网IP地址 | -| errMsg | `string` | 调用结果 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| localip | `string` | 是 | 本机局域网IP地址 | +| netmask | `string` | 否 | ,基础库 2.24.0 开始支持 | +| errMsg | `string` | 是 | 调用结果 | ## 示例代码 diff --git a/docs/apis/device/network/getNetworkType.md b/docs/apis/device/network/getNetworkType.md index 5abdd9c06dfd..489ac4b73224 100644 --- a/docs/apis/device/network/getNetworkType.md +++ b/docs/apis/device/network/getNetworkType.md @@ -5,7 +5,7 @@ sidebar_label: getNetworkType 获取网络类型。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.getNetworkType.html) @@ -31,10 +31,12 @@ sidebar_label: getNetworkType ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| networkType | `keyof NetworkType` | 网络类型 | -| errMsg | `string` | 调用结果 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| networkType | `keyof NetworkType` | 是 | 网络类型 | +| signalStrength | `number` | 否 | 信号强弱,单位 dbm | +| hasSystemProxy | `boolean` | 否 | 设备是否使用了网络代理 | +| errMsg | `string` | 是 | 调用结果 | ### NetworkType diff --git a/docs/apis/device/network/offNetworkStatusChange.md b/docs/apis/device/network/offNetworkStatusChange.md index 6318a458bf5b..aef103710a77 100644 --- a/docs/apis/device/network/offNetworkStatusChange.md +++ b/docs/apis/device/network/offNetworkStatusChange.md @@ -5,7 +5,7 @@ sidebar_label: offNetworkStatusChange 取消监听网络状态变化事件,参数为空,则取消所有的事件监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.offNetworkStatusChange.html) diff --git a/docs/apis/device/network/offNetworkWeakChange.md b/docs/apis/device/network/offNetworkWeakChange.md index 4ecc9a380744..81b9c9480423 100644 --- a/docs/apis/device/network/offNetworkWeakChange.md +++ b/docs/apis/device/network/offNetworkWeakChange.md @@ -5,14 +5,14 @@ sidebar_label: offNetworkWeakChange 取消监听弱网状态变化事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.offNetworkWeakChange.html) ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/network/onNetworkStatusChange.md b/docs/apis/device/network/onNetworkStatusChange.md index 5d8addd64b43..61c26b9383cb 100644 --- a/docs/apis/device/network/onNetworkStatusChange.md +++ b/docs/apis/device/network/onNetworkStatusChange.md @@ -5,7 +5,7 @@ sidebar_label: onNetworkStatusChange 监听网络状态变化。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.onNetworkStatusChange.html) diff --git a/docs/apis/device/network/onNetworkWeakChange.md b/docs/apis/device/network/onNetworkWeakChange.md index ff75cc54e3c0..a3e4ed183771 100644 --- a/docs/apis/device/network/onNetworkWeakChange.md +++ b/docs/apis/device/network/onNetworkWeakChange.md @@ -5,7 +5,7 @@ sidebar_label: onNetworkWeakChange 监听弱网状态变化事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.onNetworkWeakChange.html) diff --git a/docs/apis/device/nfc/IsoDep.md b/docs/apis/device/nfc/IsoDep.md index d34682cf8b71..73332b7f0450 100644 --- a/docs/apis/device/nfc/IsoDep.md +++ b/docs/apis/device/nfc/IsoDep.md @@ -204,7 +204,7 @@ IsoDep 标签 | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| transceive | `ArrayBuffer` | 是 | 需要传递的二进制数据 | +| data | `ArrayBuffer` | 是 | 需要传递的二进制数据 | | complete | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/nfc/MifareClassic.md b/docs/apis/device/nfc/MifareClassic.md index 9b1153aad58d..66ae50db7af9 100644 --- a/docs/apis/device/nfc/MifareClassic.md +++ b/docs/apis/device/nfc/MifareClassic.md @@ -172,7 +172,7 @@ MifareClassic 标签 | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| transceive | `ArrayBuffer` | 是 | 需要传递的二进制数据 | +| data | `ArrayBuffer` | 是 | 需要传递的二进制数据 | | complete | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/nfc/MifareUltralight.md b/docs/apis/device/nfc/MifareUltralight.md index 12c15c943708..809e19541f17 100644 --- a/docs/apis/device/nfc/MifareUltralight.md +++ b/docs/apis/device/nfc/MifareUltralight.md @@ -172,7 +172,7 @@ MifareUltralight 标签 | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| transceive | `ArrayBuffer` | 是 | 需要传递的二进制数据 | +| data | `ArrayBuffer` | 是 | 需要传递的二进制数据 | | complete | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/nfc/NFCAdapter.md b/docs/apis/device/nfc/NFCAdapter.md index 26d023f01ea6..939add26e157 100644 --- a/docs/apis/device/nfc/NFCAdapter.md +++ b/docs/apis/device/nfc/NFCAdapter.md @@ -116,7 +116,7 @@ NFC 实例 > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/nfc/NFCAdapter.offDiscovered.html) ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` | 参数 | 类型 | 说明 | @@ -193,7 +193,7 @@ NFC 实例 | --- | --- | :---: | --- | | techs | `string[]` | 是 | tech 数组,用于匹配NFC卡片具体可以使用什么标准(NfcA等实例)处理 | | messages | `NdefMessage[]` | 是 | NdefMessage 数组,消息格式为 {id: ArrayBuffer, type: ArrayBuffer, payload: ArrayBuffer} | -| uid | `ArrayBuffer` | 否 | NFC标签的UID
API 支持度: tt | +| id | `ArrayBuffer` | 否 | NFC标签的UID
API 支持度: tt | #### NdefMessage diff --git a/docs/apis/device/nfc/Ndef.md b/docs/apis/device/nfc/Ndef.md index c8542eeab223..1ef553808207 100644 --- a/docs/apis/device/nfc/Ndef.md +++ b/docs/apis/device/nfc/Ndef.md @@ -186,9 +186,9 @@ Ndef 标签 | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| uris | `string[]` | 是 | uri 数组 | -| texts | `string[]` | 是 | text 数组 | -| records | `record[]` | 是 | 二进制对象数组, 需要指明 id, type 以及 payload (均为 ArrayBuffer 类型) | +| uris | `string[]` | 否 | uri 数组 | +| texts | `string[]` | 否 | text 数组 | +| records | `record[]` | 否 | 二进制对象数组, 需要指明 id, type 以及 payload (均为 ArrayBuffer 类型) | | complete | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用失败的回调函数 | | success | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/nfc/NfcA.md b/docs/apis/device/nfc/NfcA.md index 6581348df16f..2df956d0246b 100644 --- a/docs/apis/device/nfc/NfcA.md +++ b/docs/apis/device/nfc/NfcA.md @@ -236,7 +236,7 @@ NfcA 标签 | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| transceive | `ArrayBuffer` | 是 | 需要传递的二进制数据 | +| data | `ArrayBuffer` | 是 | 需要传递的二进制数据 | | complete | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/nfc/NfcB.md b/docs/apis/device/nfc/NfcB.md index 12f49c2aba15..6d2d8bc820e4 100644 --- a/docs/apis/device/nfc/NfcB.md +++ b/docs/apis/device/nfc/NfcB.md @@ -172,7 +172,7 @@ NfcB 标签 | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| transceive | `ArrayBuffer` | 是 | 需要传递的二进制数据 | +| data | `ArrayBuffer` | 是 | 需要传递的二进制数据 | | complete | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/nfc/NfcF.md b/docs/apis/device/nfc/NfcF.md index 6fb7d65d3448..4e869f6527a9 100644 --- a/docs/apis/device/nfc/NfcF.md +++ b/docs/apis/device/nfc/NfcF.md @@ -172,7 +172,7 @@ NfcF 标签 | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| transceive | `ArrayBuffer` | 是 | 需要传递的二进制数据 | +| data | `ArrayBuffer` | 是 | 需要传递的二进制数据 | | complete | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/nfc/NfcV.md b/docs/apis/device/nfc/NfcV.md index a5194646c426..0523bf4cf6f0 100644 --- a/docs/apis/device/nfc/NfcV.md +++ b/docs/apis/device/nfc/NfcV.md @@ -172,7 +172,7 @@ NfcV 标签 | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| transceive | `ArrayBuffer` | 是 | 需要传递的二进制数据 | +| data | `ArrayBuffer` | 是 | 需要传递的二进制数据 | | complete | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.NFCError) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/nfc/offHCEMessage.md b/docs/apis/device/nfc/offHCEMessage.md index 13a87cec3448..020fc9096710 100644 --- a/docs/apis/device/nfc/offHCEMessage.md +++ b/docs/apis/device/nfc/offHCEMessage.md @@ -12,11 +12,11 @@ sidebar_label: offHCEMessage ## 类型 ```tsx -(callback: (...args: any[]) => any) => void +(callback: Callback) => void ``` ## 参数 | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `(...args: any[]) => any` | 接收 NFC 设备消息事件的回调函数 | +| callback | `Callback` | 接收 NFC 设备消息事件的回调函数 | diff --git a/docs/apis/device/phone/makePhoneCall.md b/docs/apis/device/phone/makePhoneCall.md index ee7f2865d06f..936f4d208bf2 100644 --- a/docs/apis/device/phone/makePhoneCall.md +++ b/docs/apis/device/phone/makePhoneCall.md @@ -5,7 +5,7 @@ sidebar_label: makePhoneCall 拨打电话 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/phone/wx.makePhoneCall.html) diff --git a/docs/apis/device/scan/scanCode.md b/docs/apis/device/scan/scanCode.md index 30d77a8e2b8f..f6a2a522a0cc 100644 --- a/docs/apis/device/scan/scanCode.md +++ b/docs/apis/device/scan/scanCode.md @@ -5,7 +5,7 @@ sidebar_label: scanCode 调起客户端扫码界面,扫码成功后返回对应的结果 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/scan/wx.scanCode.html) @@ -23,13 +23,13 @@ sidebar_label: scanCode ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| onlyFromCamera | `boolean` | 否 | 是否只能从相机扫码,不允许从相册选择图片 | -| scanType | `(keyof ScanType)[]` | 否 | 扫码类型 | -| success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| onlyFromCamera | `boolean` | `false` | 否 | 是否只能从相机扫码,不允许从相册选择图片 | +| scanType | `(keyof ScanType)[]` | | 否 | 扫码类型 | +| success | `(result: SuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | ### SuccessCallbackResult @@ -88,7 +88,7 @@ Taro.scanCode({ console.log(res) } }) - // 只允许从相机扫码 +// 只允许从相机扫码 Taro.scanCode({ onlyFromCamera: true, success: (res) => { diff --git a/docs/apis/device/screen/getScreenBrightness.md b/docs/apis/device/screen/getScreenBrightness.md index 7b499fb9b4eb..d8296c253e98 100644 --- a/docs/apis/device/screen/getScreenBrightness.md +++ b/docs/apis/device/screen/getScreenBrightness.md @@ -8,7 +8,7 @@ sidebar_label: getScreenBrightness **说明** - 若安卓系统设置中开启了自动调节亮度功能,则屏幕亮度会根据光线自动调整,该接口仅能获取自动调节亮度之前的值,而非实时的亮度值。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.getScreenBrightness.html) diff --git a/docs/apis/device/screen/getScreenRecordingState.md b/docs/apis/device/screen/getScreenRecordingState.md index 4424975ac138..7eada594694e 100644 --- a/docs/apis/device/screen/getScreenRecordingState.md +++ b/docs/apis/device/screen/getScreenRecordingState.md @@ -33,11 +33,21 @@ sidebar_label: getScreenRecordingState | 参数 | 说明 | | --- | --- | -| start | 开始录屏 | -| stop | 结束录屏 | +| on | 开启 | +| off | 关闭 | ### SuccessCallbackResult | 参数 | 类型 | 说明 | | --- | --- | --- | | state | `keyof ScreenRecordingState` | 录屏状态 | + +## 示例代码 + +```tsx +Taro.getScreenRecordingState({ + success: function (res) { + console.log(res.state) + }, +}) +``` diff --git a/docs/apis/device/screen/offScreenRecordingStateChanged.md b/docs/apis/device/screen/offScreenRecordingStateChanged.md index 4cd4a985c0e8..8a9753fd21b3 100644 --- a/docs/apis/device/screen/offScreenRecordingStateChanged.md +++ b/docs/apis/device/screen/offScreenRecordingStateChanged.md @@ -12,7 +12,7 @@ sidebar_label: offScreenRecordingStateChanged ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/screen/offUserCaptureScreen.md b/docs/apis/device/screen/offUserCaptureScreen.md index d79a4b8132df..03f1e3b40990 100644 --- a/docs/apis/device/screen/offUserCaptureScreen.md +++ b/docs/apis/device/screen/offUserCaptureScreen.md @@ -5,7 +5,7 @@ sidebar_label: offUserCaptureScreen 用户主动截屏事件。取消事件监听。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.offUserCaptureScreen.html) diff --git a/docs/apis/device/screen/onScreenRecordingStateChanged.md b/docs/apis/device/screen/onScreenRecordingStateChanged.md index 183acb628158..2c09769e6cc9 100644 --- a/docs/apis/device/screen/onScreenRecordingStateChanged.md +++ b/docs/apis/device/screen/onScreenRecordingStateChanged.md @@ -39,3 +39,13 @@ sidebar_label: onScreenRecordingStateChanged | 参数 | 类型 | 说明 | | --- | --- | --- | | state | `keyof ScreenRecordingState` | 录屏状态 | + +## 示例代码 + +```tsx +// 监听用户录屏事件 +const handler = function (res) { + console.log(res.state) +} +Taro.onScreenRecordingStateChanged(handler) +``` diff --git a/docs/apis/device/screen/onUserCaptureScreen.md b/docs/apis/device/screen/onUserCaptureScreen.md index 32ce3f9ce30d..42734737f6bd 100644 --- a/docs/apis/device/screen/onUserCaptureScreen.md +++ b/docs/apis/device/screen/onUserCaptureScreen.md @@ -5,7 +5,7 @@ sidebar_label: onUserCaptureScreen 监听用户主动截屏事件,用户使用系统截屏按键截屏时触发此事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.onUserCaptureScreen.html) diff --git a/docs/apis/device/screen/setKeepScreenOn.md b/docs/apis/device/screen/setKeepScreenOn.md index 5a19ba600bc3..c2ce451e7fc9 100644 --- a/docs/apis/device/screen/setKeepScreenOn.md +++ b/docs/apis/device/screen/setKeepScreenOn.md @@ -5,7 +5,7 @@ sidebar_label: setKeepScreenOn 设置是否保持常亮状态。仅在当前小程序生效,离开小程序后设置失效。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.setKeepScreenOn.html) diff --git a/docs/apis/device/screen/setScreenBrightness.md b/docs/apis/device/screen/setScreenBrightness.md index 1377b64867a4..1f2ff2d613ba 100644 --- a/docs/apis/device/screen/setScreenBrightness.md +++ b/docs/apis/device/screen/setScreenBrightness.md @@ -5,7 +5,7 @@ sidebar_label: setScreenBrightness 设置屏幕亮度。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.setScreenBrightness.html) diff --git a/docs/apis/device/screen/setVisualEffectOnCapture.md b/docs/apis/device/screen/setVisualEffectOnCapture.md index af80b773d2c8..0681a743abf8 100644 --- a/docs/apis/device/screen/setVisualEffectOnCapture.md +++ b/docs/apis/device/screen/setVisualEffectOnCapture.md @@ -5,7 +5,7 @@ sidebar_label: setVisualEffectOnCapture 设置截屏/录屏时屏幕表现,仅支持在 Android 端调用 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.setVisualEffectOnCapture.html) diff --git a/docs/apis/device/sms/sendSms.md b/docs/apis/device/sms/sendSms.md index 9d636eb033b9..5638c06d9209 100644 --- a/docs/apis/device/sms/sendSms.md +++ b/docs/apis/device/sms/sendSms.md @@ -5,7 +5,7 @@ sidebar_label: sendSms 拉起手机发送短信界面 -支持情况: +支持情况: > [参考文档](declare module '../../index') diff --git a/docs/apis/device/vibrate/vibrateLong.md b/docs/apis/device/vibrate/vibrateLong.md index a4ab34979a05..158e6fda6175 100644 --- a/docs/apis/device/vibrate/vibrateLong.md +++ b/docs/apis/device/vibrate/vibrateLong.md @@ -5,7 +5,7 @@ sidebar_label: vibrateLong 使手机发生较长时间的振动(400ms) -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/vibrate/wx.vibrateLong.html) diff --git a/docs/apis/device/vibrate/vibrateShort.md b/docs/apis/device/vibrate/vibrateShort.md index 2b486cbbeb24..831628dbab3a 100644 --- a/docs/apis/device/vibrate/vibrateShort.md +++ b/docs/apis/device/vibrate/vibrateShort.md @@ -5,11 +5,9 @@ sidebar_label: vibrateShort 使手机发生较短时间的振动(15 ms)。仅在 iPhone `7 / 7 Plus` 以上及 Android 机型生效 -支持情况: +仅微信小程序平台支持 type 参数 -> H5: 不支持 type 参数 -> -> React Native: 不支持 type 参数 +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/vibrate/wx.vibrateShort.html) @@ -29,7 +27,7 @@ sidebar_label: vibrateShort | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| type | "heavy" or "medium" or "light" | 是 | 震动强度类型,有效值为:heavy、medium、light | +| type | "heavy" or "medium" or "light" | 否 | 震动强度类型,有效值为:heavy、medium、light | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/device/wifi/connectWifi.md b/docs/apis/device/wifi/connectWifi.md index ab69ff77abe2..3798e96f0aa8 100644 --- a/docs/apis/device/wifi/connectWifi.md +++ b/docs/apis/device/wifi/connectWifi.md @@ -5,7 +5,7 @@ sidebar_label: connectWifi 连接 Wi-Fi。若已知 Wi-Fi 信息,可以直接利用该接口连接。仅 Android 与 iOS 11 以上版本支持。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.connectWifi.html) @@ -23,14 +23,16 @@ sidebar_label: connectWifi ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| SSID | `string` | 是 | Wi-Fi 设备 SSID | -| password | `string` | 是 | Wi-Fi 设备密码 | -| BSSID | `string` | 否 | Wi-Fi 设备 BSSID | -| complete | `(res: TaroGeneral.WifiError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.WifiError) => void` | 否 | 接口调用失败的回调函数 | -| success | `(res: TaroGeneral.WifiError) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| SSID | `string` | | 是 | Wi-Fi 设备 SSID | +| password | `string` | | 是 | Wi-Fi 设备密码 | +| BSSID | `string` | | 否 | Wi-Fi 设备 BSSID | +| maunal | `boolean` | `false` | 否 | 跳转到系统设置页进行连接 | +| partialInfo | `boolean` | `false` | 否 | 是否需要返回部分 Wi-Fi 信息,仅安卓生效 | +| complete | `(res: TaroGeneral.WifiError) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.WifiError) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.WifiError) => void` | | 否 | 接口调用成功的回调函数 | ## 示例代码 diff --git a/docs/apis/device/wifi/getConnectedWifi.md b/docs/apis/device/wifi/getConnectedWifi.md index df86586e36d6..ab9dec246945 100644 --- a/docs/apis/device/wifi/getConnectedWifi.md +++ b/docs/apis/device/wifi/getConnectedWifi.md @@ -5,7 +5,7 @@ sidebar_label: getConnectedWifi 获取已连接中的 Wi-Fi 信息。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getConnectedWifi.html) @@ -23,11 +23,12 @@ sidebar_label: getConnectedWifi ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| complete | `(res: TaroGeneral.WifiError) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.WifiError) => void` | 否 | 接口调用失败的回调函数 | -| success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| partialInfo | `boolean` | `false` | 否 | 是否需要返回部分 Wi-Fi 信息 | +| complete | `(res: TaroGeneral.WifiError) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.WifiError) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(result: SuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | ### SuccessCallbackResult diff --git a/docs/apis/device/wifi/getWifiList.md b/docs/apis/device/wifi/getWifiList.md index 617a75912a0c..fa1c22c0710d 100644 --- a/docs/apis/device/wifi/getWifiList.md +++ b/docs/apis/device/wifi/getWifiList.md @@ -7,7 +7,7 @@ sidebar_label: getWifiList iOS 将跳转到系统的 Wi-Fi 界面,Android 不会跳转。 iOS 11.0 及 iOS 11.1 两个版本因系统问题,该方法失效。但在 iOS 11.2 中已修复。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getWifiList.html) diff --git a/docs/apis/device/wifi/offGetWifiList.md b/docs/apis/device/wifi/offGetWifiList.md index 3990b13917bf..6d1062eddc5c 100644 --- a/docs/apis/device/wifi/offGetWifiList.md +++ b/docs/apis/device/wifi/offGetWifiList.md @@ -5,14 +5,14 @@ sidebar_label: offGetWifiList 取消监听获取到 Wi-Fi 列表数据事件。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offGetWifiList.html) ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/wifi/offWifiConnected.md b/docs/apis/device/wifi/offWifiConnected.md index fb62ba4fa737..ecbdfb2d834e 100644 --- a/docs/apis/device/wifi/offWifiConnected.md +++ b/docs/apis/device/wifi/offWifiConnected.md @@ -5,14 +5,14 @@ sidebar_label: offWifiConnected 取消监听连接上 Wi-Fi 的事件。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offWifiConnected.html) ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/wifi/offWifiConnectedWithPartialInfo.md b/docs/apis/device/wifi/offWifiConnectedWithPartialInfo.md index 42f9cbfc9f67..0039bdda2df3 100644 --- a/docs/apis/device/wifi/offWifiConnectedWithPartialInfo.md +++ b/docs/apis/device/wifi/offWifiConnectedWithPartialInfo.md @@ -12,7 +12,7 @@ sidebar_label: offWifiConnectedWithPartialInfo ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/device/wifi/onGetWifiList.md b/docs/apis/device/wifi/onGetWifiList.md index 5306c31dcf1a..761952a01b30 100644 --- a/docs/apis/device/wifi/onGetWifiList.md +++ b/docs/apis/device/wifi/onGetWifiList.md @@ -5,7 +5,7 @@ sidebar_label: onGetWifiList 监听获取到 Wi-Fi 列表数据事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.onGetWifiList.html) diff --git a/docs/apis/device/wifi/onWifiConnected.md b/docs/apis/device/wifi/onWifiConnected.md index 3f06a44a870a..69720f81e1e7 100644 --- a/docs/apis/device/wifi/onWifiConnected.md +++ b/docs/apis/device/wifi/onWifiConnected.md @@ -5,7 +5,7 @@ sidebar_label: onWifiConnected 监听连接上 Wi-Fi 的事件。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.onWifiConnected.html) diff --git a/docs/apis/device/wifi/setWifiList.md b/docs/apis/device/wifi/setWifiList.md index e9dff5ca9ce4..515dda3bae6f 100644 --- a/docs/apis/device/wifi/setWifiList.md +++ b/docs/apis/device/wifi/setWifiList.md @@ -10,7 +10,7 @@ sidebar_label: setWifiList - 此时客户端会挂起,等待小程序设置 Wi-Fi 信息,请务必尽快调用该接口,若无数据请传入一个空数组。 - 有可能随着周边 Wi-Fi 列表的刷新,单个流程内收到多次带有存在重复的 Wi-Fi 列表的回调。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.setWifiList.html) diff --git a/docs/apis/device/wifi/startWifi.md b/docs/apis/device/wifi/startWifi.md index 6d30add96c43..8bb8e0cbea27 100644 --- a/docs/apis/device/wifi/startWifi.md +++ b/docs/apis/device/wifi/startWifi.md @@ -5,7 +5,7 @@ sidebar_label: startWifi 初始化 Wi-Fi 模块。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.startWifi.html) diff --git a/docs/apis/device/wifi/stopWifi.md b/docs/apis/device/wifi/stopWifi.md index ea6bfe2ee397..d86084c7e6a0 100644 --- a/docs/apis/device/wifi/stopWifi.md +++ b/docs/apis/device/wifi/stopWifi.md @@ -5,7 +5,7 @@ sidebar_label: stopWifi 关闭 Wi-Fi 模块。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.stopWifi.html) diff --git a/docs/apis/files/FileSystemManager.md b/docs/apis/files/FileSystemManager.md index 2bc75a2431ce..563caf60532c 100644 --- a/docs/apis/files/FileSystemManager.md +++ b/docs/apis/files/FileSystemManager.md @@ -15,7 +15,7 @@ sidebar_label: FileSystemManager 判断文件/目录是否存在 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.access.html) @@ -31,7 +31,7 @@ sidebar_label: FileSystemManager [FileSystemManager.access](#access) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.accessSync.html) @@ -47,7 +47,7 @@ sidebar_label: FileSystemManager 在文件结尾追加内容 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFile.html) @@ -63,7 +63,7 @@ sidebar_label: FileSystemManager [FileSystemManager.appendFile](#appendfile) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFileSync.html) @@ -113,7 +113,7 @@ sidebar_label: FileSystemManager 复制文件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFile.html) @@ -129,7 +129,7 @@ sidebar_label: FileSystemManager [FileSystemManager.copyFile](#copyfile) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFileSync.html) @@ -210,7 +210,7 @@ sidebar_label: FileSystemManager 获取该小程序下的 `本地临时文件` 或 `本地缓存文件` 信息 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.getFileInfo.html) @@ -226,7 +226,7 @@ sidebar_label: FileSystemManager 获取该小程序下已保存的本地缓存文件列表 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.getSavedFileList.html) @@ -242,7 +242,7 @@ sidebar_label: FileSystemManager 创建目录 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdir.html) @@ -258,7 +258,7 @@ sidebar_label: FileSystemManager [FileSystemManager.mkdir](#mkdir) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdirSync.html) @@ -355,7 +355,7 @@ sidebar_label: FileSystemManager 读取目录内文件列表 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdir.html) @@ -371,7 +371,7 @@ sidebar_label: FileSystemManager [FileSystemManager.readdir](#readdir) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdirSync.html) @@ -387,7 +387,7 @@ sidebar_label: FileSystemManager 读取本地文件内容 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFile.html) @@ -403,7 +403,7 @@ sidebar_label: FileSystemManager [FileSystemManager.readFile](#readfile) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFileSync.html) @@ -454,7 +454,7 @@ sidebar_label: FileSystemManager 删除该小程序下已保存的本地缓存文件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.removeSavedFile.html) @@ -470,7 +470,7 @@ sidebar_label: FileSystemManager 重命名文件。可以把文件从 oldPath 移动到 newPath -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rename.html) @@ -486,7 +486,7 @@ sidebar_label: FileSystemManager [FileSystemManager.rename](#rename) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.renameSync.html) @@ -536,7 +536,7 @@ sidebar_label: FileSystemManager 保存临时文件到本地。此接口会移动临时文件,因此调用成功后,tempFilePath 将不可用。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFile.html) @@ -552,7 +552,7 @@ sidebar_label: FileSystemManager [FileSystemManager.saveFile](#savefile) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFileSync.html) @@ -569,7 +569,7 @@ sidebar_label: FileSystemManager 获取文件 Stats 对象 -支持情况: +支持情况: ```tsx (option: StatOption) => void @@ -583,7 +583,7 @@ sidebar_label: FileSystemManager [FileSystemManager.stat](#stat) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.statSync.html) @@ -600,7 +600,7 @@ sidebar_label: FileSystemManager 对文件内容进行截断操作 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncate.html) @@ -616,7 +616,7 @@ sidebar_label: FileSystemManager 对文件内容进行截断操作 ([truncate](#truncate) 的同步版本) -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncateSync.html) @@ -632,7 +632,7 @@ sidebar_label: FileSystemManager 删除文件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlink.html) @@ -648,7 +648,7 @@ sidebar_label: FileSystemManager [FileSystemManager.unlink](#unlink) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlinkSync.html) @@ -664,7 +664,7 @@ sidebar_label: FileSystemManager 解压文件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unzip.html) @@ -696,7 +696,7 @@ sidebar_label: FileSystemManager 写文件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFile.html) @@ -712,7 +712,7 @@ sidebar_label: FileSystemManager [FileSystemManager.writeFile](#writefile) 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFileSync.html) @@ -787,8 +787,8 @@ sidebar_label: FileSystemManager | --- | --- | :---: | --- | | data | string or ArrayBuffer | 是 | 要追加的文本或二进制数据 | | filePath | `string` | 是 | 要追加内容的文件路径 | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | encoding | `keyof Encoding` | 否 | 指定写入文件的字符编码 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(result: AppendFileFailCallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | @@ -816,12 +816,13 @@ sidebar_label: FileSystemManager ### getFileInfoOption -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| filePath | `string` | 是 | 要读取的文件路径 | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(result: GetFileInfoFailCallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| success | `(result: GetFileInfoSuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| filePath | `string` | | 是 | 要读取的文件路径 | +| digestAlgorithm | "md5" or "sha1" | `'md5'` | 否 | 计算文件摘要的算法 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(result: GetFileInfoFailCallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(result: GetFileInfoSuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | ### GetFileInfoFailCallbackResult @@ -831,10 +832,11 @@ sidebar_label: FileSystemManager ### GetFileInfoSuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| size | `number` | 文件大小,以字节为单位 | -| errMsg | `string` | 调用结果 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| size | `number` | 是 | 文件大小,以字节为单位 | +| digest | `string` | 否 | 按照传入的 digestAlgorithm 计算得出的的文件摘要 | +| errMsg | `string` | 是 | 调用结果 | ### getSavedFileListOption @@ -863,13 +865,13 @@ sidebar_label: FileSystemManager ### MkdirOption -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| dirPath | `string` | 是 | 创建的目录路径 | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(result: MkdirFailCallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| recursive | `boolean` | 否 | 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 | -| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| dirPath | `string` | | 是 | 创建的目录路径 | +| recursive | `boolean` | `false` | 否 | 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。
如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(result: MkdirFailCallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用成功的回调函数 | ### MkdirFailCallbackResult @@ -994,6 +996,7 @@ FailCallbackResult | SuccessCallbackResult | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | | filePath | `string` | 是 | 需要删除的文件路径 | +| apFilePath | `string` | 否 | 本地缓存文件路径
API 支持度: alipay | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(result: RemoveSavedFileFailCallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | @@ -1387,51 +1390,51 @@ FailCallbackResult | SuccessCallbackResult ## API 支持度 -| API | 微信小程序 | 抖音小程序 | H5 | React Native | Harmony | -| :---: | :---: | :---: | :---: | :---: | :---: | -| FileSystemManager | ✔️ | ✔️ | | | | -| FileSystemManager.access | ✔️ | ✔️ | | | | -| FileSystemManager.accessSync | ✔️ | ✔️ | | | | -| FileSystemManager.appendFile | ✔️ | | | | | -| FileSystemManager.appendFileSync | ✔️ | | | | | -| FileSystemManager.close | ✔️ | | | | | -| FileSystemManager.closeSync | ✔️ | | | | | -| FileSystemManager.copyFile | ✔️ | ✔️ | | | | -| FileSystemManager.copyFileSync | ✔️ | ✔️ | | | | -| FileSystemManager.fstat | ✔️ | | | | | -| FileSystemManager.fstatSync | ✔️ | | | | | -| FileSystemManager.ftruncate | ✔️ | | | | | -| FileSystemManager.ftruncateSync | ✔️ | | | | | -| FileSystemManager.getFileInfo | ✔️ | ✔️ | | | | -| FileSystemManager.getSavedFileList | ✔️ | ✔️ | | | | -| FileSystemManager.mkdir | ✔️ | ✔️ | | | | -| FileSystemManager.mkdirSync | ✔️ | ✔️ | | | | -| FileSystemManager.open | ✔️ | | | | | -| FileSystemManager.openSync | ✔️ | | | | | -| FileSystemManager.read | ✔️ | | | | | -| FileSystemManager.readCompressedFile | ✔️ | | | | | -| FileSystemManager.readCompressedFileSync | ✔️ | | | | | -| FileSystemManager.readdir | ✔️ | ✔️ | | | | -| FileSystemManager.readdirSync | ✔️ | ✔️ | | | | -| FileSystemManager.readFile | ✔️ | ✔️ | | | | -| FileSystemManager.readFileSync | ✔️ | ✔️ | | | | -| FileSystemManager.readSync | ✔️ | | | | | -| FileSystemManager.readZipEntry | ✔️ | | | | | -| FileSystemManager.removeSavedFile | ✔️ | | | | | -| FileSystemManager.rename | ✔️ | ✔️ | | | | -| FileSystemManager.renameSync | ✔️ | ✔️ | | | | -| FileSystemManager.rmdir | ✔️ | ✔️ | | | | -| FileSystemManager.rmdirSync | ✔️ | ✔️ | | | | -| FileSystemManager.saveFile | ✔️ | ✔️ | | | | -| FileSystemManager.saveFileSync | ✔️ | ✔️ | | | | -| FileSystemManager.stat | ✔️ | | | | | -| FileSystemManager.statSync | ✔️ | ✔️ | | | | -| FileSystemManager.truncate | ✔️ | | | | | -| FileSystemManager.truncateSync | ✔️ | | | | | -| FileSystemManager.unlink | ✔️ | ✔️ | | | | -| FileSystemManager.unlinkSync | ✔️ | ✔️ | | | | -| FileSystemManager.unzip | ✔️ | ✔️ | | | | -| FileSystemManager.write | ✔️ | | | | | -| FileSystemManager.writeFile | ✔️ | ✔️ | | | | -| FileSystemManager.writeFileSync | ✔️ | ✔️ | | | | -| FileSystemManager.writeSync | ✔️ | | | | | +| API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| FileSystemManager | ✔️ | | | ✔️ | | | | | | +| FileSystemManager.access | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.accessSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.appendFile | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.appendFileSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.close | ✔️ | | | | | | | | | +| FileSystemManager.closeSync | ✔️ | | | | | | | | | +| FileSystemManager.copyFile | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.copyFileSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.fstat | ✔️ | | | | | | | | | +| FileSystemManager.fstatSync | ✔️ | | | | | | | | | +| FileSystemManager.ftruncate | ✔️ | | | | | | | | | +| FileSystemManager.ftruncateSync | ✔️ | | | | | | | | | +| FileSystemManager.getFileInfo | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.getSavedFileList | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.mkdir | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.mkdirSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.open | ✔️ | | | | | | | | | +| FileSystemManager.openSync | ✔️ | | | | | | | | | +| FileSystemManager.read | ✔️ | | | | | | | | | +| FileSystemManager.readCompressedFile | ✔️ | | | | | | | | | +| FileSystemManager.readCompressedFileSync | ✔️ | | | | | | | | | +| FileSystemManager.readdir | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.readdirSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.readFile | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.readFileSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.readSync | ✔️ | | | | | | | | | +| FileSystemManager.readZipEntry | ✔️ | | | | | | | | | +| FileSystemManager.removeSavedFile | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.rename | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.renameSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.rmdir | ✔️ | | | ✔️ | | | | | | +| FileSystemManager.rmdirSync | ✔️ | | | ✔️ | | | | | | +| FileSystemManager.saveFile | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.saveFileSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.stat | ✔️ | ✔️ | ✔️ | | ✔️ | ✔️ | | | | +| FileSystemManager.statSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.truncate | ✔️ | | | ✔️ | | | | | | +| FileSystemManager.truncateSync | ✔️ | | | ✔️ | | | | | | +| FileSystemManager.unlink | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.unlinkSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.unzip | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.write | ✔️ | | | | | | | | | +| FileSystemManager.writeFile | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.writeFileSync | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| FileSystemManager.writeSync | ✔️ | | | | | | | | | diff --git a/docs/apis/files/Stats.md b/docs/apis/files/Stats.md index af6d7b816853..e8f95ea64ba5 100644 --- a/docs/apis/files/Stats.md +++ b/docs/apis/files/Stats.md @@ -22,7 +22,7 @@ sidebar_label: Stats 判断当前文件是否一个目录 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.isDirectory.html) @@ -34,7 +34,7 @@ sidebar_label: Stats 判断当前文件是否一个普通文件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.isFile.html) @@ -44,8 +44,8 @@ sidebar_label: Stats ## API 支持度 -| API | 微信小程序 | H5 | React Native | Harmony | -| :---: | :---: | :---: | :---: | :---: | -| Stats | ✔️ | | | | -| Stats.isDirectory | ✔️ | | | | -| Stats.isFile | ✔️ | | | | +| API | 微信小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| Stats | ✔️ | | | | | | | | +| Stats.isDirectory | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| Stats.isFile | ✔️ | | ✔️ | ✔️ | ✔️ | | | | diff --git a/docs/apis/files/getFileInfo.md b/docs/apis/files/getFileInfo.md index ad210a09fb15..521e5371512b 100644 --- a/docs/apis/files/getFileInfo.md +++ b/docs/apis/files/getFileInfo.md @@ -5,7 +5,7 @@ sidebar_label: getFileInfo 获取该小程序下的 本地临时文件 或 本地缓存文件 信息 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.getFileInfo.html) @@ -26,6 +26,7 @@ sidebar_label: getFileInfo | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | | filePath | `string` | | 是 | 要读取的文件路径 | +| apFilePath | `string` | | 否 | 本地文件路径
API 支持度: alipay | | digestAlgorithm | "md5" or "sha1" | `'md5'` | 否 | 计算文件摘要的算法 | | complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(result: FailCallbackResult) => void` | | 否 | 接口调用失败的回调函数 | diff --git a/docs/apis/files/getFileSystemManager.md b/docs/apis/files/getFileSystemManager.md index a8f02b24285f..08172540cfc4 100644 --- a/docs/apis/files/getFileSystemManager.md +++ b/docs/apis/files/getFileSystemManager.md @@ -5,7 +5,7 @@ sidebar_label: getFileSystemManager 获取全局唯一的文件管理器 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.getFileSystemManager.html) diff --git a/docs/apis/files/getSavedFileInfo.md b/docs/apis/files/getSavedFileInfo.md index c7690bff124e..20ffde1f3fbb 100644 --- a/docs/apis/files/getSavedFileInfo.md +++ b/docs/apis/files/getSavedFileInfo.md @@ -5,7 +5,7 @@ sidebar_label: getSavedFileInfo 获取本地文件的文件信息。此接口只能用于获取已保存到本地的文件,若需要获取临时文件信息,请使用 [Taro.getFileInfo](/docs/apis/files/getFileInfo) 接口。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.getSavedFileInfo.html) @@ -26,6 +26,7 @@ sidebar_label: getSavedFileInfo | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | | filePath | `string` | 是 | 文件路径 | +| apFilePath | `string` | 否 | 文件路径
API 支持度: alipay | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/files/getSavedFileList.md b/docs/apis/files/getSavedFileList.md index e3a41960cd88..6025c2a0d459 100644 --- a/docs/apis/files/getSavedFileList.md +++ b/docs/apis/files/getSavedFileList.md @@ -5,7 +5,7 @@ sidebar_label: getSavedFileList 获取本地已保存的文件列表 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.getSavedFileList.html) @@ -40,11 +40,12 @@ sidebar_label: getSavedFileList 文件数组 -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| createTime | `number` | 文件保存时的时间戳,从1970/01/01 08:00:00 到当前时间的秒数 | -| filePath | `string` | 本地路径 | -| size | `number` | 本地文件大小,以字节为单位 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| createTime | `number` | 是 | 文件保存时的时间戳,从1970/01/01 08:00:00 到当前时间的秒数 | +| filePath | `string` | 是 | 本地路径 | +| apFilePath | `string` | 否 | 文件路径
API 支持度: alipay | +| size | `number` | 是 | 本地文件大小,以字节为单位 | ## 示例代码 diff --git a/docs/apis/files/openDocument.md b/docs/apis/files/openDocument.md index 6b9212ce6af7..6a7775821e30 100644 --- a/docs/apis/files/openDocument.md +++ b/docs/apis/files/openDocument.md @@ -5,7 +5,7 @@ sidebar_label: openDocument 新开页面打开文档,支持格式 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.openDocument.html) diff --git a/docs/apis/files/saveFile.md b/docs/apis/files/saveFile.md index aa4be33331dc..8708606b6a89 100644 --- a/docs/apis/files/saveFile.md +++ b/docs/apis/files/saveFile.md @@ -5,7 +5,7 @@ sidebar_label: saveFile 保存文件到本地。**注意:saveFile 会把临时文件移动,因此调用成功后传入的 tempFilePath 将不可用** -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.saveFile.html) @@ -29,6 +29,7 @@ sidebar_label: saveFile | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(result: FailCallbackResult) => void` | 否 | 接口调用失败的回调函数 | | filePath | `string` | 否 | 要存储的文件路径 | +| apFilePath | `string` | 否 | 要保存的本地临时文件路径
API 支持度: alipay | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | ### FailCallbackResult diff --git a/docs/apis/files/saveFileToDisk.md b/docs/apis/files/saveFileToDisk.md index b73eb1ac74c0..9cf2359cb2e5 100644 --- a/docs/apis/files/saveFileToDisk.md +++ b/docs/apis/files/saveFileToDisk.md @@ -5,7 +5,7 @@ sidebar_label: saveFileToDisk 保存文件系统的文件到用户磁盘,仅在 PC 端支持 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.saveFileToDisk.html) diff --git a/docs/apis/location/chooseLocation.md b/docs/apis/location/chooseLocation.md index 2033c7b6f906..9d2eb3e00e3b 100644 --- a/docs/apis/location/chooseLocation.md +++ b/docs/apis/location/chooseLocation.md @@ -7,7 +7,7 @@ sidebar_label: chooseLocation `chooseLocation` api功能是依赖于腾讯位置服务,所以需要使用 api 密钥。如果您没有,可以前往腾讯位置服务[开发者控制台](https://lbs.qq.com/console/mykey.html?console=mykey)进行申请。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.chooseLocation.html) @@ -30,19 +30,26 @@ sidebar_label: chooseLocation | latitude | `number` | 否 | 目标地纬度 | | longitude | `number` | 否 | 目标地经度 | | mapOpts | `Record` | 否 | 地图选点组件参数
API 支持度: h5
h5: 仅支持 H5 使用
[参考地址](https://lbs.qq.com/webApi/component/componentGuide/componentPicker) | +| title | `string` | 否 | 页面显示标题
API 支持度: alipay
alipay: 安卓默认值为 位置,iOS、IDE 默认值为 你在哪里?
[参考地址](https://opendocs.alipay.com/mini/api/location?pathHash=951b46a1) | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| address | `string` | 详细地址 | -| latitude | `number` | 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 | -| longitude | `number` | 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 | -| name | `string` | 位置名称 | -| errMsg | `string` | 调用结果 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| address | `string` | 是 | 详细地址 | +| latitude | `number` | 是 | 纬度,浮点数,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 | +| longitude | `number` | 是 | 经度,浮点数,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 | +| name | `string` | 是 | 位置名称 | +| adCode | `number` | 否 | 区县代码
API 支持度: alipay | +| adName | `string` | 否 | 区县名称
API 支持度: alipay | +| cityCode | `string` | 否 | 城市代码
API 支持度: alipay | +| cityName | `string` | 否 | 城市名称
API 支持度: alipay | +| provinceCode | `number` | 否 | 省份代码
API 支持度: alipay | +| provinceName | `string` | 否 | 省份名称
API 支持度: alipay | +| errMsg | `string` | 是 | 调用结果 | ## 示例代码 diff --git a/docs/apis/location/getFuzzyLocation.md b/docs/apis/location/getFuzzyLocation.md index 052f8d94c45b..62ae6433586c 100644 --- a/docs/apis/location/getFuzzyLocation.md +++ b/docs/apis/location/getFuzzyLocation.md @@ -25,11 +25,18 @@ sidebar_label: getFuzzyLocation | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| type | "wgs84" or "gcj02" | 否 | wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 | +| type | `keyof Type` | 否 | wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | +### Type + +| 参数 | 说明 | +| --- | --- | +| wgs84 | 返回 gps 坐标 | +| gcj02 | 返回 gcj02 坐标 | + ### SuccessCallbackResult | 参数 | 类型 | 说明 | diff --git a/docs/apis/location/getLocation.md b/docs/apis/location/getLocation.md index 4e9f28a1ee5b..8a42c7980414 100644 --- a/docs/apis/location/getLocation.md +++ b/docs/apis/location/getLocation.md @@ -9,7 +9,7 @@ sidebar_label: getLocation - 工具中定位模拟使用IP定位,可能会有一定误差。且工具目前仅支持 gcj02 坐标。 - 使用第三方服务进行逆地址解析时,请确认第三方服务默认的坐标系,正确进行坐标转换。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.getLocation.html) @@ -27,28 +27,38 @@ sidebar_label: getLocation ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| altitude | `string` | 否 | 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| highAccuracyExpireTime | `number` | 否 | 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 | -| isHighAccuracy | `boolean` | 否 | 开启高精度定位 | -| success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | -| type | `string` | 否 | wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| altitude | `boolean` | `false` | 否 | 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| highAccuracyExpireTime | `number` | | 否 | 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 | +| isHighAccuracy | `boolean` | `false` | 否 | 开启高精度定位 | +| success | `(result: SuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | +| type | `string` | `"wgs84"` | 否 | wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 | +| needFullAccuracy | `boolean` | `false` | 否 | 针对 iOS14/Android12 及以上的新特性,其他情况本参数忽略。默认情况宿主是精确定位就返回精确定位信息。
传入 true 会强制使用精确定位信息,iOS14/Android12 及以上如果没有精确定位权限,会弹出精确定位授权弹框
API 支持度: swan | ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| accuracy | `number` | 位置的精确度 | -| altitude | `number` | 高度,单位 m | -| horizontalAccuracy | `number` | 水平精度,单位 m | -| latitude | `number` | 纬度,范围为 -90~90,负数表示南纬 | -| longitude | `number` | 经度,范围为 -180~180,负数表示西经 | -| speed | `number` | 速度,单位 m/s | -| verticalAccuracy | `number` | 垂直精度,单位 m(Android 无法获取,返回 0) | -| errMsg | `string` | 调用结果 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| accuracy | `number` | 是 | 位置的精确度 | +| altitude | `number` | 是 | 高度,单位 m | +| horizontalAccuracy | `number` | 是 | 水平精度,单位 m | +| latitude | `number` | 是 | 纬度,范围为 -90~90,负数表示南纬 | +| longitude | `number` | 是 | 经度,范围为 -180~180,负数表示西经 | +| speed | `number` | 是 | 速度,单位 m/s | +| verticalAccuracy | `number` | 是 | 垂直精度,单位 m(Android 无法获取,返回 0) | +| street | `string` | 否 | 城市名称
API 支持度: swan | +| cityCode | `string` | 否 | 国家代码
API 支持度: swan | +| city | `string` | 否 | 城市名称
API 支持度: swan, tt | +| country | `string` | 否 | 国家
API 支持度: swan | +| countryCode | `string` | 否 | 国家代码
API 支持度: swan | +| province | `string` | 否 | 省份
API 支持度: swan | +| streetNumber | `string` | 否 | 街道号码
API 支持度: swan | +| district | `string` | 否 | 区
API 支持度: swan | +| isFullAccuracy | `boolean` | 否 | 是不是精确定位信息
API 支持度: swan | +| errMsg | `string` | 是 | 调用结果 | ## 示例代码 diff --git a/docs/apis/location/offLocationChange.md b/docs/apis/location/offLocationChange.md index d6a7b01489d5..2346bf155d14 100644 --- a/docs/apis/location/offLocationChange.md +++ b/docs/apis/location/offLocationChange.md @@ -5,18 +5,18 @@ sidebar_label: offLocationChange 取消监听实时地理位置变化事件 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.offLocationChange.html) ## 类型 ```tsx -(callback: (res: TaroGeneral.CallbackResult) => void) => void +(callback?: Callback) => void ``` ## 参数 | 参数 | 类型 | 说明 | | --- | --- | --- | -| callback | `(res: TaroGeneral.CallbackResult) => void` | 实时地理位置变化事件的回调函数 | +| callback | `Callback` | 实时地理位置变化事件的回调函数 | diff --git a/docs/apis/location/offLocationChangeError.md b/docs/apis/location/offLocationChangeError.md index cfb7314565a9..c0cacc35fbff 100644 --- a/docs/apis/location/offLocationChangeError.md +++ b/docs/apis/location/offLocationChangeError.md @@ -12,7 +12,7 @@ sidebar_label: offLocationChangeError ## 类型 ```tsx -(callback: Callback) => void +(callback?: Callback) => void ``` ## 参数 diff --git a/docs/apis/location/onLocationChange.md b/docs/apis/location/onLocationChange.md index 3b4b600f9e47..e409fa055f20 100644 --- a/docs/apis/location/onLocationChange.md +++ b/docs/apis/location/onLocationChange.md @@ -5,7 +5,7 @@ sidebar_label: onLocationChange 监听实时地理位置变化事件,需结合 Taro.startLocationUpdateBackground、Taro.startLocationUpdate 使用。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.onLocationChange.html) @@ -35,15 +35,24 @@ sidebar_label: onLocationChange ### CallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| accuracy | `number` | 位置的精确度 | -| altitude | `number` | 高度,单位 m | -| horizontalAccuracy | `number` | 水平精度,单位 m | -| latitude | `number` | 纬度,范围为 -90~90,负数表示南纬 | -| longitude | `number` | 经度,范围为 -180~180,负数表示西经 | -| speed | `number` | 速度,单位 m/s | -| verticalAccuracy | `number` | 垂直精度,单位 m(Android 无法获取,返回 0) | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| accuracy | `number` | 是 | 位置的精确度 | +| altitude | `number` | 是 | 高度,单位 m | +| horizontalAccuracy | `number` | 是 | 水平精度,单位 m | +| latitude | `number` | 是 | 纬度,范围为 -90~90,负数表示南纬 | +| longitude | `number` | 是 | 经度,范围为 -180~180,负数表示西经 | +| speed | `number` | 是 | 速度,单位 m/s | +| verticalAccuracy | `number` | 是 | 垂直精度,单位 m(Android 无法获取,返回 0) | +| street | `string` | 否 | 街道名称
API 支持度: swan | +| cityCode | `string` | 否 | 城市编码
API 支持度: swan | +| city | `string` | 否 | 城市名称
API 支持度: swan, tt
tt: iOS 不支持 | +| country | `string` | 否 | 国家
API 支持度: swan | +| countryCode | `string` | 否 | 国家代码
API 支持度: swan | +| province | `string` | 否 | 省份
API 支持度: swan | +| streetNumber | `string` | 否 | 街道号码
API 支持度: swan | +| district | `string` | 否 | 区
API 支持度: swan | +| isFullAccuracy | `boolean` | 否 | 是不是精确定位信息
API 支持度: swan | ## 示例代码 diff --git a/docs/apis/location/onLocationChangeError.md b/docs/apis/location/onLocationChangeError.md index 2459b4de6d7f..ceea7f0ef57a 100644 --- a/docs/apis/location/onLocationChangeError.md +++ b/docs/apis/location/onLocationChangeError.md @@ -35,6 +35,7 @@ sidebar_label: onLocationChangeError ### CallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| errCode | `number` | 错误码 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| errCode | `number` | 是 | 错误码 | +| errMsg | `string` | 否 | 错误信息
API 支持度: tt
tt: 最低支持版本 2.48.0 | diff --git a/docs/apis/location/openLocation.md b/docs/apis/location/openLocation.md index c2a8be458c2d..8a3c69ecb3ce 100644 --- a/docs/apis/location/openLocation.md +++ b/docs/apis/location/openLocation.md @@ -5,7 +5,7 @@ sidebar_label: openLocation 使用微信内置地图查看位置 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.openLocation.html) @@ -27,11 +27,12 @@ sidebar_label: openLocation | --- | --- | :---: | --- | | latitude | `number` | 是 | 纬度,范围为-90~90,负数表示南纬。使用 gcj02 国测局坐标系 | | longitude | `number` | 是 | 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 | +| scale | `number` | 否 | 缩放比例
weapp: 范围 5~18,默认值18
alipay: 范围 3~19,默认值15 | +| name | `string` | 否 | 位置名 | | address | `string` | 否 | 地址的详细说明 | +| ignoredApps | `any[]` | 否 | 定义在拉起的地图 App 面板中需要被屏蔽的地图类 App
API 支持度: swan | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| name | `string` | 否 | 位置名 | -| scale | `number` | 否 | 缩放比例,范围5~18 | | success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | ## 示例代码 diff --git a/docs/apis/location/startLocationUpdate.md b/docs/apis/location/startLocationUpdate.md index ed56304b4018..eacbbf7ee09c 100644 --- a/docs/apis/location/startLocationUpdate.md +++ b/docs/apis/location/startLocationUpdate.md @@ -8,7 +8,7 @@ sidebar_label: startLocationUpdate **注意** - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdate.html) @@ -26,8 +26,10 @@ sidebar_label: startLocationUpdate ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| type | `string` | `"gcj02"` | 否 | wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 | +| needFullAccuracy | `boolean` | `false` | 否 | 针对 iOS14/Android12 及以上的新特性,其他情况本参数忽略。默认情况宿主是精确定位就返回精确定位信息。
传入 true 会强制使用精确定位信息,iOS14/Android12 及以上如果没有精确定位权限,会弹出精确定位授权弹框
API 支持度: swan | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/location/startLocationUpdateBackground.md b/docs/apis/location/startLocationUpdateBackground.md index a467de721265..cb94cf604d9e 100644 --- a/docs/apis/location/startLocationUpdateBackground.md +++ b/docs/apis/location/startLocationUpdateBackground.md @@ -28,8 +28,9 @@ sidebar_label: startLocationUpdateBackground ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| type | `string` | `"gcj02"` | 否 | wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用成功的回调函数 | diff --git a/docs/apis/location/stopLocationUpdate.md b/docs/apis/location/stopLocationUpdate.md index 139f0de6a335..47b9f49c965b 100644 --- a/docs/apis/location/stopLocationUpdate.md +++ b/docs/apis/location/stopLocationUpdate.md @@ -5,7 +5,7 @@ sidebar_label: stopLocationUpdate 关闭监听实时位置变化,前后台都停止消息接收 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.stopLocationUpdate.html) diff --git a/docs/apis/media/audio/createInnerAudioContext.md b/docs/apis/media/audio/createInnerAudioContext.md index 6366a8161301..8af0cd600c65 100644 --- a/docs/apis/media/audio/createInnerAudioContext.md +++ b/docs/apis/media/audio/createInnerAudioContext.md @@ -1,5 +1,5 @@ --- -title: Taro.createInnerAudioContext() +title: Taro.createInnerAudioContext(option) sidebar_label: createInnerAudioContext --- @@ -12,9 +12,21 @@ sidebar_label: createInnerAudioContext ## 类型 ```tsx -() => InnerAudioContext +(option?: Option) => InnerAudioContext ``` +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| useWebAudioImplement | `boolean` | 是否使用 WebAudio 作为底层音频驱动,默认关闭。对于短音频、播放频繁的音频建议开启此选项,开启后将获得更优的性能表现。由于开启此选项后也会带来一定的内存增长,因此对于长音频建议关闭此选项。
API 支持度: weapp | + ## 示例代码 ```tsx diff --git a/docs/apis/media/camera/CameraContext.md b/docs/apis/media/camera/CameraContext.md index 5e00d36d01ed..244b56c35757 100644 --- a/docs/apis/media/camera/CameraContext.md +++ b/docs/apis/media/camera/CameraContext.md @@ -210,6 +210,7 @@ listener.start() | high | 高质量 | | normal | 普通质量 | | low | 低质量 | +| original | 原图 | ## API 支持度 diff --git a/docs/apis/media/camera/createCameraContext.md b/docs/apis/media/camera/createCameraContext.md index 242dabb2e6fd..9ce3b4b81943 100644 --- a/docs/apis/media/camera/createCameraContext.md +++ b/docs/apis/media/camera/createCameraContext.md @@ -7,6 +7,8 @@ sidebar_label: createCameraContext 支持情况: +> 支付宝小程序: 支付宝小程序需指定 camera 组件中的 id 属性 + > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/camera/wx.createCameraContext.html) ## 类型 diff --git a/docs/apis/media/image/chooseMessageFile.md b/docs/apis/media/image/chooseMessageFile.md index e54c00cf69e9..3014aeb6c6b0 100644 --- a/docs/apis/media/image/chooseMessageFile.md +++ b/docs/apis/media/image/chooseMessageFile.md @@ -76,7 +76,7 @@ Taro.chooseMessageFile({ type: 'image', success: function (res) { // tempFilePath可以作为img标签的src属性显示图片 - const tempFilePaths = res.tempFilePaths + const tempFilePaths = res.tempFiles } }) ``` diff --git a/docs/apis/navigate/openEmbeddedMiniProgram.md b/docs/apis/navigate/openEmbeddedMiniProgram.md index 6b36c24e79c2..5e626d835d8a 100644 --- a/docs/apis/navigate/openEmbeddedMiniProgram.md +++ b/docs/apis/navigate/openEmbeddedMiniProgram.md @@ -32,6 +32,7 @@ sidebar_label: openEmbeddedMiniProgram | shortLink | `string` | 否 | 小程序链接,当传递该参数后,可以不传 appId 和 path。链接可以通过【小程序菜单】->【复制链接】获取。 | | verify | `keyof Verify` | 否 | 校验方式 。默认为binding | | noRelaunchIfPathUnchanged | `boolean` | 否 | 不 reLaunch 目标小程序,直接打开目标跳转的小程序退后台时的页面,需满足以下条件:1. 目标跳转的小程序生命周期未被销毁;2. 且目标当次启动的path、query、apiCategory与上次启动相同。默认值为 false 。 | +| allowFullScreen | `boolean` | 否 | 打开的小程序是否支持全屏 | | success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | diff --git a/docs/apis/network/request/request.md b/docs/apis/network/request/request.md index 03decb0d5bec..1cad87616e58 100644 --- a/docs/apis/network/request/request.md +++ b/docs/apis/network/request/request.md @@ -34,7 +34,7 @@ sidebar_label: request | url | `string` | | 是 | 开发者服务器接口地址 | | data | `U` | | 否 | 请求的参数 | | header | `TaroGeneral.IAnyObject` | | 否 | 设置请求的 header,header 中不能设置 Referer。

`content-type` 默认为 `application/json` | -| timeout | `number` | `2000` | 否 | 超时时间,单位为毫秒
API 支持度: weapp, h5, tt, alipay | +| timeout | `number` | `60000` | 否 | 超时时间,单位为毫秒
API 支持度: weapp, h5, tt, alipay, rn | | method | `keyof Method` | `"GET"` | 否 | HTTP 请求方法 | | dataType | `string` | | 否 | 返回的数据格式 | | responseType | `keyof ResponseType` | | 否 | 响应的数据类型 | diff --git a/docs/apis/open-api/account/getAccountInfoSync.md b/docs/apis/open-api/account/getAccountInfoSync.md index 7f503ddf673f..14b60253f5d4 100644 --- a/docs/apis/open-api/account/getAccountInfoSync.md +++ b/docs/apis/open-api/account/getAccountInfoSync.md @@ -5,7 +5,7 @@ sidebar_label: getAccountInfoSync 获取当前帐号信息 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/account-info/wx.getAccountInfoSync.html) diff --git a/docs/apis/open-api/address/chooseAddress.md b/docs/apis/open-api/address/chooseAddress.md index 5921c3c3447a..0d314e498ee2 100644 --- a/docs/apis/open-api/address/chooseAddress.md +++ b/docs/apis/open-api/address/chooseAddress.md @@ -5,7 +5,7 @@ sidebar_label: chooseAddress 获取用户收货地址。调起用户编辑收货地址原生界面,并在编辑完成后返回用户选择的地址。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/address/wx.chooseAddress.html) @@ -34,14 +34,14 @@ sidebar_label: chooseAddress | 参数 | 类型 | 说明 | | --- | --- | --- | | userName | `string` | 收货人姓名 | -| postalCode | `string` | 邮编 | +| postalCode | `string` | 邮编
API 支持度: weapp, qq | | provinceName | `string` | 国标收货地址第一级地址 | | cityName | `string` | 国标收货地址第二级地址 | | countyName | `string` | 国标收货地址第三级地址 | -| streetName | `string` | 国标收货地址第四级地址 | +| streetName | `string` | 国标收货地址第四级地址
API 支持度: weapp, qq | | detailInfo | `string` | 详细收货地址信息 | -| detailInfoNew | `string` | 新选择器详细收货地址信息 | -| nationalCode | `string` | 收货地址国家码 | +| detailInfoNew | `string` | 新选择器详细收货地址信息
API 支持度: weapp, qq | +| nationalCode | `string` | 收货地址国家码
API 支持度: weapp, qq | | telNumber | `string` | 收货人手机号码 | ## 示例代码 diff --git a/docs/apis/open-api/authorize/authorize.md b/docs/apis/open-api/authorize/authorize.md index f613117b84d3..940e43adf2b1 100644 --- a/docs/apis/open-api/authorize/authorize.md +++ b/docs/apis/open-api/authorize/authorize.md @@ -5,7 +5,7 @@ sidebar_label: authorize 提前向用户发起授权请求。调用后会立刻弹窗询问用户是否同意授权小程序使用某项功能或获取用户的某些数据,但不会实际调用对应接口。如果用户之前已经同意授权,则不会出现弹窗,直接返回成功。更多用法详见 [用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html)。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/authorize/wx.authorize.html) diff --git a/docs/apis/open-api/channels/getChannelsLiveInfo.md b/docs/apis/open-api/channels/getChannelsLiveInfo.md index efb6f3ab4d23..d94d48e1393e 100644 --- a/docs/apis/open-api/channels/getChannelsLiveInfo.md +++ b/docs/apis/open-api/channels/getChannelsLiveInfo.md @@ -32,14 +32,16 @@ sidebar_label: getChannelsLiveInfo ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| feedId | `string` | 直播 feedId | -| nonceId | `string` | 直播 nonceId | -| description | `string` | 直播主题 | -| status | `number` | 直播状态,2直播中,3直播结束 | -| headUrl | `string` | 视频号头像 | -| nickname | `string` | 视频号昵称 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| feedId | `string` | 是 | 直播 feedId | +| nonceId | `string` | 是 | 直播 nonceId | +| description | `string` | 是 | 直播主题 | +| status | `number` | 是 | 直播状态,2直播中,3直播结束 | +| headUrl | `string` | 是 | 视频号头像 | +| nickname | `string` | 是 | 视频号昵称 | +| replayStatus | `number` | 是 | 直播回放状态 | +| otherInfos | `string[]` | 否 | 除最近的一条直播外,其他的直播列表(注意:每次最多返回按时间戳增序排列的15个直播信息,其中时间最近的那个直播会在接口其他的返回参数中展示,其余的直播会在该字段中展示)。 | ### Status @@ -47,3 +49,12 @@ sidebar_label: getChannelsLiveInfo | --- | --- | | 2 | 直播中 | | 3 | 直播结束 | + +### ReplayStatus + +| 参数 | 说明 | +| --- | --- | +| 0 | 未生成 | +| 1 | 已生成 | +| 3 | 生成中 | +| 6 | 已过期 | diff --git a/docs/apis/open-api/channels/getChannelsLiveNoticeInfo.md b/docs/apis/open-api/channels/getChannelsLiveNoticeInfo.md index f79d40aef610..54121b6ec92c 100644 --- a/docs/apis/open-api/channels/getChannelsLiveNoticeInfo.md +++ b/docs/apis/open-api/channels/getChannelsLiveNoticeInfo.md @@ -32,14 +32,15 @@ sidebar_label: getChannelsLiveNoticeInfo ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| nonceId | `string` | 预告 nonceId | -| status | `number` | 预告状态:0可用 1取消 2已用 | -| startTime | `string` | 开始时间 | -| headUrl | `string` | 直播封面 | -| nickname | `string` | 视频号昵称 | -| reservable | `boolean` | 是否可预约 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| nonceId | `string` | 是 | 预告 nonceId | +| status | `number` | 是 | 预告状态:0可用 1取消 2已用 | +| startTime | `string` | 是 | 开始时间 | +| headUrl | `string` | 是 | 直播封面 | +| nickname | `string` | 是 | 视频号昵称 | +| reservable | `boolean` | 是 | 是否可预约 | +| otherInfos | `string[]` | 否 | 除最近的一条预告信息外,其他的预告信息列表(注意:每次最多返回按时间戳增序排列的15个预告信息,其中时间最近的那个预告信息会在接口其他的返回参数中展示,其余的预告信息会在该字段中展示)。 | ### Status diff --git a/docs/apis/open-api/device-voip/getDeviceVoIPList.md b/docs/apis/open-api/device-voip/getDeviceVoIPList.md index 7850d6974185..8273297c522c 100644 --- a/docs/apis/open-api/device-voip/getDeviceVoIPList.md +++ b/docs/apis/open-api/device-voip/getDeviceVoIPList.md @@ -43,3 +43,16 @@ sidebar_label: getDeviceVoIPList | model_id | `string` | 设备型号 id。通过微信公众平台注册设备获得。(仅单台设备时) | | group_id | `string` | 设备组的唯一标识 id(仅设备组时) | | status | `number` | 设备(组)授权状态。0:未授权;1:已授权 | + +## 示例代码 + +```tsx +Taro.getDeviceVoIPList({ + success(res) { + console.log(res) + }, + fail(res) { + console.log(res) + } +}) +``` diff --git a/docs/apis/open-api/device-voip/requestDeviceVoIP.md b/docs/apis/open-api/device-voip/requestDeviceVoIP.md index fd291494f904..505b70a45b0f 100644 --- a/docs/apis/open-api/device-voip/requestDeviceVoIP.md +++ b/docs/apis/open-api/device-voip/requestDeviceVoIP.md @@ -34,3 +34,33 @@ sidebar_label: requestDeviceVoIP | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +// 授权单台设备 +Taro.requestDeviceVoIP({ + sn: 'xxxx', + snTicket: 'xxxxx', + modelId: 'xxx', + deviceName: 'xxx', + success(res) { + console.log(res) + }, + fail(res) { + console.log(res) + } +}) + +// 批量授权(授权设备组) +Taro.requestDeviceVoIP({ + isGroup: true, + groupId: '设备组 ID', + success(res) { + console.log(res) + }, + fail(res) { + console.log(res) + } +}) +``` diff --git a/docs/apis/open-api/login/checkSession.md b/docs/apis/open-api/login/checkSession.md index 27b141f420e2..97727b28216c 100644 --- a/docs/apis/open-api/login/checkSession.md +++ b/docs/apis/open-api/login/checkSession.md @@ -7,9 +7,9 @@ sidebar_label: checkSession 通过 Taro.login 接口获得的用户登录态拥有一定的时效性。用户越久未使用小程序,用户登录态越有可能失效。反之如果用户一直在使用小程序,则用户登录态一直保持有效。具体时效逻辑由微信维护,对开发者透明。开发者只需要调用 Taro.checkSession 接口检测当前用户登录态是否有效。 -登录态过期后开发者可以再调用 Taro.login 获取新的用户登录态。调用成功说明当前 session_key 未过期,调用失败说明 session_key 已过期。更多使用方法详见 [小程序登录](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html)。 +登录态过期后开发者可以再调用 Taro.login 获取新的用户登录态。调用 Taro.checkSession 成功说明当前 session_key 未过期,调用失败说明 session_key 已过期。更多使用方法详见 [小程序登录](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html)。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.checkSession.html) diff --git a/docs/apis/open-api/login/login.md b/docs/apis/open-api/login/login.md index 4c909a9e1de0..7ba3893fcbe4 100644 --- a/docs/apis/open-api/login/login.md +++ b/docs/apis/open-api/login/login.md @@ -5,7 +5,7 @@ sidebar_label: login 调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户的唯一标识(openid)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。更多使用方法详见 [小程序登录](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html)。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html) @@ -23,19 +23,22 @@ sidebar_label: login ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | -| timeout | `number` | 否 | 超时时间,单位ms | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(result: SuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | +| timeout | `number` | | 否 | 超时时间,单位ms | +| force | `boolean` | `true` | 否 | 未登录时, 是否强制调起登录框
API 支持度: tt | ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| code | `string` | 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 [auth.code2Session](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html),使用 code 换取 openid 和 session_key 等信息 | -| errMsg | `string` | 调用结果 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| code | `string` | 是 | 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 [auth.code2Session](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html),使用 code 换取 openid 和 session_key 等信息 | +| errMsg | `string` | 是 | 调用结果 | +| anonymousCode | `string` | 否 | 用于标识当前设备, 无论登录与否都会返回, 有效期 5 分钟。
API 支持度: tt | +| isLogin | `boolean` | 否 | 判断在当前 APP(头条、抖音等)是否处于登录状态。
API 支持度: tt | ## 示例代码 diff --git a/docs/apis/open-api/privacy/openPrivacyContract.md b/docs/apis/open-api/privacy/openPrivacyContract.md index 1d49ade79b35..15255c6f0230 100644 --- a/docs/apis/open-api/privacy/openPrivacyContract.md +++ b/docs/apis/open-api/privacy/openPrivacyContract.md @@ -28,3 +28,13 @@ sidebar_label: openPrivacyContract | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.openPrivacyContract({ + success: () => {}, // 打开成功 + fail: () => {}, // 打开失败 + complete: () => {} +}) +``` diff --git a/docs/apis/open-api/settings/getSetting.md b/docs/apis/open-api/settings/getSetting.md index 2d859ca56fbc..0889057c4518 100644 --- a/docs/apis/open-api/settings/getSetting.md +++ b/docs/apis/open-api/settings/getSetting.md @@ -5,7 +5,7 @@ sidebar_label: getSetting 获取用户的当前设置。**返回值中只会出现小程序已经向用户请求过的[权限](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html)**。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/wx.getSetting.html) diff --git a/docs/apis/open-api/settings/openSetting.md b/docs/apis/open-api/settings/openSetting.md index 3e75818fd15c..f81d7973bacb 100644 --- a/docs/apis/open-api/settings/openSetting.md +++ b/docs/apis/open-api/settings/openSetting.md @@ -7,7 +7,7 @@ sidebar_label: openSetting 注意:[2.3.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 版本开始,用户发生点击行为后,才可以跳转打开设置页,管理授权信息。[详情](https://developers.weixin.qq.com/community/develop/doc/000cea2305cc5047af5733de751008) -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/setting/wx.openSetting.html) @@ -25,12 +25,12 @@ sidebar_label: openSetting ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| withSubscriptions | `boolean` | 否 | 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | -| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| withSubscriptions | `boolean` | `false` | 否 | 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| success | `(result: SuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | ### SuccessCallbackResult diff --git a/docs/apis/open-api/sticker/openSingleStickerView.md b/docs/apis/open-api/sticker/openSingleStickerView.md new file mode 100644 index 000000000000..dff6ee7f2ca6 --- /dev/null +++ b/docs/apis/open-api/sticker/openSingleStickerView.md @@ -0,0 +1,40 @@ +--- +title: Taro.openSingleStickerView(option) +sidebar_label: openSingleStickerView +--- + +打开单个表情 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sticker/wx.openSingleStickerView.html) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| url | `Object` | 是 | 表情链接,可前往(表情开放平台)[https://sticker.weixin.qq.com/cgi-bin/mmemoticonwebnode-bin/pages/home],在详情页中的「小程序跳转链接」入口复制 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.openSingleStickerView({ + url: '', + success(res) {} +}) +``` diff --git a/docs/apis/open-api/sticker/openStickerIPView.md b/docs/apis/open-api/sticker/openStickerIPView.md new file mode 100644 index 000000000000..6edb55e0e4f0 --- /dev/null +++ b/docs/apis/open-api/sticker/openStickerIPView.md @@ -0,0 +1,40 @@ +--- +title: Taro.openStickerIPView(option) +sidebar_label: openStickerIPView +--- + +打开表情IP合辑 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sticker/wx.openStickerIPView.html) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| url | `Object` | 是 | 表情IP合辑链接,可前往[表情开放平台](https://sticker.weixin.qq.com/cgi-bin/mmemoticonwebnode-bin/pages/home),在详情页中的「小程序跳转链接」入口复制 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.openStickerIPView({ + url: '', + success(res) {} +}) +``` diff --git a/docs/apis/open-api/sticker/openStickerSetView.md b/docs/apis/open-api/sticker/openStickerSetView.md new file mode 100644 index 000000000000..35d83dc092ad --- /dev/null +++ b/docs/apis/open-api/sticker/openStickerSetView.md @@ -0,0 +1,40 @@ +--- +title: Taro.openStickerSetView(option) +sidebar_label: openStickerSetView +--- + +打开表情专辑 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sticker/wx.openStickerSetView.html) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| url | `Object` | 是 | 表情专辑链接,可前往[表情开放平台](https://sticker.weixin.qq.com/cgi-bin/mmemoticonwebnode-bin/pages/home),在详情页中的「小程序跳转链接」入口复制 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.openStickerSetView({ + url: '', + success(res) {} +}) +``` diff --git a/docs/apis/open-api/subscribe-message/requestSubscribeDeviceMessage.md b/docs/apis/open-api/subscribe-message/requestSubscribeDeviceMessage.md index cd78b24cde78..55394c215ed0 100644 --- a/docs/apis/open-api/subscribe-message/requestSubscribeDeviceMessage.md +++ b/docs/apis/open-api/subscribe-message/requestSubscribeDeviceMessage.md @@ -5,7 +5,7 @@ sidebar_label: requestSubscribeDeviceMessage 订阅设备消息接口,调用后弹出授权框,用户同意后会允许开发者给用户发送订阅模版消息。当用户点击“允许”按钮时,模板消息会被添加到用户的小程序设置页,通过 wx.getSetting 接口可获取用户对相关模板消息的订阅状态。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/subscribe-message/wx.requestSubscribeDeviceMessage.html) diff --git a/docs/apis/open-api/subscribe-message/requestSubscribeMessage.md b/docs/apis/open-api/subscribe-message/requestSubscribeMessage.md index da243b392b87..20c2f41e9dcb 100644 --- a/docs/apis/open-api/subscribe-message/requestSubscribeMessage.md +++ b/docs/apis/open-api/subscribe-message/requestSubscribeMessage.md @@ -27,7 +27,9 @@ sidebar_label: requestSubscribeMessage | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| tmplIds | `string[]` | 是 | 需要订阅的消息模板的id的集合(注意:iOS客户端7.0.6版本、Android客户端7.0.7版本之后的一次性订阅/长期订阅才支持多个模板消息,iOS客户端7.0.5版本、Android客户端7.0.6版本之前的一次订阅只支持一个模板消息)消息模板id在[微信公众平台(mp.weixin.qq.com)-功能-订阅消息]中配置 | +| tmplIds | `string[]` | 是 | 需要订阅的消息模板的id的集合(注意:iOS客户端7.0.6版本、Android客户端7.0.7版本之后的一次性订阅/长期订阅才支持多个模板消息,iOS客户端7.0.5版本、Android客户端7.0.6版本之前的一次订阅只支持一个模板消息)消息模板id在[微信公众平台(mp.weixin.qq.com)-功能-订阅消息]中配置
API 支持度: weapp, tt | +| entityIds | `string[]` | 是 | 需要订阅的消息模板 id 集合(注意:1、一次性模板 id 和长期性模板 id 不可同时使用,2、一次最多传入三个模板 id
API 支持度: alipay | +| thirdTypeAppId | `string` | 否 | 模板小程序 appId,仅在服务商代调用场景下需要传入
API 支持度: alipay | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(result: FailCallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | @@ -41,10 +43,15 @@ sidebar_label: requestSubscribeMessage ### SuccessCallbackResult -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| [TEMPLATE_ID] | "accept" or "reject" or "ban" | 动态的键,即模板id | -| errMsg | `string` | 接口调用成功时errMsg值为'requestSubscribeMessage:ok' | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| [TEMPLATE_ID] | "accept" or "reject" or "ban" | 是 | 动态的键,即模板id | +| behavior | `string` | 否 | 用户订阅操作结果。

or 枚举值 or 描述 or
or --- or ---- or
or subscribe or 订阅成功 or
API 支持度: alipay | +| keep | `boolean` | 否 | 一次性订阅,是否勾选 总是保持以上选择,不再询问。

or 枚举值 or 描述 or
or --- or ---- or
or true or 勾选 or
or false or 未勾选 or
API 支持度: alipay | +| refuse | `boolean` | 否 | 长期性订阅,是否点击 拒绝,不再询问。

or 枚举值 or 描述 or
or --- or ---- or
or true or 点击 or
or false or 未点击 or
API 支持度: alipay | +| result | `ISubscribeResult` | 否 | 订阅数据
API 支持度: alipay | +| show | `boolean` | 否 | 本次订阅过程是否弹出了订阅面板。

or 枚举值 or 描述 or
or --- or ---- or
or true or 弹出 or
or false or 未弹出 or
API 支持度: alipay | +| errMsg | `string` | 是 | 接口调用成功时errMsg值为'requestSubscribeMessage:ok' | #### 示例代码 @@ -57,16 +64,26 @@ sidebar_label: requestSubscribeMessage } ``` +### ISubscribeResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| subscribeEntityIds | `string[]` | 订阅成功的模板列表 | +| subscribedEntityIds | `string[]` | 最终订阅成功的模板列表 | +| unsubscribedEntityIds | `string[]` | 未订阅的模板列表 | +| currentSubscribedEntityIds | `string[]` | 本次新增订阅成功的模板列表 | + ### TemplateReflex 模版消息订阅类型 | 参数 | 说明 | | --- | --- | -| accept | 表示用户同意订阅该条id对应的模板消息 | -| reject | 表示用户拒绝订阅该条id对应的模板消息 | -| ban | 表示已被后台封禁 | -| filter | 表示该模板因为模板标题同名被后台过滤 | +| accept | 表示用户同意订阅该条id对应的模板消息
API 支持度: weapp, alipay, tt | +| reject | 表示用户拒绝订阅该条id对应的模板消息
API 支持度: weapp, alipay, tt | +| ban | 表示已被后台封禁
API 支持度: weapp, tt | +| filter | 表示该模板因为模板标题同名被后台过滤
API 支持度: weapp | +| fail | 表示该条 id 对应的模版消息授权失败
API 支持度: tt | ## 示例代码 diff --git a/docs/apis/open-api/subscribe-message/subscribeService.md b/docs/apis/open-api/subscribe-message/subscribeService.md new file mode 100644 index 000000000000..26993502d34d --- /dev/null +++ b/docs/apis/open-api/subscribe-message/subscribeService.md @@ -0,0 +1,44 @@ +--- +title: Taro.subscribeService(option) +sidebar_label: subscribeService +--- + +小程序消息订阅服务,包括取消订阅和查询订阅;订阅操作详见 [form 表单](https://smartprogram.baidu.com/docs/develop/component/formlist_form/)。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-subscribeService/) + +## 类型 + +```tsx +(option: subscribeService.Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `subscribeService.Option` | + +## 示例代码 + +```tsx +Taro.subscribeService({ + templateId: 'BD0003', + subscribeId: '8026', + type: 'query', + success(res) { + Taro.showModal({ + title: 'success', + content: JSON.stringify(res) + }) + }, + fail(err) { + Taro.showModal({ + title: 'fail', + content: JSON.stringify(err) + }) + } +}) +``` diff --git a/docs/apis/open-api/subscribe-message/unsubscribeMessage.md b/docs/apis/open-api/subscribe-message/unsubscribeMessage.md new file mode 100644 index 000000000000..b54636f3d710 --- /dev/null +++ b/docs/apis/open-api/subscribe-message/unsubscribeMessage.md @@ -0,0 +1,48 @@ +--- +title: Taro.unsubscribeMessage(option) +sidebar_label: unsubscribeMessage +--- + +取消当前用户已订阅的消息 + +支持情况: + +> [参考文档](https://opendocs.alipay.com/mini/07vg26?pathHash=8c9630ac) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| entityIds | `string[]` | 是 | 需要取消订阅的消息模板 id 集合(注意:1、一次性模板 id 和长期性模板 id 不可同时使用,2、一次最多传入三个模板 id)。 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.unsubscribeMessage({ + entityIds: [ + 'ac768fca1ce245ccae9404bb5243c49b', + '9aa357acb7c6434aba294aded1cdfb7c', + ], + success(res) { + console.log(res); + }, + fail(err) { + console.log(err); + } +}) +``` diff --git a/docs/apis/open-api/user-info/getUserInfo.md b/docs/apis/open-api/user-info/getUserInfo.md index 8fc67d679df2..45a3e6f08df8 100644 --- a/docs/apis/open-api/user-info/getUserInfo.md +++ b/docs/apis/open-api/user-info/getUserInfo.md @@ -8,7 +8,7 @@ sidebar_label: getUserInfo **接口调整说明** 在用户未授权过的情况下调用此接口,将不再出现授权弹窗,会直接进入 fail 回调(详见[《公告》](https://developers.weixin.qq.com/community/develop/doc/0000a26e1aca6012e896a517556c01))。在用户已授权的情况下调用此接口,可成功获取用户信息。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/open-api/user-info/wx.getUserInfo.html) diff --git a/docs/apis/open-api/user-info/getUserProfile.md b/docs/apis/open-api/user-info/getUserProfile.md index ef13f1f60219..6ac569095afe 100644 --- a/docs/apis/open-api/user-info/getUserProfile.md +++ b/docs/apis/open-api/user-info/getUserProfile.md @@ -33,13 +33,14 @@ sidebar_label: getUserProfile ### Option -| 参数 | 类型 | 必填 | 说明 | -| --- | --- | :---: | --- | -| lang | `keyof Language` | 否 | 显示用户信息的语言 | -| desc | `string` | 是 | 声明获取用户个人信息后的用途,不超过30个字符 | -| success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | -| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| lang | `keyof Language` | | 否 | 显示用户信息的语言 | +| desc | `string` | | 是 | 声明获取用户个人信息后的用途,不超过30个字符 | +| force | `boolean` | `false` | 否 | 当宿主未登录时,是否强制拉起登录框
API 支持度: tt | +| success | `(result: SuccessCallbackResult) => void` | | 否 | 接口调用成功的回调函数 | +| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | ### SuccessCallbackResult diff --git a/docs/apis/qq/addRecentColorSign.md b/docs/apis/qq/addRecentColorSign.md new file mode 100644 index 000000000000..59a3e7ba1bbe --- /dev/null +++ b/docs/apis/qq/addRecentColorSign.md @@ -0,0 +1,51 @@ +--- +title: Taro.addRecentColorSign(option) +sidebar_label: addRecentColorSign +--- + +添加当前小程序页面到最近浏览彩签,需要授权基础库 1.20.0 开始支持。 +提示:在手 Q 8.9.0 前的版本,当系统未授予手 Q 悬浮穿权限时,每次调用该接口都会弹出系统授权窗口。自手 Q 8.9.0 起交互调整如下: + 1. 系统没有授予手 Q 悬浮窗权限时,接口执行 fail 回调函数并附带 ”No floating window permission“的错误信息,开发者可针对此信息在业务代码里弹窗提示用户手动授予手 Q 悬浮窗权限。 + 2. 安卓系统部分机型存在获取悬浮窗权限不准确情况。 + +支持情况: + +> [参考文档](https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addColorSign.html#qq-addrecentcolorsign) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| query | `string` | 否 | 做为点击最近彩签打开的小程序页面的启动参数,如 a=1&b=2
默认值:当前页面的查询参数 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.addRecentColorSign({ + query: 'a=1&b=2', + success(res) { + console.log('addRecentColorSign success: ', res) + }, + fail(err) { + console.log('addRecentColorSign fail: ', err) + }, + complete(res) { + console.log('addRecentColorSign complete: ', res) + } +}) +``` diff --git a/docs/apis/qq/applyAddToMyApps.md b/docs/apis/qq/applyAddToMyApps.md new file mode 100644 index 000000000000..92c980561800 --- /dev/null +++ b/docs/apis/qq/applyAddToMyApps.md @@ -0,0 +1,53 @@ +--- +title: Taro.applyAddToMyApps(option) +sidebar_label: applyAddToMyApps +--- + +申请用户将本小程序添加到下拉页面中“我的小程序”当中,手Q8.9.13及以上版本支持 + +支持情况: + +> [参考文档](https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addToMyApps.html#qq-applyaddtomyapps) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| confirm | `boolean` | true 代表用户选择了同意 | +| cancel | `boolean` | true 代表用户选择了不同意 | + +## 示例代码 + +```tsx +Taro.applyAddToMyApps({ + success(res) { + if (res.confirm) { + // 用户同意添加 + } + if (res.cancel) { + // 用户不同意添加 + } + // 原则上,confirm和cancel是互斥的 + } +}) +``` diff --git a/docs/apis/qq/getGuildInfo.md b/docs/apis/qq/getGuildInfo.md new file mode 100644 index 000000000000..763c33379b17 --- /dev/null +++ b/docs/apis/qq/getGuildInfo.md @@ -0,0 +1,40 @@ +--- +title: Taro.getGuildInfo(option) +sidebar_label: getGuildInfo +--- + +获取频道信息与当前人身份(FOR 机器人服务入口) + +支持情况: + +> [参考文档](https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_guild.html) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| open_guild_id | `string` | 是 | 频道id | +| channel_id | `string` | 否 | 子频道Id | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| encryptedData | `string` | 加密之后的数据,需要解密 | +| iv | `string` | 对称解密算法初始向量(base64) | +| signature | `string` | 签名(base64) | diff --git a/docs/apis/qq/getQQRunData.md b/docs/apis/qq/getQQRunData.md new file mode 100644 index 000000000000..d9656a3b3eb8 --- /dev/null +++ b/docs/apis/qq/getQQRunData.md @@ -0,0 +1,72 @@ +--- +title: Taro.getQQRunData(option) +sidebar_label: getQQRunData +--- + +获取用户过去三十天QQ运动步数。需要先调用 qq.login 接口。步数信息会在用户主动进入小程序时更新。 + +支持情况: + +> [参考文档](https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_sport.html) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(result: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| encryptedData | `string` | 包括敏感数据在内的完整用户信息的加密数据,详细见加密数据解密算法。 | +| iv | `string` | 加密算法的初始向量,详细见加密数据解密算法 | + +## 示例代码 + +```tsx +Taro.getQQRunData({ + success(res) { + // 拿 encryptedData 到开发者后台解密开放数据 + const encryptedData = res.encryptedData + } +}) +``` + +**开放数据 JSON 结构** +敏感数据有两种获取方式,一是使用 加密数据解密算法 。 获取得到的开放数据为以下 json 结构: + +```json +{ + "stepInfoList": [ + { + "timestamp": 1445866601, + "step": 100 + }, + { + "timestamp": 1445876601, + "step": 120 + } + ] +} +``` +* stepInfoList 中,每一项结构如下: + +| 属性 | 类型 | 说明 | +| --- | ---- | --- | +| timestamp | number | 时间戳,表示数据对应的时间 | +| step | number | QQ运动步数 | diff --git a/docs/apis/qq/isAddedToMyApps.md b/docs/apis/qq/isAddedToMyApps.md new file mode 100644 index 000000000000..c9ffc22f145b --- /dev/null +++ b/docs/apis/qq/isAddedToMyApps.md @@ -0,0 +1,50 @@ +--- +title: Taro.isAddedToMyApps(option) +sidebar_label: isAddedToMyApps +--- + +查询用户是否已经将本小程序添加到下拉页面中“我的小程序”当中,手Q8.9.13及以上版本支持,建议使用qq.applyAddToMyApps之前先调用qq.isAddedToMyApps来作前置判断 + +支持情况: + +> [参考文档](https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addToMyApps.html#qq-isaddedtomyapps) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| isAdded | `boolean` | true 代表用户已经添加,false 则还没添加 | + +## 示例代码 + +```tsx +Taro.isAddedToMyApps({ + success(res) { + if (res.isAdded) { + // 用户已经添加 + } else { + // 用户还未添加 + } + } +}) +``` diff --git a/docs/apis/qq/openQzonePublish.md b/docs/apis/qq/openQzonePublish.md index 61a3b510c666..6293d471c7a8 100644 --- a/docs/apis/qq/openQzonePublish.md +++ b/docs/apis/qq/openQzonePublish.md @@ -4,23 +4,6 @@ sidebar_label: openQzonePublish --- 此接口可打开手Q说说发表界面,并将文字内容和图片/视频内容传递到手Q说说发表界面。 -```tsx -Taro.openQzonePublish({ - footnote: '使用同款滤镜', - path: 'pages/index/index', - text: '我爱中国', - media: [ - { - type: 'photo', - path: 'qqfile://1.png' - }, - { - type: 'video', - path: 'qqfile://2.mp4' - } - ] -}) -``` 支持情况: @@ -59,3 +42,23 @@ Taro.openQzonePublish({ ```tsx "photo" | "video" ``` + +## 示例代码 + +```tsx +Taro.openQzonePublish({ + footnote: '使用同款滤镜', + path: 'pages/index/index', + text: '我爱中国', + media: [ + { + type: 'photo', + path: 'qqfile://1.png' + }, + { + type: 'video', + path: 'qqfile://2.mp4' + } + ] +}) +``` diff --git a/docs/apis/qq/setCustomDress.md b/docs/apis/qq/setCustomDress.md new file mode 100644 index 000000000000..8ecad0fd75c0 --- /dev/null +++ b/docs/apis/qq/setCustomDress.md @@ -0,0 +1,47 @@ +--- +title: Taro.setCustomDress(option) +sidebar_label: setCustomDress +--- + +QQ美化平台内测阶段,仅被邀请的商户可使用此接口。 + +支持情况: + +> [参考文档](https://q.qq.com/wiki/develop/miniprogram/API/open_port/personalize.html#qq-setcustomdress) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| action | `string` | 是 | 方法名,设置头像填"uploadAvatar",其他方法后续开放 | +| path | `string` | 是 | 素材路径,必须为本地文件,路径为 wxfile:// 的形式 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.setCustomDress({ + action: "uploadAvatar", + path:"wxfile://images/1.png" + success(res) { + console.log("success"+res); + }, + fail(res) { + console.log("fail"+res); + } +}) +``` diff --git a/docs/apis/qq/setOfficialDress.md b/docs/apis/qq/setOfficialDress.md new file mode 100644 index 000000000000..1cec8d3271a5 --- /dev/null +++ b/docs/apis/qq/setOfficialDress.md @@ -0,0 +1,50 @@ +--- +title: Taro.setOfficialDress(option) +sidebar_label: setOfficialDress +--- + +QQ美化平台内测阶段,仅被邀请的商户可使用此接口。 + +支持情况: + +> [参考文档](https://q.qq.com/wiki/develop/miniprogram/API/open_port/personalize.html#qq-setofficialdress) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| action | `string` | 是 | 方法名,设置头像填"setAvatar",其他方法后续开放 | +| uin | `string` | 是 | openid,给自己设置头像填"self" | +| item_id | `string` | 否 | 物品id | +| busi_info | `string` | 否 | 设置头像"setAvatar"此处不用填 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.setOfficialDress({ + action: "setAvatar", + uin: "self", + item_id: "2740", + success(res) { + console.log("success"+res); + }, + fail(res) { + console.log("fail"+res); + } +}) +``` diff --git a/docs/apis/qq/updateQQApp.md b/docs/apis/qq/updateQQApp.md new file mode 100644 index 000000000000..3da9dd2e9d94 --- /dev/null +++ b/docs/apis/qq/updateQQApp.md @@ -0,0 +1,46 @@ +--- +title: Taro.updateQQApp(option) +sidebar_label: updateQQApp +--- + +更新 QQ 版本 + +支持情况: + +> [参考文档](https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_updateQQ.html#qq-updateqqapp) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.updateQQApp({ + success: function(res) { + console.log('updateQQApp success',res) + }, + fail: function(err) { + console.log('updateQQApp fail',err) + }, + complete: function(res) { + console.log('updateQQApp info',res) + } +}) +``` diff --git a/docs/apis/skyline/Snapshot.md b/docs/apis/skyline/Snapshot.md new file mode 100644 index 000000000000..0f7be9e11efc --- /dev/null +++ b/docs/apis/skyline/Snapshot.md @@ -0,0 +1,60 @@ +--- +title: Snapshot +sidebar_label: Snapshot +--- + +Snapshot 实例,可通过 SelectorQuery 获取。 + +Snapshot 通过 id 跟一个 snapshot 组件绑定,操作对应的 snapshot 组件。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/skyline/Snapshot.html) + +## 方法 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| width | `number` | 画布宽度 | +| height | `number` | 画布高度 | + +### takeSnapshot + +对 snapshot 组件子树进行截图 + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/skyline/Snapshot.takeSnapshot.html) + +```tsx +(option: Option) => Promise +``` + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +## 参数 + +### TakeSnapshot + +#### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| type | `string` | 是 | 截图导出类型,'file' 保存到临时文件目录或 'arraybuffer' 返回图片二进制数据,默认值为 'file' | +| format | `string` | 是 | 截图文件格式,'rgba' 或 'png',默认值为 'png' | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +#### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| tempFilePath | `string` | 截图保存的临时文件路径,当 type 为 file 该字段生效 | +| data | `string` | 截图对应的二进制数据,当 type 为 arraybuffer 该字段生效 | + +## API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| Snapshot | ✔️ | | | | diff --git a/docs/apis/storage/background-fetch/getBackgroundFetchData.md b/docs/apis/storage/background-fetch/getBackgroundFetchData.md index 9ff6e62e00e3..ae61089834a2 100644 --- a/docs/apis/storage/background-fetch/getBackgroundFetchData.md +++ b/docs/apis/storage/background-fetch/getBackgroundFetchData.md @@ -5,14 +5,14 @@ sidebar_label: getBackgroundFetchData 拉取 backgroundFetch 客户端缓存数据 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchData.html) ## 类型 ```tsx -(option: Option) => void +(option: Option) => Promise ``` ## 参数 @@ -25,7 +25,19 @@ sidebar_label: getBackgroundFetchData | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | -| fetchType | `string` | 是 | 取值为 periodic | +| fetchType | `string` | 是 | 缓存数据类别
weapp: 取值为 periodic
qq: 取值为 periodic
alipay: 取值为 pre: 数据预拉取; jsapiPre: API 预调用(目前仅支持地理位置预拉取) | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### SuccessCallbackResult + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| fetchedData | string or Object | 是 | 缓存数据
alipay: Object | +| timeStamp | `number` | 是 | 客户端拿到缓存数据的时间戳 ms。(iOS 时间戳存在异常,8.0.27 修复) | +| path | `string` | 是 | 小程序页面路径 | +| query | `string` | 是 | 传给页面的 query 参数 | +| scene | `number` | 是 | 进入小程序的场景值 | +| fetchType | `string` | 否 | 缓存数据类型,与入参 fetchType 一致
API 支持度: alipay | +| timestamp | `number` | 否 | 缓存数据的时间戳。单位:ms。
API 支持度: alipay | diff --git a/docs/apis/storage/background-fetch/getBackgroundFetchToken.md b/docs/apis/storage/background-fetch/getBackgroundFetchToken.md index 39f95ca0b5b1..e297ffe22010 100644 --- a/docs/apis/storage/background-fetch/getBackgroundFetchToken.md +++ b/docs/apis/storage/background-fetch/getBackgroundFetchToken.md @@ -5,14 +5,14 @@ sidebar_label: getBackgroundFetchToken 获取设置过的自定义登录态。若无,则返回 fail。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchToken.html) ## 类型 ```tsx -(option?: Option) => void +(option?: Option) => Promise ``` ## 参数 @@ -27,4 +27,11 @@ sidebar_label: getBackgroundFetchToken | --- | --- | :---: | --- | | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | -| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| token | `string` | 自定义的登录态 | +| errMsg | `string` | 接口调用结果 | diff --git a/docs/apis/storage/background-fetch/onBackgroundFetchData.md b/docs/apis/storage/background-fetch/onBackgroundFetchData.md index fc98bf29da8a..38d60616ac57 100644 --- a/docs/apis/storage/background-fetch/onBackgroundFetchData.md +++ b/docs/apis/storage/background-fetch/onBackgroundFetchData.md @@ -5,21 +5,21 @@ sidebar_label: onBackgroundFetchData 收到 backgroundFetch 数据时的回调 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.onBackgroundFetchData.html) ## 类型 ```tsx -(option?: Option) => void +(option?: Option | Callback) => void ``` ## 参数 | 参数 | 类型 | | --- | --- | -| option | `Option` | +| option | Option or Callback | ### Option @@ -28,3 +28,24 @@ sidebar_label: onBackgroundFetchData | complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | | fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | | success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### Callback + +```tsx +(result: CallbackResult) => void +``` + +| 参数 | 类型 | +| --- | --- | +| result | `CallbackResult` | + +### CallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| fetchType | `string` | 缓存数据类别,取值为 periodic 或 pre | +| fetchedData | `string` | 缓存数据 | +| timeStamp | `number` | 客户端拿到缓存数据的时间戳 | +| path | `string` | 小程序页面路径 | +| query | `string` | 传给页面的 query 参数 | +| scene | `number` | 进入小程序的场景值 | diff --git a/docs/apis/storage/background-fetch/setBackgroundFetchToken.md b/docs/apis/storage/background-fetch/setBackgroundFetchToken.md index 20c81e883228..fd6b58dc1eb5 100644 --- a/docs/apis/storage/background-fetch/setBackgroundFetchToken.md +++ b/docs/apis/storage/background-fetch/setBackgroundFetchToken.md @@ -5,14 +5,14 @@ sidebar_label: setBackgroundFetchToken 设置自定义登录态,在周期性拉取数据时带上,便于第三方服务器验证请求合法性 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.setBackgroundFetchToken.html) ## 类型 ```tsx -(option: Option) => void +(option: Option) => Promise ``` ## 参数 diff --git a/docs/apis/storage/batchGetStorage.md b/docs/apis/storage/batchGetStorage.md new file mode 100644 index 000000000000..3760e6b476db --- /dev/null +++ b/docs/apis/storage/batchGetStorage.md @@ -0,0 +1,42 @@ +--- +title: Taro.batchGetStorage(option) +sidebar_label: batchGetStorage +--- + +从本地缓存中异步批量获取指定 key 的内容。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorage.html) + +## 类型 + +```tsx +(option: Option) => Promise +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| keyList | `string[]` | 是 | 本地缓存中指定的 keyList | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +## 示例代码 + +```tsx +Taro.batchGetStorage({ + keyList: ['key'], + success(res) { + console.log(res) + } +}) +``` diff --git a/docs/apis/storage/batchGetStorageSync.md b/docs/apis/storage/batchGetStorageSync.md new file mode 100644 index 000000000000..1bcf9a5b6001 --- /dev/null +++ b/docs/apis/storage/batchGetStorageSync.md @@ -0,0 +1,35 @@ +--- +title: Taro.batchGetStorageSync(keyList) +sidebar_label: batchGetStorageSync +--- + +从本地缓存中同步批量获取指定 key 的内容。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorageSync.html) + +## 类型 + +```tsx +(keyList: string[]) => T[] +``` + +## 参数 + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| keyList | `T` | 本地缓存中指定的 key 数组 | + +## 示例代码 + +```tsx +try { + var valueList = Taro.batchGetStorageSync(['key']) + if (valueList) { + // Do something with return value + } +} catch (e) { + // Do something when catch error +} +``` diff --git a/docs/apis/storage/batchSetStorage.md b/docs/apis/storage/batchSetStorage.md new file mode 100644 index 000000000000..02ca4eb4166f --- /dev/null +++ b/docs/apis/storage/batchSetStorage.md @@ -0,0 +1,51 @@ +--- +title: Taro.batchSetStorage(option) +sidebar_label: batchSetStorage +--- + +将数据批量存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。 +除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。 +单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorage.html) + +## 类型 + +```tsx +(option: Option) => Promise +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| kvList | `kv[]` | 是 | [{ key, value }] | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### kv + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| key | `string` | key 本地缓存中指定的 key | +| value | `any` | data 需要存储的内容。只支持原生类型、Date、及能够通过JSON.stringify序列化的对象。 | + +## 示例代码 + +```tsx +Taro.batchGetStorage({ + keyList: ['key'] + success(res) { + console.log(res) + } +}) +``` diff --git a/docs/apis/storage/batchSetStorageSync.md b/docs/apis/storage/batchSetStorageSync.md new file mode 100644 index 000000000000..0a5e3fcb185c --- /dev/null +++ b/docs/apis/storage/batchSetStorageSync.md @@ -0,0 +1,45 @@ +--- +title: Taro.batchSetStorageSync(option) +sidebar_label: batchSetStorageSync +--- + +将数据批量存储在本地缓存中指定的 key 中。 +会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。 +单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorageSync.html) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| kvList | `kv[]` | [{ key, value }] | + +### kv + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| key | `string` | key 本地缓存中指定的 key | +| value | `any` | data 需要存储的内容。只支持原生类型、Date、及能够通过JSON.stringify序列化的对象。 | + +## 示例代码 + +```tsx +try { + Taro.batchSetStorageSync([{key: 'key', value: 'value'}]) +} catch (e) { } +``` diff --git a/docs/apis/storage/cache-manager/CacheManager.md b/docs/apis/storage/cache-manager/CacheManager.md index faf33dc36c28..834d79ea5215 100644 --- a/docs/apis/storage/cache-manager/CacheManager.md +++ b/docs/apis/storage/cache-manager/CacheManager.md @@ -5,6 +5,13 @@ sidebar_label: CacheManager ## 方法 +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| mode | `keyof Mode` | 当前缓存模式 | +| origin | `string` | 全局 origin | +| maxAge | `number` | 全局缓存有效时间 | +| state | `keyof State` | 当前缓存管理器状态 | + ### addRule 添加规则 @@ -21,6 +28,34 @@ sidebar_label: CacheManager | --- | --- | | option | `AddRuleOption` | +#### 示例代码 + +```tsx +const ruleId = cacheManager.addRule({ + id: 'haha-rule', + method: 'GET', + url: '/haha', + maxAge: 123455, + dataSchema: [ + // data 字段的匹配,默认为空,表示不匹配 + // 类型可以是:string、number、boolean、null、object、any(表示任意类型均可),以及这些类型的数组表示方式 + {name: 'aaa', schema: {type: 'string'}}, // 类型为 string + {name: 'bbb', schema: [{type: 'number'}, {type: 'string'}]}, // 类型为 number, string + {name: 'ccc', schema: {type: 'string', value: 'abc'}}, // 值为 abc + {name: 'ddd', schema: {type: 'string', value: /(abc|cba)/ig}}, // 值符合该正则匹配,如果该值不是字符串类型,则会被尝试转成字符串后再进行比较 + {name: 'ddd', schema: {type: 'string', value: val => val === '123'}}, // 传入函数来校验值 + {name: 'eee', schema: {type: 'object', value: [{ // 类型为对象,则通过嵌套的方式来逐层校验 + name: 'aaa', schema: {type: 'string'}, + // ... + // 嵌套 dataSchema,同上面的方式一样来匹配嵌套的对象 + }]}}, + {name: 'fff', schema: {type: 'string[]'}}, // 类型为 string 数组 + {name: 'ggg', schema: {type: 'any'}}, // 类型为任意类型 + {name: 'hhh', schema: {type: 'any[]'}}, // 类型为任意类型的数组 + ] +}) +``` + ### addRules 批量添加规则 @@ -150,13 +185,13 @@ sidebar_label: CacheManager > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.off.html) ```tsx -(eventName: string, handler: Function) => void +(eventName: string, handler: TaroGeneral.EventCallback) => void ``` | 参数 | 类型 | 说明 | | --- | --- | --- | | eventName | `string` | 事件名称 | -| handler | `Function` | 事件监听函数 | +| handler | `TaroGeneral.EventCallback` | 事件监听函数 | ### on @@ -167,13 +202,13 @@ sidebar_label: CacheManager > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.on.html) ```tsx -(eventName: keyof OnEventName, handler: Function) => void +(eventName: keyof OnEventName, handler: TaroGeneral.EventCallback) => void ``` | 参数 | 类型 | 说明 | | --- | --- | --- | | eventName | `keyof OnEventName` | 事件名称 | -| handler | `Function` | 事件监听函数 | +| handler | `TaroGeneral.EventCallback` | 事件监听函数 | ### start @@ -201,6 +236,22 @@ sidebar_label: CacheManager ## 参数 +### Mode + +| 参数 | 说明 | +| --- | --- | +| weakNetwork | 默认值,弱网/离线使用缓存返回 | +| always | 总是使用缓存返回 | +| none | 不开启,后续可手动开启/停止使用缓存返回 | + +### State + +| 参数 | 说明 | +| --- | --- | +| 0 | 不使用缓存返回 | +| 1 | 使用缓存返回 | +| 2 | 未知 | + ### DataSchema | 参数 | 类型 | 必填 | 说明 | @@ -235,9 +286,9 @@ sidebar_label: CacheManager ### AddRulesOption -| 参数 | 类型 | -| --- | --- | -| rules | `Rule[]` | +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| rules | `Rule[]` | 规则列表 | ### MatchOption diff --git a/docs/apis/storage/cache-manager/createCacheManager.md b/docs/apis/storage/cache-manager/createCacheManager.md index 04c96e09b3a6..77bf046e54d1 100644 --- a/docs/apis/storage/cache-manager/createCacheManager.md +++ b/docs/apis/storage/cache-manager/createCacheManager.md @@ -3,11 +3,11 @@ title: Taro.createCacheManager(option) sidebar_label: createCacheManager --- -拉起手机发送短信界面 +创建缓存管理器 -支持情况: +支持情况: -> [参考文档](declare module '../../index') +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/wx.createCacheManager.html) ## 类型 diff --git a/docs/apis/storage/clearStorage.md b/docs/apis/storage/clearStorage.md index 7c59aa85d0a0..7349387fb8be 100644 --- a/docs/apis/storage/clearStorage.md +++ b/docs/apis/storage/clearStorage.md @@ -5,7 +5,7 @@ sidebar_label: clearStorage 清理本地数据缓存 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.clearStorage.html) diff --git a/docs/apis/storage/clearStorageSync.md b/docs/apis/storage/clearStorageSync.md index b5fcb5a21c63..9d7ba528c3ed 100644 --- a/docs/apis/storage/clearStorageSync.md +++ b/docs/apis/storage/clearStorageSync.md @@ -5,7 +5,7 @@ sidebar_label: clearStorageSync Taro.clearStorage 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.clearStorageSync.html) diff --git a/docs/apis/storage/getStorage.md b/docs/apis/storage/getStorage.md index 79917d3d327f..48c8008d2eb5 100644 --- a/docs/apis/storage/getStorage.md +++ b/docs/apis/storage/getStorage.md @@ -5,7 +5,7 @@ sidebar_label: getStorage 从本地缓存中异步获取指定 key 的内容 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.getStorage.html) diff --git a/docs/apis/storage/getStorageInfo.md b/docs/apis/storage/getStorageInfo.md index b3503375e831..61653235c503 100644 --- a/docs/apis/storage/getStorageInfo.md +++ b/docs/apis/storage/getStorageInfo.md @@ -5,7 +5,7 @@ sidebar_label: getStorageInfo 异步获取当前storage的相关信息 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.getStorageInfo.html) diff --git a/docs/apis/storage/getStorageInfoSync.md b/docs/apis/storage/getStorageInfoSync.md index 0520fbe3c0c2..1e9dcb404de1 100644 --- a/docs/apis/storage/getStorageInfoSync.md +++ b/docs/apis/storage/getStorageInfoSync.md @@ -5,7 +5,7 @@ sidebar_label: getStorageInfoSync Taro.getStorageInfo 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.getStorageInfoSync.html) @@ -19,11 +19,12 @@ Taro.getStorageInfo 的同步版本 ### Option -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| currentSize | `number` | 当前占用的空间大小, 单位 KB | -| keys | `string[]` | 当前 storage 中所有的 key | -| limitSize | `number` | 限制的空间大小,单位 KB | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| currentSize | `number` | 是 | 当前占用的空间大小, 单位 KB | +| keys | `string[]` | 是 | 当前 storage 中所有的 key | +| limitSize | `number` | 是 | 限制的空间大小,单位 KB | +| success | `boolean` | 否 | 是否执行成功
API 支持度: alipay | ## 示例代码 diff --git a/docs/apis/storage/getStorageSync.md b/docs/apis/storage/getStorageSync.md index 4ca131bc77c8..e66f09815ac9 100644 --- a/docs/apis/storage/getStorageSync.md +++ b/docs/apis/storage/getStorageSync.md @@ -5,7 +5,7 @@ sidebar_label: getStorageSync Taro.getStorage 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.getStorageSync.html) diff --git a/docs/apis/storage/removeStorage.md b/docs/apis/storage/removeStorage.md index c86299ab857d..d8b64d19d925 100644 --- a/docs/apis/storage/removeStorage.md +++ b/docs/apis/storage/removeStorage.md @@ -5,7 +5,7 @@ sidebar_label: removeStorage 从本地缓存中移除指定 key -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.removeStorage.html) diff --git a/docs/apis/storage/removeStorageSync.md b/docs/apis/storage/removeStorageSync.md index 7d1d1c6ab512..351e8d16da3f 100644 --- a/docs/apis/storage/removeStorageSync.md +++ b/docs/apis/storage/removeStorageSync.md @@ -5,7 +5,7 @@ sidebar_label: removeStorageSync Taro.removeStorage 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.removeStorageSync.html) diff --git a/docs/apis/storage/setStorage.md b/docs/apis/storage/setStorage.md index 963db10e4938..5ebe3734c40c 100644 --- a/docs/apis/storage/setStorage.md +++ b/docs/apis/storage/setStorage.md @@ -5,7 +5,7 @@ sidebar_label: setStorage 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.setStorage.html) diff --git a/docs/apis/storage/setStorageSync.md b/docs/apis/storage/setStorageSync.md index 45ff94673921..8a2562e49203 100644 --- a/docs/apis/storage/setStorageSync.md +++ b/docs/apis/storage/setStorageSync.md @@ -5,7 +5,7 @@ sidebar_label: setStorageSync Taro.setStorage 的同步版本 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.setStorageSync.html) diff --git a/docs/apis/swan/bookshelf/deleteBookshelf.md b/docs/apis/swan/bookshelf/deleteBookshelf.md new file mode 100644 index 000000000000..5946d4d8361c --- /dev/null +++ b/docs/apis/swan/bookshelf/deleteBookshelf.md @@ -0,0 +1,83 @@ +--- +title: Taro.deleteBookshelf(option) +sidebar_label: deleteBookshelf +--- + +删除书架中的内容(需宿主支持书架入口) + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-deleteBookshelf/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| category | `string` | 是 | 要删除的内容分类 | +| contentIds | `string[]` | 是 | 要删除书架内容的 id,支持传多个,最多 100 条;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符)。支持批量删除的同一个 category 下的多个 id,不同 category 下的 id 请分别调用该接口删除 | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### Category + +| 参数 | 说明 | +| --- | --- | +| article | 专栏模板 | +| doc | 文档模板 | +| cartoon | 动漫模板 | +| av | 影音模板 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| list | `IListItem[]` | 添加到书架的结果列表 | + +### IListItem + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| contentId | `string` | 内容的唯一标识 | +| status | `keyof Status` | 删除状态:值为 0 时是失败,为 1 时是成功 | +| msg | `string` | 删除信息 | + +### Status + +| 参数 | 说明 | +| --- | --- | +| 0 | 失败 | +| 1 | 成功 | + +## 示例代码 + +```tsx +Taro.deleteBookshelf({ + category: 'doc', + contentIds: ['test1', 'test2'], + success(res) { + Taro.showModal({ + title: 'success', + content: JSON.stringify(res) + }) + }, + fail(err) { + Taro.showModal({ + title: 'fail', + content: JSON.stringify(err) + }) + } +}) +``` diff --git a/docs/apis/swan/bookshelf/insertBookshelf.md b/docs/apis/swan/bookshelf/insertBookshelf.md new file mode 100644 index 000000000000..8138c7fb3251 --- /dev/null +++ b/docs/apis/swan/bookshelf/insertBookshelf.md @@ -0,0 +1,84 @@ +--- +title: Taro.insertBookshelf(option) +sidebar_label: insertBookshelf +--- + +添加内容到宿主书架 + +支持情况: + +> 百度小程序: (需宿主支持书架入口) + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-insertBookshelf/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| category | `string` | 是 | 添加的内容分类 | +| contentIds | `string[]` | 是 | 要添加到书架内容的 id,支持传多个,最多 100 条;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符) | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### Category + +| 参数 | 说明 | +| --- | --- | +| article | 专栏模板 | +| doc | 文档模板 | +| cartoon | 动漫模板 | +| av | 影音模板 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| list | `IListItem[]` | 添加到书架的结果列表 | + +### IListItem + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| contentId | `string` | 内容的唯一标识 | +| status | `keyof Status` | 添加状态:值为 0 时是失败,为 1 时是成功 | +| msg | `string` | 添加信息 | + +### Status + +| 参数 | 说明 | +| --- | --- | +| 0 | 失败 | +| 1 | 成功 | + +## 示例代码 + +```tsx +Taro.insertBookshelf({ + category: 'doc', + contentIds: ['test1', 'test2'], + success(res) { + Taro.showModal({ + title: 'success', + content: JSON.stringify(res) + }) + }, + fail(err) { + Taro.showModal({ + title: 'fail', + content: JSON.stringify(err) + }) + } +}) diff --git a/docs/apis/swan/bookshelf/navigateToBookshelf.md b/docs/apis/swan/bookshelf/navigateToBookshelf.md new file mode 100644 index 000000000000..4b99517c76eb --- /dev/null +++ b/docs/apis/swan/bookshelf/navigateToBookshelf.md @@ -0,0 +1,62 @@ +--- +title: Taro.navigateToBookshelf(option) +sidebar_label: navigateToBookshelf +--- + +跳转到宿主书架 + +支持情况: + +> 百度小程序: (需宿主支持书架入口) + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-navigateToBookshelf/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| category | `string` | 是 | 跳转到指定的内容分类
API 支持度: swan | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### Category + +| 参数 | 说明 | +| --- | --- | +| article | 专栏模板 | +| doc | 文档模板 | +| cartoon | 动漫模板 | +| av | 影音模板 | + +## 示例代码 + +```tsx +Taro.navigateToBookshelf({ + category: 'article', + contentIds: 'test1', + success(res) { + Taro.showModal({ + title: 'navigateToBookshelf', + content: 'success' + }) + }, + fail(err) { + Taro.showModal({ + title: 'fail', + content: JSON.stringify(err) + }) + } +}) diff --git a/docs/apis/swan/bookshelf/queryBookshelf.md b/docs/apis/swan/bookshelf/queryBookshelf.md new file mode 100644 index 000000000000..4058b18684a4 --- /dev/null +++ b/docs/apis/swan/bookshelf/queryBookshelf.md @@ -0,0 +1,73 @@ +--- +title: Taro.queryBookshelf(option) +sidebar_label: queryBookshelf +--- + +查询宿主书架的相关内容 + +支持情况: + +> 百度小程序: (需宿主支持书架入口) + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-queryBookshelf/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| contentIds | `string[]` | 是 | 要查询内容的 id,支持传多个,最多 100 条;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符) | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| list | `IListItem[]` | 查询的内容结果列表 | + +### IListItem + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| contentId | `string` | 内容的唯一标识 | +| status | `keyof Status` | 状态 | + +### Status + +| 参数 | 说明 | +| --- | --- | +| 0 | 不存在 | +| 1 | 存在 | + +## 示例代码 + +```tsx +Taro.queryBookshelf({ + contentIds: ['test1', 'test2'], + success(res) { + Taro.showModal({ + title: 'success', + content: JSON.stringify(res) + }) + }, + fail(err) { + Taro.showModal({ + title: 'fail', + content: JSON.stringify(err) + }) + } +}) +``` diff --git a/docs/apis/swan/bookshelf/updateBookshelfReadTime.md b/docs/apis/swan/bookshelf/updateBookshelfReadTime.md new file mode 100644 index 000000000000..53f9a7f7283c --- /dev/null +++ b/docs/apis/swan/bookshelf/updateBookshelfReadTime.md @@ -0,0 +1,77 @@ +--- +title: Taro.updateBookshelfReadTime(option) +sidebar_label: updateBookshelfReadTime +--- + +更新已加入宿主书架的内容的阅读时间 + +支持情况: + +> 百度小程序: (需宿主支持书架入口) + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-queryBookshelf/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| category | `string` | 是 | 添加的内容分类 | +| contentIds | `string[]` | 是 | 要更新内容的 id;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符) | +| complete | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | +| fail | `(res: TaroGeneral.CallbackResult) => void` | 否 | 接口调用失败的回调函数 | +| success | `(res: SuccessCallbackResult) => void` | 否 | 接口调用成功的回调函数 | + +### Category + +| 参数 | 说明 | +| --- | --- | +| article | 专栏模板 | +| doc | 文档模板 | +| cartoon | 动漫模板 | +| av | 影音模板 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| status | `keyof Status` | 更新状态 | +| msg | `string` | 更新的结果信息 | + +### Status + +| 参数 | 说明 | +| --- | --- | +| 0 | 失败 | +| 1 | 成功 | + +## 示例代码 + +```tsx +Taro.updateBookshelfReadTime({ + category: 'doc', + contentIds: 'test1', + success(res) { + Taro.showModal({ + title: 'success', + content: JSON.stringify(res) + }) + }, + fail(err) { + Taro.showModal({ + title: 'fail', + content: JSON.stringify(err) + }) + } +}) diff --git a/docs/apis/swan/download-package/downloadPackage.md b/docs/apis/swan/download-package/downloadPackage.md new file mode 100644 index 000000000000..c2fbb8ac5ee2 --- /dev/null +++ b/docs/apis/swan/download-package/downloadPackage.md @@ -0,0 +1,33 @@ +--- +title: Taro.downloadPackage(option) +sidebar_label: downloadPackage +--- + +针对在小程序中调用其他小程序的场景,预下载其他小程序的包内容。 +Web 态说明:Web 态不支持预下载的能力。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-downloadPackage/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| appKey | `string` | 是 | 预下载的小程序的 appKey | +| pageUrl | `string` | 否 | 预下载的小程序的 pageUrl ,默认值为小程序的首页页面 | +| success | `(res: TaroGeneral.CallbackResult) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: TaroGeneral.CallbackResult) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: TaroGeneral.CallbackResult) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | diff --git a/docs/apis/swan/download-package/downloadPackages.md b/docs/apis/swan/download-package/downloadPackages.md new file mode 100644 index 000000000000..710e11a3433f --- /dev/null +++ b/docs/apis/swan/download-package/downloadPackages.md @@ -0,0 +1,53 @@ +--- +title: Taro.downloadPackages(option) +sidebar_label: downloadPackages +--- + +针对在小程序中调用其他小程序的场景,预下载其他小程序的包内容。 +Web 态说明:Web 态不支持预下载的能力。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-downloadPackages/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| pageList | `IPageItem[]` | 是 | 预下载的小程序的列表。 | +| success | `(res: SuccessCallbackResult) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: TaroGeneral.CallbackResult) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: TaroGeneral.CallbackResult) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | + +### IPageItem + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| appKey | `string` | 预下载的小程序的 appKey | +| pages | `string[]` | 页面路径 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| __index | `__index` | 小程序包预下载结果回调 | + +### IAppKeyResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| pageUrl | `string` | 页面路径 | +| status | `string` | 预下载能力调用结果。值为 "0" 时是成功,非 "0" 时是失败 | +| message | `string` | 预下载结果信息 | diff --git a/docs/apis/swan/download-package/loadSubPackage.md b/docs/apis/swan/download-package/loadSubPackage.md new file mode 100644 index 000000000000..dc6c460e0e43 --- /dev/null +++ b/docs/apis/swan/download-package/loadSubPackage.md @@ -0,0 +1,30 @@ +--- +title: Taro.loadSubPackage(option) +sidebar_label: loadSubPackage +--- + +提前下载好子包的资源,目录结构配置参考[分包加载](https://smartprogram.baidu.com/docs/develop/framework/subpackages/)。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-loadSubPackage/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| success | `(res: TaroGeneral.CallbackResult) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: TaroGeneral.CallbackResult) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: TaroGeneral.CallbackResult) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | diff --git a/docs/apis/swan/getFavorStatus.md b/docs/apis/swan/getFavorStatus.md new file mode 100644 index 000000000000..015efa3fe5d5 --- /dev/null +++ b/docs/apis/swan/getFavorStatus.md @@ -0,0 +1,37 @@ +--- +title: Taro.getFavorStatus(option) +sidebar_label: getFavorStatus +--- + +获取小程序用户关注状态。 +Web 态说明:Web 态小程序暂不支持关注小程序。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-getFavorStatus/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| success | `(res: SuccessCallbackResult) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: any) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: any) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| isFavor | `string` | 用户关注关注状态,1表示已关注,0表示未关注 | diff --git a/docs/apis/swan/getSystemRiskInfo.md b/docs/apis/swan/getSystemRiskInfo.md new file mode 100644 index 000000000000..ac13cea2045d --- /dev/null +++ b/docs/apis/swan/getSystemRiskInfo.md @@ -0,0 +1,44 @@ +--- +title: Taro.getSystemRiskInfo(option) +sidebar_label: getSystemRiskInfo +--- + +获取用于得到风控信息的加密信息对象。更多小程序风控能力参见[风控服务](https://smartprogram.baidu.com/docs/develop/serverapi/open_risk_power/)。 +Web 态说明:Web 态小程序暂不支持获取用于得到风控信息的加密信息对象。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-getSystemRiskInfo/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| success | `(res: SuccessCallbackResult) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: any) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: any) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| content | `Object` | 用于获取风控信息的加密信息对象。
要获取风控信息,需要和[风控检测](https://smartprogram.baidu.com/docs/develop/serverapi/open_risk_power/#detectrisk/)接口联合使用,并作为风控检测接口的 xtoken 参数传入。 | + +### IContent + +| 参数 | 类型 | +| --- | --- | +| key | `string` | +| value | `string` | diff --git a/docs/apis/swan/getTopStatus.md b/docs/apis/swan/getTopStatus.md new file mode 100644 index 000000000000..a87a96627b96 --- /dev/null +++ b/docs/apis/swan/getTopStatus.md @@ -0,0 +1,37 @@ +--- +title: Taro.getTopStatus(option) +sidebar_label: getTopStatus +--- + +获取小程序用户置顶状态。 +Web 态说明:Web 态小程序暂不支持获取置顶状态,降级调起百度 App。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-getTopStatus/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| success | `(res: SuccessCallbackResult) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: any) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: any) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| isTop | `boolean` | 置顶状态 | diff --git a/docs/apis/swan/openBdboxWebview.md b/docs/apis/swan/openBdboxWebview.md new file mode 100644 index 000000000000..d5cafbbaf7e1 --- /dev/null +++ b/docs/apis/swan/openBdboxWebview.md @@ -0,0 +1,38 @@ +--- +title: Taro.openBdboxWebview(option) +sidebar_label: openBdboxWebview +--- + +小程序跳转百度 App 内特定页面。接入本 API 的开发者,需要了解跳转页面的 scheme,并根据文档调用 API 完成跳转。可在百度 App 中,通过将跳转页面 scheme 生成对应二维码,并使用百度 APP 相机扫描二维码调起的方式,来确保 scheme 是否正确。 +Web 态说明: + 1.由于浏览器的限制,Web 态暂时无法准确获取跳转百度 App 成功 / 失败状态,会执行失败回调; + 2.在用户未安装手百、部分第三方浏览器封禁百度 App 的情况下,Web 态会尝试降级调起应用商店。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-openBdboxWebview/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| module | `string` | 否 | 跳转百度 App 特定页面的 scheme 的 module | +| action | `string` | 否 | 跳转百度 App 特定页面的 scheme 的 action | +| path | `string` | 否 | 跳转百度 App 特定页面的 scheme 的 path | +| authority | `string` | 否 | 跳转百度 App 特定页面的 scheme 的 authority | +| parameters | `Object` | 否 | 跳转百度 App 特定页面的 scheme 的参数 | +| success | `(res: any) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: any) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: any) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | diff --git a/docs/apis/swan/pay/getOptimalPriceInfo.md b/docs/apis/swan/pay/getOptimalPriceInfo.md new file mode 100644 index 000000000000..9a2d73b4facc --- /dev/null +++ b/docs/apis/swan/pay/getOptimalPriceInfo.md @@ -0,0 +1,70 @@ +--- +title: Taro.getOptimalPriceInfo(option) +sidebar_label: getOptimalPriceInfo +--- + +获取商品使用百度平台券后的价格 +通过百度收银台支付的商品,用户在支付时可以享受百度平台券提供的优惠。 +使用 API swan.getOptimalPriceInfo 可以提前获知用户在支付时享受的优惠价格。(当用户有多张平台券时,按照平台最优优惠价格计算,与支付时默认选中的优惠券对应的优惠一致) + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/payment_swan-getOptimalPriceInfo/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| productsInfo | `ProductInfo[]` | 是 | 商品信息 | +| success | `(res: SuccessCallbackResult) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: TaroGeneral.CallbackResult) => any` | 否 | 接口调用失败的回调函数 | + +### ProductInfo + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| appKey | `string` | 支付的 appKey | +| products | `Product[]` | 商品信息 | + +### Product + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| amount | `number` | 是 | 商品单价(原价) | +| promotionTag | `string` | 否 | 商品标识 | +| productId | `string` | 是 | 开发者自定义商品 ID,在success回调中,会与减免信息一起返回。 | + +### SuccessCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| productsInfo | `ProductInfoSuccess[]` | 商品信息 | + +### ProductInfoSuccess + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| appKey | `string` | 支付的 appKey | +| products | `ProductSuccess[]` | 减免后的商品信息 | + +### ProductSuccess + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| amount | `number` | 商品单价(原价) | +| productId | `string` | 开发者自定义商品 ID | +| promotionTag | `string` | 商品标识 | +| reduceAmount | `number` | 百度平台券减免金额 | +| afterPayAmount | `number` | 百度平台券减免后金额 | diff --git a/docs/apis/swan/pay/requestPolymerPayment.md b/docs/apis/swan/pay/requestPolymerPayment.md new file mode 100644 index 000000000000..6d01dfbff280 --- /dev/null +++ b/docs/apis/swan/pay/requestPolymerPayment.md @@ -0,0 +1,67 @@ +--- +title: Taro.requestPolymerPayment(option) +sidebar_label: requestPolymerPayment +--- + +1)百度收银台,聚合了主流的百度钱包、微信、支付宝、网银等多种支付渠道,方便开发者一站式快速接入多种支付渠道,让百度用户能在智能小程序场景下,直接完成支付、交易闭环,提升用户支付体验的同时,提高智能小程序的订单转化率。 +2)上述支付渠道在 C 端收银台有两种展示方式,开发者可以选择其中一种实现。 +方式一:将支付渠道内嵌在小程序提单页面中,实现方式参考文档[inline-payment-panel内嵌支付组件](https://smartprogram.baidu.com/docs/develop/component/inline_payment_panel/)。 +方式二:在用户确认订单后,调起收银台半屏面板承载支付渠道,实现方式参考文档调起[百度收银台](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)。 + +Web 态说明:为了保证用户交易行为全流程闭环体验,在 Web 态下调用该方法会做打开百度 App 对应小程序页面的降级处理。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/payment_swan-requestPolymerPayment/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| orderInfo | `OrderInfo` | 是 | 订单信息 | +| success | `(res: TaroGeneral.CallbackResult) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: FailCallbackResult) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: TaroGeneral.CallbackResult) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | + +### OrderInfo + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| dealId | `string` | 是 | 跳转百度收银台支付必带参数之一,是百度收银台的财务结算凭证,与账号绑定的结算协议一一对应,每笔交易将结算到 dealId 对应的协议主体。
详见[核心参数获取与组装](https://smartprogram.baidu.com/docs/develop/function/parameter/)。 | +| appKey | `string` | 是 | 支付能力开通后分配的支付 appKey,用以表示应用身份的唯一 ID ,在应用审核通过后进行分配,一经分配后不会发生更改,来唯一确定一个应用。
详见[核心参数获取与组装](https://smartprogram.baidu.com/docs/develop/function/parameter/)。 | +| totalAmount | `string` | 是 | 订单金额(单位:人民币分)。注:小程序测试包测试金额不可超过 1000 分 | +| tpOrderId | `string` | 是 | 小程序开发者系统创建的唯一订单 ID ,当支付状态发生变化时,会通过此订单 ID 通知开发者。 | +| notifyUrl | `string` | 否 | 通知开发者支付状态的回调地址,必须是合法的 URL ,与开发者平台填写的支付回调地址作用一致,未填写的以平台回调地址为准 | +| dealTitle | `string` | 是 | 订单的名称。 | +| signFieldsRange | `string` | 是 | 用于区分验签字段范围,signFieldsRange 的值:0:原验签字段 appKey+dealId+tpOrderId;1:包含 totalAmount 的验签,验签字段包括appKey+dealId+tpOrderId+totalAmount。固定值为 1 。 | +| rsaSign | `string` | 是 | 对appKey+dealId+totalAmount+tpOrderId进行 RSA 加密后的签名,防止订单被伪造。
签名过程见[签名与验签](https://smartprogram.baidu.com/docs/develop/function/sign_v2/)。 | +| bizInfo | `string` | 否 | 订单详细信息,需要是一个可解析为 JSON Object 的字符串。
字段内容见: [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)。 | +| payResultUrl | `string` | 否 | 当前页面 path。Web 态小程序支付成功后跳回的页面路径,例如:'/pages/payResult/payResult' | +| inlinePaySign | `string` | 否 | 内嵌支付组件返回的支付信息加密 key,与[内嵌支付组件](https://smartprogram.baidu.com/docs/develop/component/inline_payment_panel)配套使用,此值不传或者传空时默认调起支付面板。 | +| promotionTag | `string` | 否 | 平台营销信息,此处传可使用平台券的 spuid,支持通过英文逗号分割传入多个 spuid 值,仅与百度合作平台类目券的开发者需要填写 | + +### FailCallbackResult + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| errCode | `number` | 错误码 | +| data | `DetailFailData` | 详细错误信息。
注: 目前仅在内嵌支付组件调起 swan.requestPolymerPayment 时,选择数字人民币 APP 渠道支付且用户未下载数字人民币 APP 时,返回具体错误信息 data。 | + +### DetailFailData + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| subErrCode | `number` | 详细错误码。20014 表示【未下载数字人民币 APP】 | +| subErrMsg | `string` | 详细错误信息 | diff --git a/docs/apis/swan/setDocumentTitle.md b/docs/apis/swan/setDocumentTitle.md new file mode 100644 index 000000000000..eec2613301d4 --- /dev/null +++ b/docs/apis/swan/setDocumentTitle.md @@ -0,0 +1,31 @@ +--- +title: Taro.setDocumentTitle(option) +sidebar_label: setDocumentTitle +--- + +动态设置当前页面的标题。此方法为 web 版小程序专用方法,使用前需判断方法是否存在。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-setDocumentTitle/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| title | `string` | 是 | 页面中 title 标签中的内容 | +| success | `(res: any) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: any) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: any) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | diff --git a/docs/apis/swan/setMetaDescription.md b/docs/apis/swan/setMetaDescription.md new file mode 100644 index 000000000000..cf7d524ab057 --- /dev/null +++ b/docs/apis/swan/setMetaDescription.md @@ -0,0 +1,31 @@ +--- +title: Taro.setMetaDescription(option) +sidebar_label: setMetaDescription +--- + +设置 web 版小程序 description meta 信息。此方法为 web 版小程序专用方法,使用前需判断方法是否存在。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-setMetaDescription/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| content | `string` | 是 | 需要设置的 description 内容 | +| success | `(res: any) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: any) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: any) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | diff --git a/docs/apis/swan/setMetaKeywords.md b/docs/apis/swan/setMetaKeywords.md new file mode 100644 index 000000000000..b233811f5f3c --- /dev/null +++ b/docs/apis/swan/setMetaKeywords.md @@ -0,0 +1,31 @@ +--- +title: Taro.setMetaKeywords(option) +sidebar_label: setMetaKeywords +--- + +设置 web 版小程序 keywords meta 信息。此方法为 web 版小程序专用方法,使用前需判断方法是否存在。 + +支持情况: + +> [参考文档](https://smartprogram.baidu.com/docs/develop/api/open/swan-setMetaKeywords/) + +## 类型 + +```tsx +(option: Option) => void +``` + +## 参数 + +| 参数 | 类型 | +| --- | --- | +| option | `Option` | + +### Option + +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| content | `string` | 是 | 需要设置的 keywords 内容 | +| success | `(res: any) => any` | 否 | 接口调用成功的回调函数 | +| fail | `(err: any) => any` | 否 | 接口调用失败的回调函数 | +| complete | `(res: any) => any` | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) | diff --git a/docs/apis/taro.extend/requirePlugin.md b/docs/apis/taro.extend/requirePlugin.md index 36a0c0e4d3a8..d36853a391a3 100644 --- a/docs/apis/taro.extend/requirePlugin.md +++ b/docs/apis/taro.extend/requirePlugin.md @@ -1,5 +1,5 @@ --- -title: Taro.requirePlugin(pluginName) +title: requirePlugin sidebar_label: requirePlugin --- @@ -10,7 +10,7 @@ sidebar_label: requirePlugin ## 类型 ```tsx -(pluginName: string) => any +{ (pluginName: string): any; (pluginName: string, success?: (mod: any) => any, error?: (e: { mod: any; errMsg: string; }) => any): any; async?: (pluginName: string) => Promise; } ``` ## 参数 diff --git a/docs/apis/ui/fonts/loadFontFace.md b/docs/apis/ui/fonts/loadFontFace.md index 27a0a9f995ab..e9276afea6f8 100644 --- a/docs/apis/ui/fonts/loadFontFace.md +++ b/docs/apis/ui/fonts/loadFontFace.md @@ -6,14 +6,16 @@ sidebar_label: loadFontFace 动态加载网络字体。文件地址需为下载类型。iOS 仅支持 https 格式文件地址。 注意: -1. 字体文件返回的 contet-type 参考 [font](https://www.iana.org/assignments/media-types/media-types.xhtml#font),格式不正确时会解析失败。 +1. 字体文件返回的 context-type 参考 [font](https://www.iana.org/assignments/media-types/media-types.xhtml#font),格式不正确时会解析失败。 2. 字体链接必须是https(ios不支持http) 3. 字体链接必须是同源下的,或开启了cors支持,小程序的域名是`servicewechat.com` 4. canvas等原生组件不支持使用接口添加的字体 -5. 工具里提示 Faild to load font可以忽略 +5. 工具里提示 Failed to load font 可以忽略 -支持情况: +支持情况: +> 支付宝小程序: source 地址格式为 `url('https://...')`,而不是单纯 URL 地址 +> > H5: 不支持 global (默认全局加载) > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ui/font/wx.loadFontFace.html) diff --git a/docs/apis/ui/interaction/showModal.md b/docs/apis/ui/interaction/showModal.md index add1611b78a0..6ab68517d750 100644 --- a/docs/apis/ui/interaction/showModal.md +++ b/docs/apis/ui/interaction/showModal.md @@ -8,7 +8,7 @@ sidebar_label: showModal - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel"; - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑 -支持情况: +支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.showModal.html) diff --git a/docs/apis/wxml/createIntersectionObserver.md b/docs/apis/wxml/createIntersectionObserver.md index c9d71606b80c..161a2aab75c2 100644 --- a/docs/apis/wxml/createIntersectionObserver.md +++ b/docs/apis/wxml/createIntersectionObserver.md @@ -35,5 +35,5 @@ sidebar_label: createIntersectionObserver ## 示例代码 ```tsx -const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true }) +const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true }) ``` diff --git a/docs/apis/wxml/createMediaQueryObserver.md b/docs/apis/wxml/createMediaQueryObserver.md index 3f9ce220a903..7a28cd60d33d 100644 --- a/docs/apis/wxml/createMediaQueryObserver.md +++ b/docs/apis/wxml/createMediaQueryObserver.md @@ -25,5 +25,5 @@ if (process.env.TARO_ENV === 'weapp') { } else if (process.env.TARO_ENV === 'h5') { createMediaQueryObserver= Taro.createMediaQueryObserver } -const mediaQueryObserver = createMediaQueryObserver() +const mediaQueryObserver = createMediaQueryObserver() ``` diff --git a/docs/components/forms/button.md b/docs/components/forms/button.md index 4f987a385337..6789b9e99004 100755 --- a/docs/components/forms/button.md +++ b/docs/components/forms/button.md @@ -205,7 +205,7 @@ export default { | publicId | `string` | | 否 | 生活号 id,必须是当前小程序同主体且已关联的生活号,open-type="lifestyle" 时有效。 | | templateId | string or string[] | | 否 | 发送订阅类模板消息所用的模板库标题 ID ,可通过 getTemplateLibraryList 获取
当参数类型为 Array 时,可传递 1~3 个模板库标题 ID | | subscribeId | `string` | | 否 | 发送订阅类模板消息时所使用的唯一标识符,内容由开发者自定义,用来标识订阅场景
注意:同一用户在同一 subscribe-id 下的多次授权不累积下发权限,只能下发一条。若要订阅多条,需要不同 subscribe-id | -| groupId | `string` | | 否 | 打开群资料卡时,传递的群号 | +| groupId | `string` | | 否 | 群聊 id | | guildId | `string` | | 否 | 打开频道页面时,传递的频道号 | | shareType | `string` | `27` | 否 | 分享类型集合,请参考下面share-type有效值说明。share-type后续将不再维护,请更新为share-mode | | shareMode | `string` | `['qq', 'qzone']` | 否 | 分享类型集合,请参考下面share-mode有效值说明 | @@ -215,6 +215,7 @@ export default { | shareMessageTitle | `string` | | 否 | 转发标题,不传则默认使用当前小程序的昵称。 FriendInfo | | shareMessageImg | `string` | | 否 | 转发显示图片的链接,可以是网络图片路径(仅 QQ CDN 域名路径)或本地图片文件路径或相对代码包根目录的图片文件路径。显示图片长宽比是 5:4FriendInfo | | dataAwemeId | `string` | | 否 | 跳转抖音号个人页,只支持小程序绑定的品牌号、员工号、合作号 | +| dataIsHalfPage | `boolean` | | 否 | 是否开启半屏模式 | | onGetUserInfo | `CommonEventFunction` | | 否 | 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致

生效时机: `open-type="getUserInfo"` | | onGetAuthorize | `CommonEventFunction` | | 否 | 支付宝获取会员基础信息授权回调

生效时机:`open-type="getAuthorize"` | | onContact | `CommonEventFunction` | | 否 | 客服消息回调

生效时机:`open-type="contact"` | @@ -234,6 +235,7 @@ export default { | onAddFriend | `CommonEventFunction` | | 否 | 添加好友的回调 | | onAddGroupApp | `CommonEventFunction` | | 否 | 添加群应用的回调。errCode 错误码:41004(当前用户非管理员或群主,无权操作),41005(超过可添加群应用的群数量) | | onOpenAwemeUserProfile | `CommonEventFunction` | | 否 | 监听跳转抖音号个人页的回调

生效时机:`open-type="openAwemeUserProfile"` | +| onJoinGroup | `CommonEventFunction<{ errMsg: string; errNo: number; }>` | | 否 | 加群后触发 | ### API 支持度 @@ -262,7 +264,7 @@ export default { | ButtonProps.publicId | | | ✔️ | | ✔️ | | | | | | ButtonProps.templateId | | ✔️ | | | | | | | | | ButtonProps.subscribeId | | ✔️ | | | | | | | | -| ButtonProps.groupId | | | | | ✔️ | | | | | +| ButtonProps.groupId | | | | ✔️(通过创建聊天群、查询群信息获取) | ✔️(打开群资料卡时,传递的群号) | | | | | | ButtonProps.guildId | | | | | ✔️ | | | | | | ButtonProps.shareType | | | | | ✔️ | | | | | | ButtonProps.shareMode | | | | | ✔️ | | | | | @@ -272,6 +274,7 @@ export default { | ButtonProps.shareMessageTitle | | | | | ✔️ | | | | | | ButtonProps.shareMessageImg | | | | | ✔️ | | | | | | ButtonProps.dataAwemeId | | | | ✔️ | | | | | | +| ButtonProps.dataIsHalfPage | | | | ✔️ | | | | | | | ButtonProps.onGetUserInfo | ✔️ | ✔️ | ✔️ | | ✔️ | ✔️ | | | | | ButtonProps.onGetAuthorize | | | ✔️ | | | | | | | | ButtonProps.onContact | ✔️ | ✔️ | | | ✔️ | | | | | @@ -291,6 +294,7 @@ export default { | ButtonProps.onAddFriend | | | | | ✔️ | | | | | | ButtonProps.onAddGroupApp | | | | | ✔️ | | | | | | ButtonProps.onOpenAwemeUserProfile | | | | ✔️ | | | | | | +| ButtonProps.onJoinGroup | | | | ✔️ | | | | | | ### Size diff --git a/docs/components/forms/checkbox.md b/docs/components/forms/checkbox.md index 10a8e980f26a..2d7014adc70f 100755 --- a/docs/components/forms/checkbox.md +++ b/docs/components/forms/checkbox.md @@ -157,6 +157,7 @@ export default { | disabled | `boolean` | `false` | 否 | 是否禁用 | | checked | `boolean` | `false` | 否 | 当前是否选中,可用来设置默认选中 | | color | `string` | | 否 | checkbox的颜色,同 css 的 color | +| name | `string` | | 否 | Checkbox 的名字 | | nativeProps | `Record` | | 否 | 用于透传 `WebComponents` 上的属性到内部 H5 标签上 | | ariaLabel | `string` | | 否 | 无障碍访问,(属性)元素的额外描述 | | onChange | `CommonEventFunction<{ value: string[]; }>` | | 否 | 选中项发生变化时触发 change 事件,小程序无此 API | @@ -169,6 +170,7 @@ export default { | CheckboxProps.disabled | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | CheckboxProps.checked | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | CheckboxProps.color | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | +| CheckboxProps.name | | | | | | | ✔️ | | ✔️ | | CheckboxProps.nativeProps | | | | | | | ✔️ | | | | CheckboxProps.ariaLabel | | | | | ✔️ | | | | | | CheckboxProps.onChange | | | ✔️ | | | | ✔️ | ✔️ | | diff --git a/docs/components/forms/input.md b/docs/components/forms/input.md index 5f5cd9dcceb9..c83b6ed1416f 100755 --- a/docs/components/forms/input.md +++ b/docs/components/forms/input.md @@ -81,6 +81,7 @@ class App extends Component { | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | | value | `string` | | 否 | 输入框的初始内容 | +| defaultValue | `string` | | 否 | 设置 React 非受控输入框的初始内容 | | type | `keyof Type` | `"text"` | 否 | input 的类型 | | password | `boolean` | `false` | 否 | 是否是密码类型 | | placeholder | `string` | | 否 | 输入框为空时占位符 | @@ -125,6 +126,7 @@ class App extends Component { | API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | InputProps.value | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | +| InputProps.defaultValue | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | InputProps.type | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | InputProps.password | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | InputProps.placeholder | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | diff --git a/docs/components/forms/picker-view.md b/docs/components/forms/picker-view.md index f075532399ad..930f6467b51d 100755 --- a/docs/components/forms/picker-view.md +++ b/docs/components/forms/picker-view.md @@ -167,6 +167,7 @@ export default class Picks extends Component { | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | | value | `number[]` | | 否 | 数组中的数字依次表示 picker-view 内的 picker-view-column 选择的第几项(下标从 0 开始),数字大于 picker-view-column 可选项长度时,选择最后一项。 | +| defaultValue | `number[]` | | 否 | 设置 React 非受控状态下的初始取值 | | indicatorStyle | `string` | | 否 | 设置选择器中间选中框的样式 | | indicatorClass | `string` | | 否 | 设置选择器中间选中框的类名 | | maskStyle | `string` | | 否 | 设置蒙层的样式 | @@ -183,6 +184,7 @@ export default class Picks extends Component { | API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | PickerViewProps.value | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | ✔️ | | +| PickerViewProps.defaultValue | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | ✔️ | | | PickerViewProps.indicatorStyle | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | ✔️ | | | PickerViewProps.indicatorClass | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | | PickerViewProps.maskStyle | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | diff --git a/docs/components/forms/picker.md b/docs/components/forms/picker.md index 686eeec978bb..4bcae29a1188 100755 --- a/docs/components/forms/picker.md +++ b/docs/components/forms/picker.md @@ -166,6 +166,7 @@ export default class PagePicker extends Component { | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | +| headerText | `string` | | 否 | 选择器的标题,微信小程序中仅安卓可用 | | mode | `keyof Mode` | `"selector"` | 否 | 选择器类型,默认是普通选择器 | | disabled | `boolean` | `false` | 否 | 是否禁用 | | onCancel | `CommonEventFunction` | | 否 | 取消选择或点遮罩层收起 picker 时触发 | @@ -174,6 +175,7 @@ export default class PagePicker extends Component { | API | 微信小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | +| PickerStandardProps.headerText | ✔️ | | | | | PickerStandardProps.mode | ✔️ | ✔️ | ✔️ | | | PickerStandardProps.disabled | ✔️ | ✔️ | ✔️ | | | PickerStandardProps.onCancel | ✔️ | ✔️ | ✔️ | | @@ -207,9 +209,10 @@ export default class PagePicker extends Component { | range | string[] or number[] or Record[] | `[]` | 是 | mode为 selector 或 multiSelector 时,range 有效 | | rangeKey | `string` | | 否 | 当 range 是一个 Object Array 时,通过 rangeKey 来指定 Object 中 key 的值作为选择器显示内容 | | value | `number` | `0` | 否 | 表示选择了 range 中的第几个(下标从 0 开始) | +| defaultValue | `number` | | 否 | 设置 React 非受控状态下的初始取值 | | itemStyle | `StyleProp` | `{}` | 否 | mode为 selector 或 multiSelector 时 itemStyle 有效 | | indicatorStyle | `StyleProp` | `{}` | 否 | mode为 selector 或 multiSelector 时 indicatorStyle 有效 | -| onChange | `CommonEventFunction` | | 是 | value 改变时触发 change 事件 | +| onChange | `CommonEventFunction` | | 否 | value 改变时触发 change 事件 | | textProps | `PickerText` | | 否 | 用于替换组件内部文本 | ### API 支持度 @@ -219,6 +222,7 @@ export default class PagePicker extends Component { | PickerSelectorProps.range | ✔️ | ✔️ | ✔️ | | | PickerSelectorProps.rangeKey | ✔️ | ✔️ | ✔️ | | | PickerSelectorProps.value | ✔️ | ✔️ | ✔️ | | +| PickerSelectorProps.defaultValue | ✔️ | ✔️ | ✔️ | | | PickerSelectorProps.itemStyle | | | ✔️ | | | PickerSelectorProps.indicatorStyle | | | ✔️ | | | PickerSelectorProps.onChange | ✔️ | ✔️ | ✔️ | | @@ -277,7 +281,8 @@ export default class PagePicker extends Component { | 参数 | 类型 | 必填 | 说明 | | --- | --- | :---: | --- | | mode | `"time"` | 是 | 选择器类型 | -| value | `string` | 是 | value 的值表示选择了 range 中的第几个(下标从 0 开始) | +| value | `string` | 否 | value 的值表示选择了 range 中的第几个(下标从 0 开始) | +| defaultValue | `string` | 否 | 设置 React 非受控状态下的初始取值 | | start | `string` | 否 | 仅当 mode 为 "time" 或 "date" 时有效,表示有效时间范围的开始,字符串格式为"hh:mm" | | end | `string` | 否 | 仅当 mode 为 "time" 或 "date" 时有效,表示有效时间范围的结束,字符串格式为"hh:mm" | | onChange | `CommonEventFunction` | 是 | value 改变时触发 change 事件 | @@ -287,6 +292,7 @@ export default class PagePicker extends Component { | API | 微信小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | | PickerTimeProps.value | ✔️ | ✔️ | ✔️ | | +| PickerTimeProps.defaultValue | ✔️ | ✔️ | ✔️ | | | PickerTimeProps.start | ✔️ | ✔️ | ✔️ | | | PickerTimeProps.end | ✔️ | ✔️ | ✔️ | | | PickerTimeProps.onChange | ✔️ | ✔️ | ✔️ | | @@ -305,6 +311,7 @@ export default class PagePicker extends Component { | --- | --- | :---: | :---: | --- | | mode | `"date"` | | 是 | 选择器类型 | | value | `string` | `0` | 是 | 表示选中的日期,格式为"YYYY-MM-DD" | +| defaultValue | `string` | | 否 | 设置 React 非受控状态下的初始取值 | | start | `string` | | 否 | 仅当 mode 为 "time" 或 "date" 时有效,表示有效时间范围的开始,字符串格式为"YYYY-MM-DD" | | end | `string` | | 否 | 仅当 mode 为 "time" 或 "date" 时有效,表示有效时间范围的结束,字符串格式为"YYYY-MM-DD" | | fields | `keyof Fields` | `"day"` | 否 | 有效值 year, month, day,表示选择器的粒度 | @@ -315,6 +322,7 @@ export default class PagePicker extends Component { | API | 微信小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | | PickerDateProps.value | ✔️ | ✔️ | ✔️ | | +| PickerDateProps.defaultValue | ✔️ | ✔️ | ✔️ | | | PickerDateProps.start | ✔️ | ✔️ | ✔️ | | | PickerDateProps.end | ✔️ | ✔️ | ✔️ | | | PickerDateProps.fields | ✔️ | ✔️ | ✔️ | | @@ -342,6 +350,7 @@ export default class PagePicker extends Component { | --- | --- | :---: | :---: | --- | | mode | `"region"` | | 是 | 选择器类型 | | value | `string[]` | `[]` | 否 | 表示选中的省市区,默认选中每一列的第一个值 | +| defaultValue | `string[]` | | 否 | 设置 React 非受控状态下的初始取值 | | customItem | `string` | | 否 | 可为每一列的顶部添加一个自定义的项 | | level | `keyof Level` | `"region"` | 否 | 选择器层级 | | regionData | `RegionData[]` | | 否 | 自定义省市区数据 | @@ -352,6 +361,7 @@ export default class PagePicker extends Component { | API | 微信小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | | PickerRegionProps.value | ✔️ | ✔️ | ✔️ | | +| PickerRegionProps.defaultValue | ✔️ | ✔️ | ✔️ | | | PickerRegionProps.customItem | ✔️ | ✔️ | ✔️ | | | PickerRegionProps.level | ✔️ | | | | | PickerRegionProps.regionData | | | ✔️ | | diff --git a/docs/components/forms/radio.md b/docs/components/forms/radio.md index 09aad8c3b658..bbea30556916 100755 --- a/docs/components/forms/radio.md +++ b/docs/components/forms/radio.md @@ -176,6 +176,7 @@ export default { | checked | `boolean` | `false` | 否 | 当前是否选中 | | disabled | `boolean` | `false` | 否 | 是否禁用 | | color | `string` | `"#09BB07"` | 否 | Radio 的颜色,同 css 的 color | +| name | `string` | | 否 | Radio 的名字 | | nativeProps | `Record` | | 否 | 用于透传 `WebComponents` 上的属性到内部 H5 标签上 | | ariaLabel | `string` | | 否 | 无障碍访问,(属性)元素的额外描述 | | onChange | `CommonEventFunction<{ value?: string; }>` | | 否 | 中的选中项发生变化时触发 change 事件 | @@ -188,6 +189,7 @@ export default { | RadioProps.checked | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | RadioProps.disabled | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | RadioProps.color | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | ✔️ | | +| RadioProps.name | | | | | | | ✔️ | | ✔️ | | RadioProps.nativeProps | | | | | | | ✔️ | | | | RadioProps.ariaLabel | | | | | ✔️ | | | | | | RadioProps.onChange | | | | | | | ✔️ | ✔️ | | diff --git a/docs/components/forms/slider.md b/docs/components/forms/slider.md index 87a331e82760..1debfdbd4594 100755 --- a/docs/components/forms/slider.md +++ b/docs/components/forms/slider.md @@ -73,6 +73,7 @@ export default class PageView extends Component { | step | `number` | `1` | 否 | 步长,取值必须大于 0,并且可被(max - min)整除 | | disabled | `boolean` | `false` | 否 | 是否禁用 | | value | `number` | `0` | 否 | 当前取值 | +| defaultValue | `string` | | 否 | 设置 React 非受控状态下的初始取值 | | color | `string` | `"#e9e9e9"` | 否 | 背景条的颜色(请使用 backgroundColor) | | selectedColor | `string` | `"#1aad19"` | 否 | 已选择的颜色(请使用 activeColor) | | activeColor | `string` | `"#1aad19"` | 否 | 已选择的颜色 | @@ -97,6 +98,7 @@ export default class PageView extends Component { | SliderProps.step | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SliderProps.disabled | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SliderProps.value | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | +| SliderProps.defaultValue | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SliderProps.color | ✔️ | | | ✔️ | ✔️ | ✔️ | | | | | SliderProps.selectedColor | ✔️ | | | ✔️ | ✔️ | ✔️ | | | | | SliderProps.activeColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | diff --git a/docs/components/forms/switch.md b/docs/components/forms/switch.md index ba061cdc3242..b18ddc54c64c 100755 --- a/docs/components/forms/switch.md +++ b/docs/components/forms/switch.md @@ -69,6 +69,7 @@ export default class PageView extends Component { | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | | checked | `boolean` | `false` | 否 | 是否选中 | +| defaultChecked | `boolean` | | 否 | 设置在 React 非受控状态下,当前是否选中 | | disabled | `boolean` | `false` | 否 | 是否禁用 | | type | "switch" or "checkbox" | `"switch"` | 否 | 样式,有效值:switch, checkbox | | color | `string` | `"#04BE02"` | 否 | switch 的颜色,同 css 的 color | @@ -83,6 +84,7 @@ export default class PageView extends Component { | API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | SwitchProps.checked | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | +| SwitchProps.defaultChecked | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SwitchProps.disabled | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | ✔️ | ✔️ | | | SwitchProps.type | ✔️ | ✔️ | | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SwitchProps.color | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | diff --git a/docs/components/forms/textarea.md b/docs/components/forms/textarea.md index 6d8e5702c6cf..c7665937576d 100755 --- a/docs/components/forms/textarea.md +++ b/docs/components/forms/textarea.md @@ -65,6 +65,7 @@ export default class PageView extends Component { | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | | value | `string` | | 否 | 输入框的内容 | +| defaultValue | `string` | | 否 | 设置 React 非受控输入框的初始内容 | | placeholder | `string` | | 否 | 输入框为空时占位符 | | placeholderStyle | `string` | | 否 | 指定 placeholder 的样式 | | placeholderClass | `string` | `"textarea-placeholder"` | 否 | 指定 placeholder 的样式类 | @@ -102,6 +103,7 @@ export default class PageView extends Component { | API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | TextareaProps.value | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | +| TextareaProps.defaultValue | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | TextareaProps.placeholder | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | TextareaProps.placeholderStyle | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | | TextareaProps.placeholderClass | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | diff --git a/docs/components/maps/map.md b/docs/components/maps/map.md index ed7e181afa99..fbea4ce92ad2 100755 --- a/docs/components/maps/map.md +++ b/docs/components/maps/map.md @@ -105,7 +105,7 @@ export default { | minScale | `number` | `3` | 否 | 最小缩放级别 3-20 | | maxScale | `number` | `20` | 否 | 最大缩放级别 3-20 | | markers | `marker[]` | | 否 | 标记点 | -| covers | `any[]` | | 否 | 标记点 | +| covers | `any[]` | | 否 | **即将移除,请使用 markers**
**不推荐使用** | | polyline | `polyline[]` | | 否 | 路线 | | circles | `circle[]` | | 否 | 圆 | | controls | `control[]` | | 否 | 控件(即将废弃,建议使用 cover-view 代替)
**不推荐使用** | @@ -145,8 +145,14 @@ export default { | onUpdated | `CommonEventFunction` | | 否 | 在地图渲染更新完成时触发 | | onRegionChange | CommonEventFunction or onRegionEventDetail<"end">> | | 否 | 视野发生变化时触发 | | onPoiTap | `CommonEventFunction` | | 否 | 点击地图poi点时触发,e.detail = {name, longitude, latitude} | -| onCallOutTap | `CommonEventFunction` | | 否 | 点击标记点对应的气泡时触发e.detail = {markerId} | -| onAnchorPointTap | `CommonEventFunction` | | 否 | 点击定位标时触发,e.detail = {longitude, latitude} | +| onPolylineTap | `CommonEventFunction` | | 否 | 点击地图路线时触发,e.detail = {longitude, latitude} | +| onAbilitySuccess | `CommonEventFunction` | | 否 | 地图能力生效时触发,e.detail = {ability, errCode, errMsg} | +| onAbilityFailed | `CommonEventFunction` | | 否 | 地图能力失败时触发,e.detail = {ability, errCode, errMsg} | +| onAuthSuccess | `CommonEventFunction<{ errCode: number; errMsg: string; }>` | | 否 | 地图鉴权结果成功时触发,e.detail = {errCode, errMsg} | +| onInterpolatePoint | `CommonEventFunction` | | 否 | MapContext.moveAlong 插值动画时触发。e.detail = {markerId, longitude, latitude, animationStatus: "interpolating" or "complete"} | +| onError | `CommonEventFunction` | | 是 | 组件错误时触发,例如创建或鉴权失败,e.detail = {longitude, latitude} | +| onCallOutTap | `CommonEventFunction` | | 否 | 点击标记点对应的气泡时触发e.detail = {markerId} | +| onAnchorPointTap | `CommonEventFunction` | | 否 | 点击定位标时触发,e.detail = {longitude, latitude} | | onPanelTap | `CommonEventFunction<{ panelId: any; layoutId: any; }>` | | 否 | 点击 panel 时触发。 | | onInitComplete | `CommonEventFunction` | | 否 | 地图初始化完成即将开始渲染第一帧时触发。 | @@ -200,6 +206,12 @@ export default { | MapProps.onUpdated | ✔️ | ✔️ | | ✔️ | ✔️ | | | | | | MapProps.onRegionChange | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | | MapProps.onPoiTap | ✔️ | ✔️ | | | ✔️ | | | | | +| MapProps.onPolylineTap | ✔️ | ✔️ | | | ✔️ | | | | | +| MapProps.onAbilitySuccess | ✔️ | | | | | | | | | +| MapProps.onAbilityFailed | ✔️ | | | | | | | | | +| MapProps.onAuthSuccess | ✔️ | | | | | | | | | +| MapProps.onInterpolatePoint | ✔️ | | | | | | | | | +| MapProps.onError | ✔️ | | | | | | | | | | MapProps.onCallOutTap | ✔️ | ✔️ | | ✔️ | | ✔️ | | | | | MapProps.onAnchorPointTap | ✔️ | | | ✔️ | | | | | | | MapProps.onPanelTap | | | ✔️ | | | | | | | @@ -456,3 +468,28 @@ marker 上的气泡 label | name | `string` | | longitude | `number` | | latitude | `number` | + +### onPolylineTapEventDetail + +| 参数 | 类型 | +| --- | --- | +| polylineId | `number` | +| longitude | `number` | +| latitude | `number` | + +### onAbilityEventDetail + +| 参数 | 类型 | +| --- | --- | +| ability | `string` | +| errCode | `number` | +| errMsg | `string` | + +### onInterpolatePointEventDetail + +| 参数 | 类型 | +| --- | --- | +| markerId | `number` | +| longitude | `number` | +| latitude | `number` | +| animationStatus | "interpolating" or "complete" | diff --git a/docs/components/media/channel-video.md b/docs/components/media/channel-video.md index ea93bac3f336..1dfc6f1263bc 100644 --- a/docs/components/media/channel-video.md +++ b/docs/components/media/channel-video.md @@ -19,13 +19,13 @@ ComponentType | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | -| feedId | `string` | | 是 | 视频 feedId | +| feedId | `string` | | 是 | 仅视频号视频与小程序同主体时生效。若内嵌非同主体视频,请使用 feed-token。 | | finderUserName | `string` | | 是 | 视频号 id,以“sph”开头的id,可在视频号助手获取。视频号必须与当前小程序相同主体。 | | loop | `boolean` | `false` | 否 | 是否循环播放 | | muted | `boolean` | `false` | 否 | 是否静音播放 | | objectFit | "fill" or "contain" or "cover" | `"contain"` | 否 | 当视频大小与 video 容器大小不一致时,视频的表现形式 | | autoplay | `boolean` | `false` | 否 | 是否自动播放 | -| feedToken | `string` | | 否 | 仅内嵌小程序非同主体视频号视频时使用,获取方式参考本指引。 | +| feedToken | `string` | | 否 | 仅内嵌小程序非同主体视频号视频时使用,获取方式参考[本指引](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/channels-activity.html#feed-token)。 | | onError | `CommonEventFunction` | | 否 | 视频播放出错时触发 | ### API 支持度 diff --git a/docs/components/media/live-player.md b/docs/components/media/live-player.md index f03ecefa300b..955957440277 100755 --- a/docs/components/media/live-player.md +++ b/docs/components/media/live-player.md @@ -64,8 +64,8 @@ class App extends Components { | soundMode | `keyof soundMode` | `"speaker"` | 否 | 声音输出方式 | | autoPauseIfNavigate | `boolean` | `true` | 否 | 当跳转到本小程序的其他页面时,是否自动暂停本页面的实时音视频播放 | | pictureInPictureMode | "" or "push" or "pop" or ("push" or "pop")[] | | 否 | 设置小窗模式: push, pop,空字符串或通过数组形式设置多种模式(如: ["push", "pop"]) | -| autoPauseIfOpenNative | `string` | | 否 | 当跳转到其它微信原生页面时,是否自动暂停本页面的实时音视频播放 | -| referrerPolicy | "origin" or "no-referrer" | | 否 | 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; | +| autoPauseIfOpenNative | `boolean` | `true` | 否 | 当跳转到其它微信原生页面时,是否自动暂停本页面的实时音视频播放 | +| referrerPolicy | "origin" or "no-referrer" | `'no-referrer'` | 否 | 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html ,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; | | signature | `string` | | 否 | 设置署名水印 | | enableMetadata | `string` | | 否 | 是否回调metadata | | id | `string` | | 否 | live-player 属性的唯一标志符 | @@ -79,8 +79,8 @@ class App extends Components { | onLeavePictureInPicture | `CommonEventFunction` | | 否 | 播放器退出小窗 | | onError | `CommonEventFunction` | | 否 | 播放错误事件 | | onMetaDataChange | `CommonEventFunction` | | 否 | metadata通知,detail = {info} | -| onCastingUserSelect | `CommonEventFunction` | | 否 | 用户选择投屏设备时触发 detail = { state: "success"/"fail" } | -| onCastingStateChange | `CommonEventFunction` | | 否 | 投屏成功/失败时触发 detail = { type, state: "success"/"fail" } | +| onCastingUserSelect | CommonEventFunction<{ state: "success" or "fail"; }> | | 否 | 用户选择投屏设备时触发 detail = { state: "success"/"fail" } | +| onCastingStateChange | CommonEventFunction<{ type: any; state: "success" or "fail"; }> | | 否 | 投屏成功/失败时触发 detail = { type, state: "success"/"fail" } | | onCastingInterrupt | `CommonEventFunction` | | 否 | 投屏被中断时触发 | ### API 支持度 diff --git a/docs/components/media/video.md b/docs/components/media/video.md index 7010ff06b9c1..e4ac14f59412 100755 --- a/docs/components/media/video.md +++ b/docs/components/media/video.md @@ -111,16 +111,16 @@ export default class PageView extends Component { | showBackgroundPlaybackButton | `boolean` | | 否 | 是否展示后台音频播放按钮 | | backgroundPoster | `string` | | 否 | 进入后台音频播放后的通知栏图标(Android 独有) | | nativeProps | `Record` | | 否 | 用于透传 `WebComponents` 上的属性到内部 H5 标签上 | -| showBottomProgress | `string` | | 否 | 是否展示底部进度条 | +| showBottomProgress | `boolean` | `true` | 否 | 是否展示底部进度条 | | pictureInPictureShowProgress | `string` | | 否 | 是否在小窗模式下显示播放进度 | | referrerPolicy | "origin" or "no-referrer" | | 否 | 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; | -| isDrm | `string` | | 否 | 是否是 DRM 视频源 | +| isDrm | `boolean` | | 否 | 是否是 DRM 视频源 | | provisionUrl | `string` | | 否 | DRM 设备身份认证 url,仅 is-drm 为 true 时生效 (Android) | | certificateUrl | `string` | | 否 | DRM 设备身份认证 url,仅 is-drm 为 true 时生效 (iOS) | | licenseUrl | `string` | | 否 | DRM 获取加密信息 url,仅 is-drm 为 true 时生效 | | posterSize | `string` | | 否 | 当 poster 高宽比跟视频高宽不匹配时,如何显示 poster,设置规则同 background-size 一致。 | | showThinProgressBar | `string` | | 否 | 当底部工具条隐藏时,是否显示细进度条(controls=false 时设置无效)。 | -| mobilenetHintType | `string` | | 否 | 移动网络提醒样式。

0 - 不提醒
1 - tip 提醒
2 - 阻塞提醒(无消耗流量大小)
3 - 阻塞提醒(有消耗流量大小提醒) | +| mobilenetHintType | `number` | | 否 | 移动网络提醒样式。

0 - 不提醒
1 - tip 提醒
2 - 阻塞提醒(无消耗流量大小)
3 - 阻塞提醒(有消耗流量大小提醒) | | floatingMode | `string` | | 否 | 浮窗设置。暂时不支持全局浮窗。
可选值:

none:无浮窗。
page:页面内浮窗。 | | showNoWifiTip | `string` | | 否 | 非 wifi 环境下是否显示继续播放浮层 | | showLockBtn | `string` | | 否 | 全屏模式下,是否显示锁屏按钮 | @@ -311,6 +311,15 @@ playBtnPosition 的合法值 | --- | --- | --- | | currentTime | `number` | 当前时间 | | duration | `number` | 持续时间 | +| userPlayDuration | `number` | 用户实际观看时长 | +| videoDuration | `number` | 视频总时长 | + +#### API 支持度 + +| API | 微信小程序 | 支付宝小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | +| onTimeUpdateEventDetail.userPlayDuration | | ✔️ | | | | +| onTimeUpdateEventDetail.videoDuration | | ✔️ | | | | ### onFullscreenChangeEventDetail diff --git a/docs/components/navig/navigation-bar.md b/docs/components/navig/navigation-bar.md index fe36d5b60746..2f4dd6a82810 100644 --- a/docs/components/navig/navigation-bar.md +++ b/docs/components/navig/navigation-bar.md @@ -6,6 +6,11 @@ sidebar_label: NavigationBar 页面导航条配置节点,用于指定导航栏的一些属性。只能是 PageMeta 组件内的第一个节点,需要配合它一同使用。 通过这个节点可以获得类似于调用 Taro.setNavigationBarTitle Taro.setNavigationBarColor 等接口调用的效果。 +:::info +Taro v3.6.19 开始支持 +需要配合 PageMeta 组件使用 +::: + 支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/component/navigation-bar.html) diff --git a/docs/components/page-meta.md b/docs/components/page-meta.md index fbc135211963..7a6732593785 100644 --- a/docs/components/page-meta.md +++ b/docs/components/page-meta.md @@ -6,6 +6,11 @@ sidebar_label: PageMeta 页面属性配置节点,用于指定页面的一些属性、监听页面事件。只能是页面内的第一个节点。可以配合 navigation-bar 组件一同使用。 通过这个节点可以获得类似于调用 Taro.setBackgroundTextStyle Taro.setBackgroundColor 等接口调用的效果。 +:::info +Taro v3.6.19 开始支持 +开发者需要在页面配置里添加:`enablePageMeta: true` +::: + 支持情况: > [参考文档](https://developers.weixin.qq.com/miniprogram/dev/component/page-meta.html) @@ -16,6 +21,55 @@ sidebar_label: PageMeta ComponentType ``` +## 示例代码 + +import { ReactIcon, VueIcon } from '@site/static/icons' +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' + +, value: "React" }, { label: , value: "Vue" }]}> + + +```tsx +// page.config.ts +export default definePageConfig({ enablePageMeta: true, ... }) + +// page.tsx +function Index () { + return ( + + + + + + ) +} +``` + + + +```html + + + + + +``` + + + ## PageMetaProps | 参数 | 类型 | 默认值 | 必填 | 说明 | @@ -56,18 +110,21 @@ ComponentType ### onResizeEventDetail -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| size | `resizeType` | 窗口尺寸 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| deviceOrientation | "portrait" or "landscape" | 否 | 设备方向 | +| size | `resizeType` | 是 | 窗口尺寸 | ### resizeType 窗口尺寸类型 -| 参数 | 类型 | 说明 | -| --- | --- | --- | -| windowWidth | `number` | 窗口宽度 | -| windowHeight | `number` | 窗口高度 | +| 参数 | 类型 | 必填 | 说明 | +| --- | --- | :---: | --- | +| windowWidth | `number` | 是 | 窗口宽度 | +| windowHeight | `number` | 是 | 窗口高度 | +| screenWidth | `number` | 否 | 屏幕宽度 | +| screenHeight | `number` | 否 | 屏幕高度 | ### onScrollEventDetail diff --git a/docs/components/skyline/grid-view.md b/docs/components/skyline/grid-view.md new file mode 100644 index 000000000000..c7bd828e55a8 --- /dev/null +++ b/docs/components/skyline/grid-view.md @@ -0,0 +1,36 @@ +--- +title: GridView +sidebar_label: GridView +--- + +网格布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/component/grid-view.html) + +## 类型 + +```tsx +ComponentType +``` + +## GridViewProps + +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| type | `string` | `"aligned"` | 是 | 布局方式。masonry - 瀑布流,根据子元素高度自动布局。 aligned - 每行高度由同一行中最大高度子节点决定。 | +| crossAxisCount | `number` | `2` | 否 | 交叉轴元素数量 | +| mainAxisGap | `number` | `0` | 否 | 主轴方向间隔 | +| crossAxisGap | `number` | `0` | 否 | 交叉轴方向间隔 | +| maxCrossAxisExtent | `number` | `0` | 否 | 交叉轴元素最大范围 | + +### API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| GridViewProps.type | ✔️ | | | | +| GridViewProps.crossAxisCount | ✔️ | | | | +| GridViewProps.mainAxisGap | ✔️ | | | | +| GridViewProps.crossAxisGap | ✔️ | | | | +| GridViewProps.maxCrossAxisExtent | ✔️ | | | | diff --git a/docs/components/skyline/list-view.md b/docs/components/skyline/list-view.md new file mode 100644 index 000000000000..372eb444c69a --- /dev/null +++ b/docs/components/skyline/list-view.md @@ -0,0 +1,18 @@ +--- +title: ListView +sidebar_label: ListView +--- + +列表布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/component/list-view.html) + +## 类型 + +```tsx +ComponentType +``` + +## ListViewProps diff --git a/docs/components/skyline/share-element.md b/docs/components/skyline/share-element.md new file mode 100644 index 000000000000..e130ddf1a29d --- /dev/null +++ b/docs/components/skyline/share-element.md @@ -0,0 +1,257 @@ +--- +title: ShareElement +sidebar_label: ShareElement +--- + +共享元素 + +共享元素是一种动画形式,类似于 [`flutter Hero`](https://flutterchina.club/animations/hero-animations/) 动画,表现为元素像是在页面间穿越一样。该组件需与 [`PageContainer`](/docs/components/viewContainer/page-container) 组件结合使用。 +使用时需在当前页放置 `ShareElement` 组件,同时在 `PageContainer` 容器中放置对应的 `ShareElement` 组件,对应关系通过属性值 key 映射。当设置 `PageContainer` `显示时,transform` 属性为 `true` 的共享元素会产生动画。当前页面容器退出时,会产生返回动画。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/component/share-element.html) + +## 类型 + +```tsx +ComponentType +``` + +## 示例代码 + +import { ReactIcon, VueIcon } from '@site/static/icons' +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' + +, value: "React" }]}> + + +```tsx +// index.js +import { useState, useCallback } from 'react' +import { View, Button, PageContainer, ShareElement } from '@tarojs/components' + +import './index.scss' + +const contacts = [ + { id: 1, name: 'Frank', img: 'frank.png', phone: '0101 123456', mobile: '0770 123456', email: 'frank@emailionicsorter.com' }, + { id: 2, name: 'Susan', img: 'susan.png', phone: '0101 123456', mobile: '0770 123456', email: 'frank@emailionicsorter.com' }, + { id: 3, name: 'Emma', img: 'emma.png', phone: '0101 123456', mobile: '0770 123456', email: 'frank@emailionicsorter.com' }, + { id: 4, name: 'Scott', img: 'scott.png', phone: '0101 123456', mobile: '0770 123456', email: 'frank@emailionicsorter.com' }, + { id: 5, name: 'Bob', img: 'bob.png', phone: '0101 123456', mobile: '0770 123456', email: 'frank@emailionicsorter.com' }, + { id: 6, name: 'Olivia', img: 'olivia.png', phone: '0101 123456', mobile: '0770 123456', email: 'frank@emailionicsorter.com' }, + { id: 7, name: 'Anne', img: 'anne.png', phone: '0101 123456', mobile: '0770 123456', email: 'frank@emailionicsorter.com' }, + { id: 8, name: 'sunny', img: 'olivia.png', phone: '0101 123456', mobile: '0770 123456', email: 'frank@emailionicsorter.com' } +] + +export default function () { + const [show, setShow] = useState(false) + const [contact, setContact] = useState(contacts[0]) + const [transformIdx, setTransformIdx] = useState(0) + + const onBeforeEnter = useCallback((res) => { + console.log('onBeforeEnter: ', res) + }, []) + const onEnter = useCallback((res) => { + console.log('onEnter: ', res) + }, []) + const onAfterEnter = useCallback((res) => { + console.log('onAfterEnter: ', res) + }, []) + const onBeforeLeave = useCallback((res) => { + console.log('onBeforeLeave: ', res) + }, []) + const onLeave = useCallback((res) => { + console.log('onLeave: ', res) + }, []) + const onAfterLeave = useCallback((res) => { + console.log('onAfterLeave: ', res) + }, []) + + const showNext = (e, index) => { + setShow(true) + setContact(contacts[index]) + setTransformIdx(index) + } + + const showPrev = useCallback(() => { + setShow(false) + }, []) + + return ( + + + { + contacts.map((item, index) => ( + showNext(e, index)}> + + {item.name} + + + Phone: {item.phone} + Mobile: {item.mobile} + Email: {item.email} + + + )) + } + + + + + + {contact.name} + + + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus nisl enim, sodales non augue efficitur, sagittis + varius neque. Fusce dolor turpis, maximus eu volutpat quis, pellentesque et ligula. Ut vehicula metus in nibh + mollis ornare. Etiam aliquam lacinia malesuada. Vestibulum dignissim mollis quam a tristique. Maecenas neque + mauris, malesuada vitae magna eu, congue consectetur risus. Etiam vitae pulvinar ex. Maecenas suscipit mi ac + imperdiet pretium. Aliquam velit mauris, euismod quis elementum sed, malesuada non dui. Nunc rutrum sagittis + ligula in dapibus. Cras suscipit ut augue eget mollis. Donec auctor feugiat ipsum id viverra. Vestibulum eu nisi + risus. Vestibulum eleifend dignissim. + + + + + + + + ) +} +``` +```scss +\/** index.scss *\/ +page { + color: #333; + background-color: #ddd; + overflow: hidden; +} + +button { + border: 0 solid #0010ae; + background-color: #1f2afe; + color: #fff; + font-size: 120%; + padding: 8px 16px; + outline-width: 0; + -webkit-appearance: none; + box-shadow: 0 8px 17px rgba(0, 0, 0, 0.2); +} + +.screen { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + padding: 16px; + -webkit-overflow-scrolling: touch; +} + +.contact { + position: relative; + padding: 16px; + background-color: #fff; + width: 100%; + height: 100%; + box-sizing: border-box; +} + +.avatar { + position: absolute; + top: 16px; + left: 16px; + font-size: 0; +} + +.name { + height: 65px; + font-size: 2em; + font-weight: bold; + text-align: center; + margin: 10px 0; +} + +.list { + padding-top: 8px; + padding-left: 32px; +} + +.screen1 { + overflow-y: scroll; + padding: 0; +} + +.screen1 .contact { + margin: 16px; + height: auto; + width: auto; + box-shadow: 0 2px 5px 0 rgba(0, 0, 0, 0.2); +} + +.screen2-button { + display: block; + margin: 24px auto; +} + +.paragraph { + -webkit-transition: transform ease-in-out 300ms; + transition: transform ease-in-out 300ms; + -webkit-transform: scale(0.6); + transform: scale(0.6); +} + +.enter.paragraph { + transform: none; +} +``` + + + +## ShareElementProps + +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| key | `string` | | 否 | 映射标记
不推荐: 使用mapkey替换key | +| mapkey | `string` | | 否 | 映射标记 | +| name | `string` | | 否 | 映射标记 | +| transform | `boolean` | `false` | 否 | 是否进行动画 | +| duration | `number` | `300` | 否 | 动画时长,单位毫秒 | +| easingFunction | `string` | `ease-out` | 否 | css缓动函数 | +| transitionOnGesture | `boolean` | `false` | 否 | 手势返回时是否进行动画 | +| shuttleOnPush | "from" or "to" | `"to"` | 否 | 指定 push 阶段的飞跃物 | +| shuttleOnPop | `string` | `"to"` | 否 | 指定 pop 阶段的飞跃物 | +| rectTweenType | "materialRectArc" or "materialRectCenterArc" or "linear" or "elasticIn" or "elasticOut" or "elasticInOut" or "bounceIn" or "bounceOut" or "bounceInOut" or "cubic-bezier(x1," | `"materialRectArc"` | 否 | 动画插值曲线 | +| onFrame | `string` | | 否 | 动画帧回调 | + +### API 支持度 + +| API | 微信小程序 | 支付宝小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | +| ShareElementProps.key | ✔️ | | | | | +| ShareElementProps.mapkey | ✔️ | | | | | +| ShareElementProps.name | | ✔️ | | | | +| ShareElementProps.transform | ✔️ | ✔️ | | | | +| ShareElementProps.duration | ✔️ | ✔️ | | | | +| ShareElementProps.easingFunction | ✔️ | ✔️ | | | | +| ShareElementProps.transitionOnGesture | ✔️ | | | | | +| ShareElementProps.shuttleOnPush | ✔️ | | | | | +| ShareElementProps.shuttleOnPop | ✔️ | | | | | +| ShareElementProps.rectTweenType | ✔️ | | | | | +| ShareElementProps.onFrame | ✔️ | | | | | diff --git a/docs/components/skyline/snapshot.md b/docs/components/skyline/snapshot.md new file mode 100644 index 000000000000..282efa0e0423 --- /dev/null +++ b/docs/components/skyline/snapshot.md @@ -0,0 +1,23 @@ +--- +title: Snapshot +sidebar_label: Snapshot +--- + +截图组件。 +支持将其子节点的渲染结果导出成图片,该组件需配合 snapshot 接口使用。 目前仅在 Skyline 渲染引擎 下支持。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/component/snapshot.html) + +## 类型 + +```tsx +ComponentType +``` + +## SnapshotProps + +| 参数 | 类型 | +| --- | --- | +| id | `string` | diff --git a/docs/components/skyline/sticky-header.md b/docs/components/skyline/sticky-header.md new file mode 100644 index 000000000000..574096078600 --- /dev/null +++ b/docs/components/skyline/sticky-header.md @@ -0,0 +1,18 @@ +--- +title: StickyHeader +sidebar_label: StickyHeader +--- + +吸顶布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/component/sticky-header.html) + +## 类型 + +```tsx +ComponentType +``` + +## StickyHeaderProps diff --git a/docs/components/skyline/sticky-section.md b/docs/components/skyline/sticky-section.md new file mode 100644 index 000000000000..952115cf4eef --- /dev/null +++ b/docs/components/skyline/sticky-section.md @@ -0,0 +1,28 @@ +--- +title: StickySection +sidebar_label: StickySection +--- + +吸顶布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点。仅 Skyline 支持。 + +支持情况: + +> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/component/sticky-section.html) + +## 类型 + +```tsx +ComponentType +``` + +## StickySectionProps + +| 参数 | 类型 | 默认值 | 必填 | 说明 | +| --- | --- | :---: | :---: | --- | +| pushPinnedHeader | `boolean` | `true` | 否 | 吸顶元素重叠时是否继续上推 | + +### API 支持度 + +| API | 微信小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | +| StickySectionProps.pushPinnedHeader | ✔️ | | | | diff --git a/docs/components/viewContainer/script.md b/docs/components/viewContainer/script.md new file mode 100644 index 000000000000..8d3980be6d73 --- /dev/null +++ b/docs/components/viewContainer/script.md @@ -0,0 +1,56 @@ +--- +title: Script +sidebar_label: Script +--- + +script 类似微信小程序的 wxs 标签,支持引用各种小程序的 xs 文件 +只能在 CompileMode 中使用 + +支持情况: + +## 类型 + +```tsx +ComponentType +``` + +## 示例代码 + +import { ReactIcon, VueIcon } from '@site/static/icons' +import Tabs from '@theme/Tabs' +import TabItem from '@theme/TabItem' + +, value: "React" }]}> + + +```tsx +import { Component } from 'react' +import { View, Script } from '@tarojs/components' + +export function Index () { + return ( + + + Hello, {logic.name}! + + ) +} +``` + + + +## ScriptProps + +| 参数 | 类型 | 说明 | +| --- | --- | --- | +| src | `string` | xs 文件的相对路径 | +| module | `string` | xs 模块名 | + +### API 支持度 + +| API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | 京东小程序 | H5 | React Native | Harmony | +| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | +| ScriptProps.src | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | +| ScriptProps.module | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | diff --git a/docs/components/viewContainer/scroll-view.md b/docs/components/viewContainer/scroll-view.md index a7d004d351d6..bbb206854655 100755 --- a/docs/components/viewContainer/scroll-view.md +++ b/docs/components/viewContainer/scroll-view.md @@ -172,6 +172,12 @@ export default { ## ScrollViewProps +### 类型 + +```tsx +typeof ScrollViewProps +``` + | 参数 | 类型 | 默认值 | 必填 | 说明 | | --- | --- | :---: | :---: | --- | | scrollX | `boolean` | `false` | 否 | 允许横向滚动 | @@ -191,6 +197,7 @@ export default { | refresherBackground | `string` | `'#FFF'` | 否 | 设置自定义下拉刷新区域背景颜色 | | refresherTriggered | `boolean` | `false` | 否 | 设置当前下拉刷新状态,true 表示下拉刷新已经被触发,false 表示下拉刷新未被触发 | | enhanced | `boolean` | `false` | 否 | 启用 scroll-view 增强特性 | +| usingSticky | `boolean` | `false` | 否 | 使 scroll-view 下的 position sticky 特性生效,否则滚动一屏后 sticky 元素会被隐藏 | | bounces | `boolean` | `true` | 否 | iOS 下 scroll-view 边界弹性控制 (同时开启 enhanced 属性后生效) | | showScrollbar | `boolean` | `true` | 否 | 滚动条显隐控制 (同时开启 enhanced 属性后生效) | | pagingEnabled | `boolean` | `false` | 否 | 分页滑动效果 (同时开启 enhanced 属性后生效) | @@ -200,12 +207,22 @@ export default { | disableLowerScroll | `string` | | 否 | 发生滚动前,对滚动方向进行判断,当方向是顶部/左边时,如果值为 always 将始终禁止滚动,如果值为 out-of-bounds 且当前已经滚动到顶部/左边,禁止滚动。 | | disableUpperScroll | `string` | | 否 | 发生滚动前,对滚动方向进行判断,当方向是底部/右边时,如果值为 always 将始终禁止滚动,如果值为 out-of-bounds 且当前已经滚动到底部/右边,禁止滚动。 | | ariaLabel | `string` | | 否 | 无障碍访问,(属性)元素的额外描述 | -| enablePassive | `string` | `false` | 否 | 开启 passive 特性,能优化一定的滚动性能 | +| enablePassive | `boolean` | `false` | 否 | 开启 passive 特性,能优化一定的滚动性能 | | type | "list" or "custom" | `'list'` | 否 | 渲染模式
list - 列表模式。只会渲染在屏节点,会根据直接子节点是否在屏来按需渲染,若只有一个直接子节点则性能会退化
custom - 自定义模式。只会渲染在屏节点,子节点可以是 sticky-section list-view grid-view 等组件 | | reverse | `boolean` | `false` | 否 | 是否反向滚动。一般初始滚动位置是在顶部,反向滚动则是在底部。 | +| clip | `boolean` | `true` | 否 | 是否对溢出进行裁剪,默认开启 | | cacheExtent | `number` | | 否 | 指定视口外渲染区域的距离,默认情况下视口外节点不渲染。指定 cache-extent 可优化滚动体验和加载速度,但会提高内存占用且影响首屏速度,可按需启用。 | +| minDragDistance | `number` | `18` | 否 | 指定 scroll-view 触发滚动的最小拖动距离。仅在 scroll-view 和其他组件存在手势冲突时使用,可通过调整该属性使得滚动更加灵敏。 | +| padding | `[number, number, number, number]` | `[0,0,0,0]` | 否 | 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距 | | scrollIntoViewWithinExtent | `boolean` | `false` | 否 | 只 scroll-into-view 到 cacheExtent 以内的目标节点,性能更佳 | | scrollIntoViewAlignment | "start" or "center" or "end" or "nearest" | `'start'` | 否 | 指定 scroll-into-view 目标节点在视口内的位置。
start - 目标节点显示在视口开始处
center - 目标节点显示在视口中间
end - 目标节点显示在视口结束处
nearest - 目标节点在就近的视口边缘显示,若节点已在视口内则不触发滚动 | +| refresherTwoLevelEnabled | `boolean` | `false` | 否 | 开启下拉二级能力 | +| refresherTwoLevelTriggered | `boolean` | `false` | 否 | 设置打开/关闭二级 | +| refresherTwoLevelThreshold | `number` | `150` | 否 | 下拉二级阈值 | +| refresherTwoLevelCloseThreshold | `number` | `80` | 否 | 滑动返回时关闭二级的阈值 | +| refresherTwoLevelScrollEnabled | `boolean` | `false` | 否 | 处于二级状态时是否可滑动 | +| refresherBallisticRefreshEnabled | `boolean` | `false` | 否 | 惯性滚动是否触发下拉刷新 | +| refresherTwoLevelPinned | `boolean` | `false` | 否 | 即将打开二级时否定住 | | onScrollToUpper | `CommonEventFunction` | | 否 | 滚动到顶部/左边,会触发 scrolltoupper 事件 | | onScrollToLower | `CommonEventFunction` | | 否 | 滚动到底部/右边,会触发 scrolltolower 事件 | | onScroll | `BaseEventOrigFunction` | | 否 | 滚动时触发 | @@ -216,6 +233,7 @@ export default { | onRefresherRestore | `CommonEventFunction` | | 否 | 自定义下拉刷新被复位 | | onRefresherAbort | `CommonEventFunction` | | 否 | 自定义下拉刷新被中止 | | onRefresherWillRefresh | `CommonEventFunction` | | 否 | 自定义下拉刷新即将触发刷新(拖动超过 refresher-threshold 时)的事件 | +| onRefresherStatusChange | `CommonEventFunction` | | 否 | 下拉刷新状态回调 | | onDragStart | `CommonEventFunction` | | 否 | 滑动开始事件 (同时开启 enhanced 属性后生效) | | onDragging | `CommonEventFunction` | | 否 | 滑动事件 (同时开启 enhanced 属性后生效) | | onDragEnd | `CommonEventFunction` | | 否 | 滑动结束事件 (同时开启 enhanced 属性后生效) | @@ -245,6 +263,7 @@ export default { | ScrollViewProps.refresherBackground | ✔️ | | | | | | | | | | ScrollViewProps.refresherTriggered | ✔️ | | | | | | | | | | ScrollViewProps.enhanced | ✔️ | ✔️ | | | | | | | | +| ScrollViewProps.usingSticky | ✔️ | | | | | | | | | | ScrollViewProps.bounces | ✔️ | ✔️ | | | | | | | | | ScrollViewProps.showScrollbar | ✔️ | | | | | | | | | | ScrollViewProps.pagingEnabled | ✔️ | | | | | | | | | @@ -257,9 +276,19 @@ export default { | ScrollViewProps.enablePassive | ✔️ | | | | | | | | | | ScrollViewProps.type | ✔️ | | | | | | | | | | ScrollViewProps.reverse | ✔️ | | | | | | | | | +| ScrollViewProps.clip | ✔️ | | | | | | | | | | ScrollViewProps.cacheExtent | ✔️ | | | | | | | | | +| ScrollViewProps.minDragDistance | ✔️ | | | | | | | | | +| ScrollViewProps.padding | ✔️ | | | | | | | | | | ScrollViewProps.scrollIntoViewWithinExtent | ✔️ | | | | | | | | | | ScrollViewProps.scrollIntoViewAlignment | ✔️ | | | | | | ✔️ | | | +| ScrollViewProps.refresherTwoLevelEnabled | ✔️ | | | | | | | | | +| ScrollViewProps.refresherTwoLevelTriggered | ✔️ | | | | | | | | | +| ScrollViewProps.refresherTwoLevelThreshold | ✔️ | | | | | | | | | +| ScrollViewProps.refresherTwoLevelCloseThreshold | ✔️ | | | | | | | | | +| ScrollViewProps.refresherTwoLevelScrollEnabled | ✔️ | | | | | | | | | +| ScrollViewProps.refresherBallisticRefreshEnabled | ✔️ | | | | | | | | | +| ScrollViewProps.refresherTwoLevelPinned | ✔️ | | | | | | | | | | ScrollViewProps.onScrollToUpper | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | ScrollViewProps.onScrollToLower | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | ScrollViewProps.onScroll | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | @@ -270,6 +299,7 @@ export default { | ScrollViewProps.onRefresherRestore | ✔️ | | | | | | | | | | ScrollViewProps.onRefresherAbort | ✔️ | | | | | | | | | | ScrollViewProps.onRefresherWillRefresh | ✔️ | | | | | | | | | +| ScrollViewProps.onRefresherStatusChange | ✔️ | | | | | | | | | | ScrollViewProps.onDragStart | ✔️ | | | | | | | | | | ScrollViewProps.onDragging | ✔️ | | | | | | | | | | ScrollViewProps.onDragEnd | ✔️ | | | | | | | | | @@ -278,6 +308,10 @@ export default { | ScrollViewProps.onTouchEnd | | | ✔️ | | | | | | | | ScrollViewProps.onTouchCancel | | | ✔️ | | | | | | | +| 参数 | 类型 | +| --- | --- | +| RefreshStatus | `typeof RefreshStatus` | + ### onScrollDetail | 参数 | 类型 | 必填 | 说明 | @@ -297,3 +331,10 @@ export default { | scrollLeft | `number` | 横向滚动条位置 | | scrollTop | `number` | 竖向滚动条位置 | | velocity | `number` | 滚动速度 | + +### RefresherStatusChange + +| 参数 | 类型 | +| --- | --- | +| status | `RefreshStatus` | +| dy | `number` | diff --git a/docs/components/viewContainer/swiper-item.md b/docs/components/viewContainer/swiper-item.md index d7b840dcc1b0..eed2f1dc6e97 100644 --- a/docs/components/viewContainer/swiper-item.md +++ b/docs/components/viewContainer/swiper-item.md @@ -88,6 +88,7 @@ class App extends Component { | --- | --- | :---: | :---: | --- | | itemId | `string` | | 否 | 该 swiper-item 的标识符 | | skipHiddenItemLayout | `boolean` | `false` | 否 | 是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息 | +| deep | `boolean` | `false` | 否 | Swiper 循环状态下,前后垫片节点拷贝模式,用于修复 Vue 在 CustomElements 下的节点拷贝问题 | ### API 支持度 @@ -95,3 +96,4 @@ class App extends Component { | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | SwiperItemProps.itemId | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SwiperItemProps.skipHiddenItemLayout | ✔️ | | | | | | | +| SwiperItemProps.deep | | | | | ✔️ | | | diff --git a/docs/components/viewContainer/swiper.md b/docs/components/viewContainer/swiper.md index b37a8b3b91a9..fbfdd2066356 100755 --- a/docs/components/viewContainer/swiper.md +++ b/docs/components/viewContainer/swiper.md @@ -131,6 +131,7 @@ class App extends Component { | SwiperProps.indicatorActiveColor | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SwiperProps.autoplay | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SwiperProps.current | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | +| SwiperProps.currentItemId | (deprecated) | ✔️ | | ✔️ | ✔️ | ✔️ | ✔️ | | | | SwiperProps.interval | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | SwiperProps.duration | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | | | SwiperProps.circular | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | | diff --git a/packages/taro-components/types/Audio.d.ts b/packages/taro-components/types/Audio.d.ts index 85ffa4eb17d5..5885bf7d5543 100644 --- a/packages/taro-components/types/Audio.d.ts +++ b/packages/taro-components/types/Audio.d.ts @@ -6,22 +6,22 @@ interface AudioProps extends StandardProps { */ id?: string /** 要播放音频的资源地址 - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ src?: string /** 是否循环播放 * @default false - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ loop?: boolean /** 是否静音播放 * @default false - * @supported h5 + * @supported h5, harmony_hybrid */ muted?: boolean /** 是否显示默认控件 * @default false - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ controls?: boolean /** 默认控件上的音频封面的图片资源地址,如果 controls 属性值为 false 则设置 poster 无效 @@ -39,27 +39,27 @@ interface AudioProps extends StandardProps { */ author?: string /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 当发生错误时触发 error 事件,detail = {errMsg: MediaError.code} - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ onError?: CommonEventFunction /** 当开始/继续播放时触发play事件 - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ onPlay?: CommonEventFunction /** 当暂停播放时触发 pause 事件 - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ onPause?: CommonEventFunction /** 当播放进度改变时触发 timeupdate 事件,detail = {currentTime, duration} - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ onTimeUpdate?: CommonEventFunction /** 当播放到末尾时触发 ended 事件 - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ onEnded?: CommonEventFunction } @@ -89,7 +89,7 @@ declare namespace AudioProps { /** 音频。1.6.0版本开始,该组件不再维护。建议使用能力更强的 Taro.createInnerAudioContext 接口 * @classification media * @deprecated - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/Button.d.ts b/packages/taro-components/types/Button.d.ts index 6d5d41b01bed..022bd9127252 100644 --- a/packages/taro-components/types/Button.d.ts +++ b/packages/taro-components/types/Button.d.ts @@ -3,27 +3,27 @@ import { StandardProps, CommonEventFunction } from './common' import { StyleProp, ViewStyle } from 'react-native' interface ButtonProps extends StandardProps { /** 按钮的大小 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @default default */ size?: keyof ButtonProps.Size /** 按钮的样式类型 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @default default */ type?: keyof ButtonProps.Type /** 按钮是否镂空,背景色透明 - * @supported weapp, alipay, swan, qq, jd, h5, rn + * @supported weapp, alipay, swan, qq, jd, h5, rn, harmony_hybrid * @default false */ plain?: boolean /** 是否禁用 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @default false */ disabled?: boolean /** 名称前是否带 loading 图标 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @default false */ loading?: boolean @@ -37,7 +37,7 @@ interface ButtonProps extends StandardProps { openType?: ButtonProps.OpenType /** 指定按下去的样式类。当 `hover-class="none"` 时,没有点击态效果 * @default button-hover - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @rn 支持 hoverStyle 属性,但框架未支持 hoverClass */ hoverClass?: string @@ -53,12 +53,12 @@ interface ButtonProps extends StandardProps { hoverStopPropagation?: boolean /** 按住后多久出现点击态,单位毫秒 * @default 20 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ hoverStartTime?: number /** 手指松开后点击态保留时间,单位毫秒 * @default 70 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ hoverStayTime?: number /** 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。 @@ -127,8 +127,10 @@ interface ButtonProps extends StandardProps { * @supported swan */ subscribeId?: string - /** 打开群资料卡时,传递的群号 - * @supported qq + /** 群聊 id + * @qq 打开群资料卡时,传递的群号 + * @tt 通过创建聊天群、查询群信息获取 + * @supported qq, tt */ groupId?: string /** 打开频道页面时,传递的频道号 @@ -169,6 +171,11 @@ interface ButtonProps extends StandardProps { * @supported tt */ dataAwemeId?: string + /** + * 是否开启半屏模式 + * @supported tt + */ + dataIsHalfPage?: boolean /** 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致 * * 生效时机: `open-type="getUserInfo"` @@ -271,6 +278,11 @@ interface ButtonProps extends StandardProps { * @supported tt */ onOpenAwemeUserProfile?: CommonEventFunction + /** + * 加群后触发 + * @supported tt + */ + onJoinGroup?: CommonEventFunction<{ errMsg: string; errNo: number }> } declare namespace ButtonProps { /** size 的合法值 */ @@ -515,7 +527,7 @@ declare namespace ButtonProps { } /** 按钮 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageButton extends Component { diff --git a/packages/taro-components/types/Canvas.d.ts b/packages/taro-components/types/Canvas.d.ts index db988c3b19b5..ea4fda8c5373 100644 --- a/packages/taro-components/types/Canvas.d.ts +++ b/packages/taro-components/types/Canvas.d.ts @@ -6,7 +6,7 @@ interface CanvasProps extends StandardProps { */ type?: string /** canvas 组件的唯一标识符,若指定了 type 则无需再指定该属性 - * @supported weapp, swan, tt, qq, jd, h5 + * @supported weapp, swan, tt, qq, jd, h5, harmony_hybrid */ canvasId?: string /** 当在 canvas 中移动时且有绑定手势事件时,禁止屏幕滚动以及下拉刷新 @@ -16,39 +16,39 @@ interface CanvasProps extends StandardProps { disableScroll?: boolean /** 组件唯一标识符。 * 注意:同一页面中的 id 不可重复。 - * @supported alipay, h5 + * @supported alipay, h5, harmony_hybrid */ id?: string /** - * @supported alipay, h5 + * @supported alipay, h5, harmony_hybrid */ width?: string /** - * @supported alipay, h5 + * @supported alipay, h5, harmony_hybrid */ height?: string /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 手指触摸动作开始 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ onTouchStart?: CanvasTouchEventFunction /** 手指触摸后移动 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ onTouchMove?: CanvasTouchEventFunction /** 手指触摸动作结束 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ onTouchEnd?: CanvasTouchEventFunction /** 手指触摸动作被打断,如来电提醒,弹窗 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ onTouchCancel?: CanvasTouchEventFunction /** 手指长按 500ms 之后触发,触发了长按事件后进行移动不会触发屏幕的滚动 - * @supported weapp, alipay, swan, qq, jd, h5 + * @supported weapp, alipay, swan, qq, jd, h5, harmony_hybrid */ onLongTap?: CommonEventFunction /** 当发生错误时触发 error 事件,detail = {errMsg: 'something wrong'} @@ -73,7 +73,7 @@ declare namespace CanvasProps { * * `` 组件的 RN 版本尚未实现。 * @classification canvas - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid * @example_react * ```tsx * class App extends Components { diff --git a/packages/taro-components/types/ChannelVideo.d.ts b/packages/taro-components/types/ChannelVideo.d.ts index 54fd872c5d2a..a5cb6bf153f2 100644 --- a/packages/taro-components/types/ChannelVideo.d.ts +++ b/packages/taro-components/types/ChannelVideo.d.ts @@ -1,7 +1,7 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction } from './common' interface ChannelVideoProps extends StandardProps { - /** 视频 feedId + /** 仅视频号视频与小程序同主体时生效。若内嵌非同主体视频,请使用 feed-token。 * @supported weapp */ feedId: string @@ -29,7 +29,7 @@ interface ChannelVideoProps extends StandardProps { * @default false */ autoplay?: boolean - /** 仅内嵌小程序非同主体视频号视频时使用,获取方式参考本指引。 + /** 仅内嵌小程序非同主体视频号视频时使用,获取方式参考[本指引](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/channels-activity.html#feed-token)。 * @supported weapp */ feedToken?: string diff --git a/packages/taro-components/types/Checkbox.d.ts b/packages/taro-components/types/Checkbox.d.ts index 4705306f008d..172e3cef0943 100644 --- a/packages/taro-components/types/Checkbox.d.ts +++ b/packages/taro-components/types/Checkbox.d.ts @@ -2,25 +2,30 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction, FormItemProps } from './common' interface CheckboxProps extends StandardProps { /** ``标识,选中时触发``的 change 事件,并携带 `` 的 value - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ value: string /** 是否禁用 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @default false */ disabled?: boolean /** 当前是否选中,可用来设置默认选中 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @default false */ checked?: boolean /** checkbox的颜色,同 css 的 color - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ color?: string + /** + * Checkbox 的名字 + * @supported h5, harmony, harmony_hybrid + */ + name?: string /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 无障碍访问,(属性)元素的额外描述 @@ -28,7 +33,7 @@ interface CheckboxProps extends StandardProps { */ ariaLabel?: string /** 选中项发生变化时触发 change 事件,小程序无此 API - * @supported alipay, h5, rn + * @supported alipay, h5, rn, harmony_hybrid */ onChange?: CommonEventFunction<{ value: string[] @@ -36,7 +41,7 @@ interface CheckboxProps extends StandardProps { } /** 多选项目 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageCheckbox extends Component { diff --git a/packages/taro-components/types/CheckboxGroup.d.ts b/packages/taro-components/types/CheckboxGroup.d.ts index ab3eb60390d7..f23317ea8cea 100644 --- a/packages/taro-components/types/CheckboxGroup.d.ts +++ b/packages/taro-components/types/CheckboxGroup.d.ts @@ -2,11 +2,11 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction, FormItemProps } from './common' interface CheckboxGroupProps extends StandardProps, FormItemProps { /** 表单组件中加上 name 来作为 key - * @supported alipay, tt, h5 + * @supported alipay, tt, h5, harmony_hybrid */ name?: string /** `` 中选中项发生改变是触发 change 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onChange?: CommonEventFunction<{ value: string[] @@ -14,7 +14,7 @@ interface CheckboxGroupProps extends StandardProps, FormItemProps { } /** 多项选择器,内部由多个checkbox组成 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example * ```tsx * export default class PageCheckbox extends Component { diff --git a/packages/taro-components/types/CoverImage.d.ts b/packages/taro-components/types/CoverImage.d.ts index b486075377de..f4e6b43d15b9 100644 --- a/packages/taro-components/types/CoverImage.d.ts +++ b/packages/taro-components/types/CoverImage.d.ts @@ -2,7 +2,7 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction } from './common' interface CoverImageProps extends StandardProps { /** 图标路径,支持临时路径、网络地址、云文件ID。暂不支持base64格式。 - * @supported weapp, alipay, swan, qq, jd, h5 + * @supported weapp, alipay, swan, qq, jd, h5, harmony_hybrid */ src: string /** 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; @@ -34,11 +34,11 @@ interface CoverImageProps extends StandardProps { */ ariaLabel?: string /** 图片加载成功时触发 - * @supported weapp, swan, qq, jd, h5 + * @supported weapp, swan, qq, jd, h5, harmony_hybrid */ onLoad?: CommonEventFunction /** 图片加载失败时触发 - * @supported weapp, swan, qq, jd, h5 + * @supported weapp, swan, qq, jd, h5, harmony_hybrid */ onError?: CommonEventFunction /** 点击事件回调。 @@ -48,7 +48,7 @@ interface CoverImageProps extends StandardProps { } /** 覆盖在原生组件之上的图片视图。可覆盖的原生组件同cover-view,支持嵌套在cover-view里。 * @classification viewContainer - * @supported weapp, alipay, swan, qq, jd, h5, harmony + * @supported weapp, alipay, swan, qq, jd, h5, harmony, harmony_hybrid * @example_react * ```tsx * // js diff --git a/packages/taro-components/types/CoverView.d.ts b/packages/taro-components/types/CoverView.d.ts index dd4a7a5a2050..701e449ce1c1 100644 --- a/packages/taro-components/types/CoverView.d.ts +++ b/packages/taro-components/types/CoverView.d.ts @@ -117,7 +117,7 @@ interface CoverViewProps extends ViewProps { } /** 覆盖在原生组件之上的文本视图。可覆盖的原生组件包括 map、video、canvas、camera、live-player、live-pusher 只支持嵌套 cover-view、cover-image,可在 cover-view 中使用 button。 * @classification viewContainer - * @supported weapp, alipay, swan, qq, jd, h5 + * @supported weapp, alipay, swan, qq, jd, h5, harmony_hybrid * @example_react * ```tsx * // js diff --git a/packages/taro-components/types/CustomWrapper.d.ts b/packages/taro-components/types/CustomWrapper.d.ts index b60ffd045d00..5b29a2855bab 100644 --- a/packages/taro-components/types/CustomWrapper.d.ts +++ b/packages/taro-components/types/CustomWrapper.d.ts @@ -7,7 +7,7 @@ interface CustomWrapperProps extends StandardProps { /** custom-wrapper 自定义组件包裹器 * 当数据更新层级较深时,可用此组件将需要更新的区域包裹起来,这样更新层级将大大减少 * @classification viewContainer - * @supported weapp, swan, alipay, tt, jd, qq, h5 + * @supported weapp, swan, alipay, tt, jd, qq, h5, harmony_hybrid * @example * ```tsx * import { Component } from 'react' diff --git a/packages/taro-components/types/Form.d.ts b/packages/taro-components/types/Form.d.ts index 65ba1e5bd8b9..7b612900944b 100644 --- a/packages/taro-components/types/Form.d.ts +++ b/packages/taro-components/types/Form.d.ts @@ -3,7 +3,7 @@ import { StandardProps, CommonEventFunction } from './common' interface FormProps extends StandardProps { /** 是否返回 `formId` 用于发送模板消息。 * @default false - * @supported weapp, alipay, swan, qq, jd, h5 + * @supported weapp, alipay, swan, qq, jd, h5, harmony_hybrid */ reportSubmit?: boolean /** 等待一段时间(毫秒数)以确认 `formId` 是否生效。 @@ -43,11 +43,11 @@ interface FormProps extends StandardProps { */ clueComponentId?: string /** 携带 form 中的数据触发 submit 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onSubmit?: CommonEventFunction /** 表单重置时会触发 reset 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onReset?: CommonEventFunction } @@ -69,7 +69,7 @@ declare namespace FormProps { * * 当点击 form 表单中 form-type 为 submit 的 button 组件时,会将表单组件中的 value 值进行提交,需要在表单组件中加上 name 来作为 key。 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * class App extends Component { diff --git a/packages/taro-components/types/GridView.d.ts b/packages/taro-components/types/GridView.d.ts index a1b3765ded87..25aae495f5c7 100644 --- a/packages/taro-components/types/GridView.d.ts +++ b/packages/taro-components/types/GridView.d.ts @@ -29,7 +29,7 @@ interface GridViewProps extends StandardProps { } /** * 网格布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。 - * @classification viewContainer + * @classification skyline * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/component/grid-view.html */ diff --git a/packages/taro-components/types/Icon.d.ts b/packages/taro-components/types/Icon.d.ts index 93a0c97bfbd8..54cbed3cc001 100644 --- a/packages/taro-components/types/Icon.d.ts +++ b/packages/taro-components/types/Icon.d.ts @@ -2,16 +2,16 @@ import { ComponentType } from 'react' import { StandardProps } from './common' interface IconProps extends StandardProps { /** icon 的类型 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ type: keyof IconProps.TIconType /** icon 的大小,单位px * @default 23 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ size?: string /** icon 的颜色,同 css 的 color - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ color?: string /** 无障碍访问,(属性)元素的额外描述 @@ -48,7 +48,7 @@ declare namespace IconProps { } /** 图标。组件属性的长度单位默认为 px * @classification base - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/Image.d.ts b/packages/taro-components/types/Image.d.ts index 28212392043e..971cfbf07071 100644 --- a/packages/taro-components/types/Image.d.ts +++ b/packages/taro-components/types/Image.d.ts @@ -2,12 +2,12 @@ import { ComponentType, ImgHTMLAttributes } from 'react' import { StandardProps, CommonEventFunction } from './common' interface ImageProps extends StandardProps { /** 图片资源地址 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ src: string /** 图片裁剪、缩放的模式 * @default "scaleToFill" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @rn 部分支持 scaleToFill, aspectFit, aspectFill, widthFix */ mode?: keyof ImageProps.Mode @@ -23,7 +23,7 @@ interface ImageProps extends StandardProps { svg?: boolean /** 图片懒加载。只针对 page 与 scroll-view 下的 image 有效 * @default false - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ lazyLoad?: boolean /** 开启长按图片显示识别小程序码菜单 @@ -33,11 +33,11 @@ interface ImageProps extends StandardProps { showMenuByLongpress?: boolean /** * 为 img 标签额外增加的属性 - * @supported h5 + * @supported h5, harmony_hybrid */ imgProps?: ImgHTMLAttributes /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 默认图片地址,若设置默认图片地址,会先显示默认图片,等 src 对应的图片加载成功后,再渲染对应的图片。 @@ -66,11 +66,11 @@ interface ImageProps extends StandardProps { */ fadeIn?: boolean /** 当错误发生时,发布到 AppService 的事件名,事件对象 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onError?: CommonEventFunction /** 当图片载入完毕时,发布到 AppService 的事件名,事件对象 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onLoad?: CommonEventFunction /** 点击图片时触发。 @@ -129,7 +129,7 @@ declare namespace ImageProps { * * **Note:** 为实现小程序的 `mode` 特性,在 H5 组件中使用一个 `div` 容器来对内部的 `img` 进行展示区域的裁剪,因此请勿使用元素选择器来重置 `img` 的样式! * @classification media - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/Input.d.ts b/packages/taro-components/types/Input.d.ts index f58bdebaaae4..375c9a59d50a 100644 --- a/packages/taro-components/types/Input.d.ts +++ b/packages/taro-components/types/Input.d.ts @@ -2,21 +2,26 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction, FormItemProps } from './common' interface InputProps extends StandardProps, FormItemProps { /** 输入框的初始内容 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ value?: string + /** 设置 React 非受控输入框的初始内容 + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid + * @unique + */ + defaultValue?: string /** input 的类型 * @default "text" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ type?: keyof InputProps.Type /** 是否是密码类型 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ password?: boolean /** 输入框为空时占位符 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ placeholder?: string /** 指定 placeholder 的样式 @@ -34,12 +39,12 @@ interface InputProps extends StandardProps, FormItemProps { placeholderTextColor?: string /** 是否禁用 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ disabled?: boolean /** 最大输入长度,设置为 -1 的时候不限制最大长度 * @default 140 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ maxlength?: number /** 指定光标与键盘的距离,单位 px 。取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离 @@ -50,12 +55,12 @@ interface InputProps extends StandardProps, FormItemProps { /** (即将废弃,请直接使用 focus )自动聚焦,拉起键盘 * @default false * @deprecated - * @supported weapp, qq, jd, h5 + * @supported weapp, qq, jd, h5, harmony_hybrid */ autoFocus?: boolean /** 获取焦点 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ focus?: boolean /** 设置键盘右下角按钮的文字,仅在type='text'时生效 @@ -144,7 +149,7 @@ interface InputProps extends StandardProps, FormItemProps { */ controlled?: boolean /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 组件名字,用于表单提交获取数据。 @@ -166,19 +171,19 @@ interface InputProps extends StandardProps, FormItemProps { */ clueType?: number /** 当键盘输入时,触发input事件,event.detail = {value, cursor, keyCode},处理函数可以直接 return 一个字符串,将替换输入框的内容。 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onInput?: CommonEventFunction /** 输入框聚焦时触发,event.detail = { value, height },height 为键盘高度 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onFocus?: CommonEventFunction /** 输入框失去焦点时触发 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onBlur?: CommonEventFunction /** 点击完成按钮时触发 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onConfirm?: CommonEventFunction /** 键盘高度发生变化的时候触发此事件 @@ -194,11 +199,11 @@ declare namespace InputProps { /** Input 类型 */ interface Type { /** 文本输入键盘 - * @supported weapp, alipay, h5, rn + * @supported weapp, alipay, h5, rn, harmony_hybrid */ text /** 数字输入键盘 - * @supported weapp, alipay, h5, rn + * @supported weapp, alipay, h5, rn, harmony_hybrid */ number /** 身份证输入键盘 @@ -206,7 +211,7 @@ declare namespace InputProps { */ idcard /** 带小数点的数字键盘 - * @supported weapp, alipay, h5, rn + * @supported weapp, alipay, h5, rn, harmony_hybrid */ digit /** 密码安全输入键盘[指引](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/safe-password.html) @@ -271,7 +276,7 @@ declare namespace InputProps { } /** 输入框。该组件是原生组件,使用时请注意相关限制 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * class App extends Component { diff --git a/packages/taro-components/types/Label.d.ts b/packages/taro-components/types/Label.d.ts index dabe2bf4dcf2..c212f3411c80 100644 --- a/packages/taro-components/types/Label.d.ts +++ b/packages/taro-components/types/Label.d.ts @@ -2,7 +2,7 @@ import { ComponentType } from 'react' import { StandardProps } from './common' interface LabelProps extends StandardProps { /** 绑定控件的 id - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ for?: string } @@ -10,7 +10,7 @@ interface LabelProps extends StandardProps { * * 使用for属性找到对应的id,或者将控件放在该标签下,当点击时,就会触发对应的控件。 for优先级高于内部控件,内部有多个控件的时候默认触发第一个控件。 目前可以绑定的控件有:button, checkbox, radio, switch。 * @classification forms - * @supported weapp, swan, alipay, tt, h5, rn, harmony + * @supported weapp, swan, alipay, tt, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * class App extends Components { diff --git a/packages/taro-components/types/ListView.d.ts b/packages/taro-components/types/ListView.d.ts index 82cf98a24f02..3d24eb846b6b 100644 --- a/packages/taro-components/types/ListView.d.ts +++ b/packages/taro-components/types/ListView.d.ts @@ -4,7 +4,7 @@ interface ListViewProps extends StandardProps {} /** * 列表布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。 - * @classification viewContainer + * @classification skyline * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/component/list-view.html */ diff --git a/packages/taro-components/types/LivePlayer.d.ts b/packages/taro-components/types/LivePlayer.d.ts index 6f235f9c105f..6e157840198e 100644 --- a/packages/taro-components/types/LivePlayer.d.ts +++ b/packages/taro-components/types/LivePlayer.d.ts @@ -61,10 +61,12 @@ interface LivePlayerProps extends StandardProps { */ pictureInPictureMode?: ('push' | 'pop')[] | 'push' | 'pop' | '' /** 当跳转到其它微信原生页面时,是否自动暂停本页面的实时音视频播放 + * @default true * @supported weapp, qq */ - autoPauseIfOpenNative?: string - /** 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; + autoPauseIfOpenNative?: boolean + /** 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html ,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本; + * @default 'no-referrer' * @supported weapp */ referrerPolicy?: 'origin' | 'no-referrer' @@ -125,11 +127,16 @@ interface LivePlayerProps extends StandardProps { /** 用户选择投屏设备时触发 detail = { state: "success"/"fail" } * @supported weapp */ - onCastingUserSelect?: CommonEventFunction + onCastingUserSelect?: CommonEventFunction<{ + state: 'success' | 'fail' + }> /** 投屏成功/失败时触发 detail = { type, state: "success"/"fail" } * @supported weapp */ - onCastingStateChange?: CommonEventFunction + onCastingStateChange?: CommonEventFunction<{ + type: any + state: 'success' | 'fail' + }> /** 投屏被中断时触发 * @supported weapp */ diff --git a/packages/taro-components/types/Map.d.ts b/packages/taro-components/types/Map.d.ts index 3a2d2f185513..472141277828 100644 --- a/packages/taro-components/types/Map.d.ts +++ b/packages/taro-components/types/Map.d.ts @@ -30,8 +30,9 @@ interface MapProps extends StandardProps { * @supported weapp, alipay, swan, tt, qq, jd */ markers?: MapProps.marker[] - /** 标记点 + /** **即将移除,请使用 markers** * @supported weapp + * @deprecated */ covers?: any[] /** 路线 @@ -217,14 +218,38 @@ interface MapProps extends StandardProps { * @supported weapp, swan, qq */ onPoiTap?: CommonEventFunction + /** 点击地图路线时触发,e.detail = {longitude, latitude} + * @supported weapp, swan, qq + */ + onPolylineTap?: CommonEventFunction + /** 地图能力生效时触发,e.detail = {ability, errCode, errMsg} + * @supported weapp + */ + onAbilitySuccess?: CommonEventFunction + /** 地图能力失败时触发,e.detail = {ability, errCode, errMsg} + * @supported weapp + */ + onAbilityFailed?: CommonEventFunction + /** 地图鉴权结果成功时触发,e.detail = {errCode, errMsg} + * @supported weapp + */ + onAuthSuccess?: CommonEventFunction<{ errCode: number; errMsg: string }> + /** MapContext.moveAlong 插值动画时触发。e.detail = {markerId, longitude, latitude, animationStatus: "interpolating" | "complete"} + * @supported weapp + */ + onInterpolatePoint?: CommonEventFunction + /** 组件错误时触发,例如创建或鉴权失败,e.detail = {longitude, latitude} + * @supported weapp + */ + onError: CommonEventFunction /** 点击标记点对应的气泡时触发e.detail = {markerId} * @supported weapp, swan, tt, jd */ - onCallOutTap?: CommonEventFunction + onCallOutTap?: CommonEventFunction /** 点击定位标时触发,e.detail = {longitude, latitude} * @supported weapp, tt */ - onAnchorPointTap?: CommonEventFunction + onAnchorPointTap?: CommonEventFunction /** 点击 panel 时触发。 * @supported alipay */ @@ -612,6 +637,22 @@ declare namespace MapProps { longitude: number latitude: number } + interface onPolylineTapEventDetail { + polylineId: number + longitude: number + latitude: number + } + interface onAbilityEventDetail { + ability: string + errCode: number + errMsg: string + } + interface onInterpolatePointEventDetail { + markerId: number + longitude: number + latitude: number + animationStatus: 'interpolating' | 'complete' + } } /** 地图。相关api Taro.createMapContext。 * @classification maps diff --git a/packages/taro-components/types/MovableArea.d.ts b/packages/taro-components/types/MovableArea.d.ts index 1e5ec29d1d56..e223f65a5a2f 100644 --- a/packages/taro-components/types/MovableArea.d.ts +++ b/packages/taro-components/types/MovableArea.d.ts @@ -3,13 +3,13 @@ import { StandardProps } from './common' interface MovableAreaProps extends StandardProps { /** 当里面的 movable-view 设置为支持双指缩放时,设置此值可将缩放手势生效区域修改为整个 movable-area * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ scaleArea?: boolean } /** movable-view 的可移动区域 * @classification viewContainer - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @example_react * ```tsx * class App extends Components { diff --git a/packages/taro-components/types/MovableView.d.ts b/packages/taro-components/types/MovableView.d.ts index a27a53253d24..9a971376110b 100644 --- a/packages/taro-components/types/MovableView.d.ts +++ b/packages/taro-components/types/MovableView.d.ts @@ -3,65 +3,65 @@ import { StandardProps, CommonEventFunction, TouchEventFunction } from './common interface MovableViewProps extends Omit { /** movable-view 的移动方向,属性值有`all`、`vertical`、`horizontal`、`none` * @default none - * @supported weapp, alipay, swan, tt, qq, h5, rn + * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony_hybrid */ direction?: 'all' | 'vertical' | 'horizontal' | 'none' /** movable-view 是否带有惯性 * @default false - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ inertia?: boolean /** 超过可移动区域后,movable-view 是否还可以移动 * @default false - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ outOfBounds?: boolean /** 定义 x 轴方向的偏移,如果 x 的值不在可移动范围内,会自动移动到可移动范围;改变 x 的值会触发动画 - * @supported weapp, alipay, swan, tt, qq, h5, rn + * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony_hybrid */ x?: number | string /** 定义 y 轴方向的偏移,如果 y 的值不在可移动范围内,会自动移动到可移动范围;改变 y 的值会触发动画 - * @supported weapp, alipay, swan, tt, qq, h5, rn + * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony_hybrid */ y?: number | string /** 阻尼系数,用于控制x或y改变时的动画和过界回弹的动画,值越大移动越快 * @default 20 - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ damping?: number /** 摩擦系数,用于控制惯性滑动的动画,值越大摩擦力越大,滑动越快停止;必须大于 0,否则会被设置成默认值 * @default 2 - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ friction?: number /** 是否禁用 * @default false - * @supported weapp, alipay, swan, tt, qq, h5, rn + * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony_hybrid */ disabled?: boolean /** 是否支持双指缩放,默认缩放手势生效区域是在 movable-view 内 * @default false - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ scale?: boolean /** 定义缩放倍数最小值 * @default 0.5 - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ scaleMin?: number /** 定义缩放倍数最大值 * @default 10 - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ scaleMax?: number /** 定义缩放倍数,取值范围为 0.5 - 10 * @default 1 - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ scaleValue?: number /** 是否使用动画 * @default true - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ animation?: boolean /** 拖动过程中触发的事件 @@ -81,7 +81,7 @@ interface MovableViewProps extends Omit { */ onDragEnd?: CommonEventFunction /** 缩放过程中触发的事件 - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ onScale?: CommonEventFunction /** 触摸动作开始,事件会向父节点传递。 @@ -93,7 +93,7 @@ interface MovableViewProps extends Omit { */ onTouchMove?: CommonEventFunction /** 手指触摸动作结束 - * @supported alipay, h5 + * @supported alipay, h5, harmony_hybrid * @h5 此事件的触发顺序会因为当前事件机制引起组件内外注册的事件执行顺序不正常,外部注册的事件可能会优先于内部执行,如需保证执行顺序一致,需要在回调函数中包裹 setTimeout 临时处理 */ onTouchEnd?: TouchEventFunction @@ -102,11 +102,11 @@ interface MovableViewProps extends Omit { */ onTouchCancel?: CommonEventFunction /** 初次手指触摸后移动为横向的移动,如果 catch 此事件,则意味着 touchmove 事件也被 catch - * @supported weapp, swan, tt, h5 + * @supported weapp, swan, tt, h5, harmony_hybrid */ onHTouchMove?: TouchEventFunction /** 初次手指触摸后移动为纵向的移动,如果 catch 此事件,则意味着 touchmove 事件也被 catch - * @supported weapp, swan, tt, h5 + * @supported weapp, swan, tt, h5, harmony_hybrid */ onVTouchMove?: TouchEventFunction /** 触摸移动事件,事件仅作用于组件,不向父节点传递。 @@ -155,7 +155,7 @@ declare namespace MovableViewProps { } /** 可移动的视图容器,在页面中可以拖拽滑动。movable-view 必须在 movable-area 组件中,并且必须是直接子节点,否则不能移动。 * @classification viewContainer - * @supported weapp, alipay, swan, tt, qq, h5, rn + * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony_hybrid * @example_react * ```tsx * class App extends Components { diff --git a/packages/taro-components/types/NativeSlot.d.ts b/packages/taro-components/types/NativeSlot.d.ts index 001e96e283a5..3a374d3739ce 100644 --- a/packages/taro-components/types/NativeSlot.d.ts +++ b/packages/taro-components/types/NativeSlot.d.ts @@ -1,6 +1,8 @@ -import { ComponentType } from 'react' +import { StandardProps } from './common' -interface NativeSlotProps { +import type { ComponentType, ReactNode } from 'react' + +interface NativeSlotProps extends StandardProps { /** 指定插入的 slot 位置 * @default none * @supported weapp, swan, alipay, tt, jd, qq @@ -10,7 +12,7 @@ interface NativeSlotProps { /** 编译的原生组件支持使用 slot 插槽 * @classification viewContainer - * @supported weapp, swan, alipay, tt, jd, qq, h5 + * @supported weapp, swan, alipay, tt, jd, qq, h5, harmony_hybrid * @version 3.5.7+ * @example * ```tsx diff --git a/packages/taro-components/types/NavigationBar.d.ts b/packages/taro-components/types/NavigationBar.d.ts index bbf090a6a762..a2a1c575a9b8 100644 --- a/packages/taro-components/types/NavigationBar.d.ts +++ b/packages/taro-components/types/NavigationBar.d.ts @@ -30,6 +30,12 @@ interface NavigationBarProps extends StandardProps { } /** 页面导航条配置节点,用于指定导航栏的一些属性。只能是 PageMeta 组件内的第一个节点,需要配合它一同使用。 * 通过这个节点可以获得类似于调用 Taro.setNavigationBarTitle Taro.setNavigationBarColor 等接口调用的效果。 + * + * :::info + * Taro v3.6.19 开始支持 + * 需要配合 PageMeta 组件使用 + * ::: + * * @classification navig * @supported weapp, harmony * @see https://developers.weixin.qq.com/miniprogram/dev/component/navigation-bar.html diff --git a/packages/taro-components/types/Navigator.d.ts b/packages/taro-components/types/Navigator.d.ts index 3a50bf3fb96f..d5d6d1050af1 100644 --- a/packages/taro-components/types/Navigator.d.ts +++ b/packages/taro-components/types/Navigator.d.ts @@ -7,16 +7,16 @@ interface NavigatorProps extends StandardProps { */ target?: keyof NavigatorProps.Target /** 当前小程序内的跳转链接 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ url?: string /** 跳转方式 * @default "navigate" - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ openType?: keyof NavigatorProps.OpenType /** 当 open-type 为 'navigateBack' 时有效,表示回退的层数 - * @supported weapp, swan, tt, qq, jd, h5 + * @supported weapp, swan, tt, qq, jd, h5, harmony_hybrid */ delta?: number /** 当 `target="miniProgram"` 时有效,要打开的小程序 appId @@ -37,7 +37,7 @@ interface NavigatorProps extends StandardProps { version?: keyof NavigatorProps.Version /** 指定按下去的样式类。当 `hover-class="none"` 时,没有点击态效果 * @default "navigator-hover" - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ hoverClass?: string /** 指定是否阻止本节点的祖先节点出现点击态 @@ -64,15 +64,15 @@ interface NavigatorProps extends StandardProps { */ ariaLabel?: string /** 当 `target="miniProgram"` 时有效,跳转小程序成功 - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ onSuccess?: CommonEventFunction /** 当 `target="miniProgram"` 时有效,跳转小程序失败 - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ onFail?: CommonEventFunction /** 当 `target="miniProgram"` 时有效,跳转小程序完成 - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ onComplete?: CommonEventFunction } @@ -111,7 +111,7 @@ declare namespace NavigatorProps { } /** 页面链接 * @classification navig - * @supported weapp, alipay, swan, tt, qq, jd, harmony, h5 + * @supported weapp, alipay, swan, tt, qq, jd, harmony, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/component/navigator.html */ declare const Navigator: ComponentType diff --git a/packages/taro-components/types/PageMeta.d.ts b/packages/taro-components/types/PageMeta.d.ts index 53bfe00208ac..72b44b73473d 100644 --- a/packages/taro-components/types/PageMeta.d.ts +++ b/packages/taro-components/types/PageMeta.d.ts @@ -64,6 +64,8 @@ interface PageMetaProps extends StandardProps { } declare namespace PageMetaProps { interface onResizeEventDetail { + /** 设备方向 */ + deviceOrientation?: 'portrait' | 'landscape' /** 窗口尺寸 */ size: resizeType } @@ -73,6 +75,10 @@ declare namespace PageMetaProps { windowWidth: number /** 窗口高度 */ windowHeight: number + /** 屏幕宽度 */ + screenWidth?: number + /** 屏幕高度 */ + screenHeight?: number } interface onScrollEventDetail { scrollTop: number @@ -80,7 +86,47 @@ declare namespace PageMetaProps { } /** 页面属性配置节点,用于指定页面的一些属性、监听页面事件。只能是页面内的第一个节点。可以配合 navigation-bar 组件一同使用。 * 通过这个节点可以获得类似于调用 Taro.setBackgroundTextStyle Taro.setBackgroundColor 等接口调用的效果。 + * + * :::info + * Taro v3.6.19 开始支持 + * 开发者需要在页面配置里添加:`enablePageMeta: true` + * ::: + * * @supported weapp, alipay + * @example_react + * ```tsx + * // page.config.ts + * export default definePageConfig({ enablePageMeta: true, ... }) + * + * // page.tsx + * function Index () { + * return ( + * + * + * + * + * + * ) + * } + * ``` + * @example_vue + * ```html + * + * + * + * + * + * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/component/page-meta.html */ declare const PageMeta: ComponentType diff --git a/packages/taro-components/types/Picker.d.ts b/packages/taro-components/types/Picker.d.ts index 2694965b076b..a4e9af9f3679 100644 --- a/packages/taro-components/types/Picker.d.ts +++ b/packages/taro-components/types/Picker.d.ts @@ -3,21 +3,26 @@ import { StyleProp, TextStyle, ViewStyle } from 'react-native' import { StandardProps, CommonEventFunction, FormItemProps } from './common' /** 选择器通用参数 */ interface PickerStandardProps extends StandardProps, FormItemProps { + /** + * 选择器的标题,微信小程序中仅安卓可用 + * @supported weapp + */ + headerText?: string /** * 选择器类型,默认是普通选择器 * @default "selector" - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ mode?: keyof PickerStandardProps.Mode /** * 是否禁用 * @default false - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ disabled?: boolean /** * 取消选择或点遮罩层收起 picker 时触发 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onCancel?: CommonEventFunction } @@ -46,21 +51,25 @@ interface PickerSelectorProps extends PickerStandardProps { mode?: 'selector' /** * mode为 selector 或 multiSelector 时,range 有效 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @default [] */ range: string[] | number[] | Record[] /** * 当 range 是一个 Object Array 时,通过 rangeKey 来指定 Object 中 key 的值作为选择器显示内容 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ rangeKey?: string /** * 表示选择了 range 中的第几个(下标从 0 开始) - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @default 0 */ value?: number + /** 设置 React 非受控状态下的初始取值 + * @supported weapp, h5, rn, harmony_hybrid + */ + defaultValue?: number /** * mode为 selector 或 multiSelector 时 itemStyle 有效 * @supported rn @@ -75,12 +84,12 @@ interface PickerSelectorProps extends PickerStandardProps { indicatorStyle?: StyleProp /** * value 改变时触发 change 事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ - onChange: CommonEventFunction + onChange?: CommonEventFunction /** * 用于替换组件内部文本 - * @supported h5 + * @supported h5, harmony_hybrid */ textProps?: PickerStandardProps.PickerText } @@ -96,18 +105,18 @@ interface PickerMultiSelectorProps extends PickerStandardProps { mode: 'multiSelector' /** * mode为 selector 或 multiSelector 时,range 有效 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @default [] */ range: Array | Array | Array[]> /** * 当 range 是一个 Object Array 时,通过 rangeKey 来指定 Object 中 key 的值作为选择器显示内容 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ rangeKey?: string /** * 表示选择了 range 中的第几个(下标从 0 开始) - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @default [] */ value: number[] | string[] | Record[] @@ -125,12 +134,12 @@ interface PickerMultiSelectorProps extends PickerStandardProps { indicatorStyle?: StyleProp /** * 当 value 改变时触发 change 事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onChange: CommonEventFunction /** * 列改变时触发 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onColumnChange?: CommonEventFunction } @@ -152,22 +161,26 @@ interface PickerTimeProps extends PickerStandardProps { mode: 'time' /** * value 的值表示选择了 range 中的第几个(下标从 0 开始) + * @supported weapp, h5, rn, harmony_hybrid + */ + value?: string + /** 设置 React 非受控状态下的初始取值 * @supported weapp, h5, rn */ - value: string + defaultValue?: string /** * 仅当 mode 为 "time" 或 "date" 时有效,表示有效时间范围的开始,字符串格式为"hh:mm" - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ start?: string /** * 仅当 mode 为 "time" 或 "date" 时有效,表示有效时间范围的结束,字符串格式为"hh:mm" - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ end?: string /** * value 改变时触发 change 事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onChange: CommonEventFunction } @@ -183,29 +196,33 @@ interface PickerDateProps extends PickerStandardProps { mode: 'date' /** * 表示选中的日期,格式为"YYYY-MM-DD" - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @default 0 */ value: string + /** 设置 React 非受控状态下的初始取值 + * @supported weapp, h5, rn + */ + defaultValue?: string /** * 仅当 mode 为 "time" 或 "date" 时有效,表示有效时间范围的开始,字符串格式为"YYYY-MM-DD" - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ start?: string /** * 仅当 mode 为 "time" 或 "date" 时有效,表示有效时间范围的结束,字符串格式为"YYYY-MM-DD" - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ end?: string /** * 有效值 year, month, day,表示选择器的粒度 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @default "day" */ fields?: keyof PickerDateProps.Fields /** * value 改变时触发 change 事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onChange: CommonEventFunction } @@ -229,13 +246,17 @@ interface PickerRegionProps extends PickerStandardProps { mode: 'region' /** * 表示选中的省市区,默认选中每一列的第一个值 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @default [] */ value?: string[] + /** 设置 React 非受控状态下的初始取值 + * @supported weapp, h5, rn + */ + defaultValue?: string[] /** * 可为每一列的顶部添加一个自定义的项 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ customItem?: string /** @@ -251,7 +272,7 @@ interface PickerRegionProps extends PickerStandardProps { regionData?: PickerRegionProps.RegionData[] /** * value 改变时触发 change 事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onChange: CommonEventFunction } @@ -283,7 +304,7 @@ declare namespace PickerRegionProps { /** * 从底部弹起的滚动选择器 * @classification forms - * @supported weapp, swan, alipay, tt, h5, rn, harmony + * @supported weapp, swan, alipay, tt, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PagePicker extends Component { diff --git a/packages/taro-components/types/PickerView.d.ts b/packages/taro-components/types/PickerView.d.ts index 212a930f4ca5..1f9724666895 100644 --- a/packages/taro-components/types/PickerView.d.ts +++ b/packages/taro-components/types/PickerView.d.ts @@ -5,6 +5,11 @@ interface PickerViewProps extends StandardProps { * @supported weapp, alipay, swan, tt, qq, jd, rn */ value?: number[] + /** 设置 React 非受控状态下的初始取值 + * @supported weapp, alipay, swan, tt, qq, jd, rn + * @unique + */ + defaultValue?: number[] /** 设置选择器中间选中框的样式 * @supported weapp, alipay, swan, tt, qq, jd, rn */ @@ -55,7 +60,7 @@ declare namespace PickerViewProps { /** 嵌入页面的滚动选择器 * 其中只可放置 picker-view-column 组件,其它节点不会显示 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class Picks extends Component { diff --git a/packages/taro-components/types/PickerViewColumn.d.ts b/packages/taro-components/types/PickerViewColumn.d.ts index 098b21a1dc1f..767785f68697 100644 --- a/packages/taro-components/types/PickerViewColumn.d.ts +++ b/packages/taro-components/types/PickerViewColumn.d.ts @@ -5,7 +5,7 @@ type PickerViewColumnProps = StandardProps /** 滚动选择器子项 * 仅可放置于 `` 中,其孩子节点的高度会自动设置成与 picker-view 的选中框的高度一致 * @classification forms - * @supported weapp, swan, alipay, tt, h5, rn, harmony + * @supported weapp, swan, alipay, tt, h5, rn, harmony, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/component/picker-view-column.html */ declare const PickerViewColumn: ComponentType diff --git a/packages/taro-components/types/Progress.d.ts b/packages/taro-components/types/Progress.d.ts index aa17cef42b30..6c4cb35a2ba5 100644 --- a/packages/taro-components/types/Progress.d.ts +++ b/packages/taro-components/types/Progress.d.ts @@ -2,59 +2,59 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction } from './common' interface ProgressProps extends StandardProps { /** 百分比 0~100 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ percent?: number /** 在进度条右侧显示百分比 * @default false - * @supported weapp, alipay, swan, qq, jd, h5, rn + * @supported weapp, alipay, swan, qq, jd, h5, rn, harmony_hybrid */ showInfo?: boolean /** 圆角大小 * @default 0 - * @supported weapp, swan, qq, jd, h5 + * @supported weapp, swan, qq, jd, h5, harmony_hybrid */ borderRadius?: number | string /** 右侧百分比字体大小 * @default 16 - * @supported weapp, swan, qq, jd, h5 + * @supported weapp, swan, qq, jd, h5, harmony_hybrid */ fontSize?: number | string /** 进度条线的宽度 * @default 6 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ strokeWidth?: number | string /** 进度条颜色 (请使用 activeColor) * @default "#09BB07" - * @supported weapp, swan, qq, jd, h5 + * @supported weapp, swan, qq, jd, h5, harmony_hybrid */ color?: string /** 已选择的进度条的颜色 * @default "#09BB07" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ activeColor?: string /** 未选择的进度条的颜色 * @default "#EBEBEB" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ backgroundColor?: string /** 进度条从左往右的动画 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ active?: boolean /** backwards: 动画从头播 * * forwards: 动画从上次结束点接着播 * @default backwards - * @supported weapp, swan, tt, qq, jd, h5, rn + * @supported weapp, swan, tt, qq, jd, h5, rn, harmony_hybrid */ activeMode?: 'backwards' | 'forwards' /** 进度增加 1% 所需毫秒数 * @default 30 - * @supported weapp, swan, tt, jd, h5 + * @supported weapp, swan, tt, jd, h5, harmony_hybrid */ duration?: number /** 无障碍访问,(属性)元素的额外描述 @@ -62,13 +62,13 @@ interface ProgressProps extends StandardProps { */ ariaLabel?: string /** 动画完成事件 - * @supported weapp, tt, qq, jd, h5 + * @supported weapp, tt, qq, jd, h5, harmony_hybrid */ onActiveEnd?: CommonEventFunction } /** 进度条。组件属性的长度单位默认为 px * @classification base - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/Radio.d.ts b/packages/taro-components/types/Radio.d.ts index f0313425b0b8..16658650f3b2 100644 --- a/packages/taro-components/types/Radio.d.ts +++ b/packages/taro-components/types/Radio.d.ts @@ -2,17 +2,17 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction, FormItemProps } from './common' interface RadioProps extends StandardProps { /** `` 标识。当该`` 选中时,``的 change 事件会携带``的 value - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ value?: string /** 当前是否选中 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ checked?: boolean /** 是否禁用 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ disabled?: boolean /** Radio 的颜色,同 css 的 color @@ -20,8 +20,13 @@ interface RadioProps extends StandardProps { * @supported weapp, alipay, swan, tt, qq, jd, rn */ color?: string + /** + * Radio 的名字 + * @supported h5, harmony, harmony_hybrid + */ + name?: string /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 无障碍访问,(属性)元素的额外描述 @@ -29,7 +34,7 @@ interface RadioProps extends StandardProps { */ ariaLabel?: string /** 中的选中项发生变化时触发 change 事件 - * @supported h5, rn + * @supported h5, rn, harmony_hybrid */ onChange?: CommonEventFunction<{ value?: string @@ -37,7 +42,7 @@ interface RadioProps extends StandardProps { } /** 单选项目 * @classification forms - * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageRadio extends Component { diff --git a/packages/taro-components/types/RadioGroup.d.ts b/packages/taro-components/types/RadioGroup.d.ts index a01d334b5383..34bba0cf0456 100644 --- a/packages/taro-components/types/RadioGroup.d.ts +++ b/packages/taro-components/types/RadioGroup.d.ts @@ -6,7 +6,7 @@ interface RadioGroupProps extends StandardProps, FormItemProps { */ name?: string /** RadioGroup 中选中项发生改变时触发 change 事件,detail = {value:[选中的radio的value的数组]} - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ onChange?: CommonEventFunction } @@ -17,7 +17,7 @@ declare namespace RadioGroupProps { } /** 单项选择器,内部由多个 Radio 组成。 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/component/radio-group.html */ declare const RadioGroup: ComponentType diff --git a/packages/taro-components/types/RichText.d.ts b/packages/taro-components/types/RichText.d.ts index 09f790ca94a6..f09f5a69e1c3 100644 --- a/packages/taro-components/types/RichText.d.ts +++ b/packages/taro-components/types/RichText.d.ts @@ -3,20 +3,20 @@ import { CommonEventFunction, StandardProps } from './common' interface RichTextProps extends StandardProps { /** 文本是否可选,该属性会使节点显示为 block * @default false - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid */ userSelect?: boolean /** 节点列表/ HTML String - * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony, harmony_hybrid */ nodes?: Nodes /** 显示连续空格 - * @supported weapp, alipay, tt, qq, h5, rn + * @supported weapp, alipay, tt, qq, h5, rn, harmony_hybrid */ space?: keyof RichTextProps.TSpace /** 富文本是否可以长按选中,可用于复制,粘贴,长按搜索等场景 * @default false(基础库 3.150.1 以前版本)true(基础库 3.150.1 及以后版本) - * @supported swan, h5 + * @supported swan, h5, harmony_hybrid */ selectable?: string /** 阻止长按图片时弹起默认菜单(将该属性设置为image-menu-prevent或image-menu-prevent="true"),只在初始化时有效,不能动态变更;若不想阻止弹起默认菜单,则不需要设置此属性 @@ -99,7 +99,7 @@ declare namespace RichTextProps { } /** 富文本 * @classification base - * @supported weapp, swan, alipay, tt, h5, rn, harmony + * @supported weapp, swan, alipay, tt, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * class App extends Components { diff --git a/packages/taro-components/types/Script.d.ts b/packages/taro-components/types/Script.d.ts new file mode 100644 index 000000000000..d3b1468ce7a7 --- /dev/null +++ b/packages/taro-components/types/Script.d.ts @@ -0,0 +1,37 @@ +import { ComponentType } from 'react' + +import { StandardProps } from './common' + +interface ScriptProps extends StandardProps { + /** xs 文件的相对路径 + * @supported weapp, alipay, swan, tt, qq, jd + */ + src: string + /** xs 模块名 + * @supported weapp, alipay, swan, tt, qq, jd + */ + module: string +} + +/** script 类似微信小程序的 wxs 标签,支持引用各种小程序的 xs 文件 + * 只能在 CompileMode 中使用 + * @classification viewContainer + * @supported weapp, swan, alipay, tt, jd, qq + * @example_react + * ```tsx + * import { Component } from 'react' + * import { View, Script } from '@tarojs/components' + * + * export function Index () { + * return ( + * + * + * Hello, {logic.name}! + * + * ) + * } + * ``` + */ +declare const Script: ComponentType + +export { Script, ScriptProps } diff --git a/packages/taro-components/types/ScrollView.d.ts b/packages/taro-components/types/ScrollView.d.ts index ab1142f35804..44449332632f 100644 --- a/packages/taro-components/types/ScrollView.d.ts +++ b/packages/taro-components/types/ScrollView.d.ts @@ -3,40 +3,40 @@ import { BaseEventOrigFunction, CommonEventFunction, StandardProps } from './com interface ScrollViewProps extends StandardProps { /** 允许横向滚动 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @rn 二选一 */ scrollX?: boolean /** 允许纵向滚动 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @rn 二选一 */ scrollY?: boolean /** 距顶部/左边多远时(单位px),触发 scrolltoupper 事件 * @default 50 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ upperThreshold?: number /** 距底部/右边多远时(单位px),触发 scrolltolower 事件 * @default 50 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ lowerThreshold?: number /** 设置竖向滚动条位置 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ scrollTop?: number /** 设置横向滚动条位置 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ scrollLeft?: number /** 值应为某子元素id(id不能以数字开头)。设置哪个方向可滚动,则在哪个方向滚动到该元素 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ scrollIntoView?: string /** 在设置滚动条位置时使用动画过渡 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @default false */ scrollWithAnimation?: boolean @@ -85,6 +85,11 @@ interface ScrollViewProps extends StandardProps { * @default false */ enhanced?: boolean + /** 使 scroll-view 下的 position sticky 特性生效,否则滚动一屏后 sticky 元素会被隐藏 + * @supported weapp + * @default false + */ + usingSticky?: boolean /** iOS 下 scroll-view 边界弹性控制 (同时开启 enhanced 属性后生效) * @supported weapp, swan * @default true @@ -130,7 +135,7 @@ interface ScrollViewProps extends StandardProps { * @supported weapp * @default false */ - enablePassive?: string + enablePassive?: boolean /** 渲染模式 * list - 列表模式。只会渲染在屏节点,会根据直接子节点是否在屏来按需渲染,若只有一个直接子节点则性能会退化 * custom - 自定义模式。只会渲染在屏节点,子节点可以是 sticky-section list-view grid-view 等组件 @@ -143,10 +148,25 @@ interface ScrollViewProps extends StandardProps { * @default false */ reverse?: boolean + /** 是否对溢出进行裁剪,默认开启 + * @supported weapp + * @default true + */ + clip?: boolean /** 指定视口外渲染区域的距离,默认情况下视口外节点不渲染。指定 cache-extent 可优化滚动体验和加载速度,但会提高内存占用且影响首屏速度,可按需启用。 * @supported weapp */ cacheExtent?: number + /** 指定 scroll-view 触发滚动的最小拖动距离。仅在 scroll-view 和其他组件存在手势冲突时使用,可通过调整该属性使得滚动更加灵敏。 + * @supported weapp + * @default 18 + */ + minDragDistance?: number + /** 长度为 4 的数组,按 top、right、bottom、left 顺序指定内边距 + * @supported weapp + * @default [0,0,0,0] + */ + padding?: [number, number, number, number] /** 只 scroll-into-view 到 cacheExtent 以内的目标节点,性能更佳 * @supported weapp * @default false @@ -157,20 +177,55 @@ interface ScrollViewProps extends StandardProps { * center - 目标节点显示在视口中间 * end - 目标节点显示在视口结束处 * nearest - 目标节点在就近的视口边缘显示,若节点已在视口内则不触发滚动 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @default 'start' */ scrollIntoViewAlignment?: 'start' | 'center' | 'end' | 'nearest' + /** 开启下拉二级能力 + * @supported weapp + * @default false + */ + refresherTwoLevelEnabled?: boolean + /** 设置打开/关闭二级 + * @supported weapp + * @default false + */ + refresherTwoLevelTriggered?: boolean + /** 下拉二级阈值 + * @supported weapp + * @default 150 + */ + refresherTwoLevelThreshold?: number + /** 滑动返回时关闭二级的阈值 + * @supported weapp + * @default 80 + */ + refresherTwoLevelCloseThreshold?: number + /** 处于二级状态时是否可滑动 + * @supported weapp + * @default false + */ + refresherTwoLevelScrollEnabled?: boolean + /** 惯性滚动是否触发下拉刷新 + * @supported weapp + * @default false + */ + refresherBallisticRefreshEnabled?: boolean + /** 即将打开二级时否定住 + * @supported weapp + * @default false + */ + refresherTwoLevelPinned?: boolean /** 滚动到顶部/左边,会触发 scrolltoupper 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onScrollToUpper?: CommonEventFunction /** 滚动到底部/右边,会触发 scrolltolower 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onScrollToLower?: CommonEventFunction /** 滚动时触发 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onScroll?: BaseEventOrigFunction /** 滚动开始事件 @@ -201,6 +256,10 @@ interface ScrollViewProps extends StandardProps { * @supported weapp */ onRefresherWillRefresh?: CommonEventFunction + /** 下拉刷新状态回调 + * @supported weapp + */ + onRefresherStatusChange?: CommonEventFunction /** 滑动开始事件 (同时开启 enhanced 属性后生效) * @supported weapp */ @@ -252,6 +311,30 @@ declare namespace ScrollViewProps { /** 滚动速度 */ velocity: number } + interface RefresherStatusChange { + status: RefreshStatus + dy: number + } + const enum RefreshStatus { + // 空闲 + Idle, + // 超过下拉刷新阈值,同 bind:refresherwillRefresh 触发时机 + CanRefresh, + // 下拉刷新,同 bind:refresherrefresh 触发时机 + Refreshing, + // 下拉刷新完成,同 bind:refresherrestore 触发时机 + Completed, + // 下拉刷新失败 + Failed, + // 超过下拉二级阈值 + CanTwoLevel, + // 开始打开二级 + TwoLevelOpening, + // 打开二级 + TwoLeveling, + // 开始关闭二级 + TwoLevelClosing, + } } /** 可滚动视图区域。使用竖向滚动时,需要给scroll-view一个固定高度,通过 WXSS 设置 height。组件属性的长度单位默认为 px * @@ -259,7 +342,7 @@ declare namespace ScrollViewProps { * H5 中 ScrollView 组件是通过一个高度(或宽度)固定的容器内部滚动来实现的,因此务必正确的设置容器的高度。例如: 如果 ScrollView 的高度将 body 撑开,就会同时存在两个滚动条(body 下的滚动条,以及 ScrollView 的滚动条)。 * 微信小程序 中 ScrollView 组件如果设置 scrollX 横向滚动时,并且子元素为多个时(单个子元素时设置固定宽度则可以正常横向滚动),需要通过 WXSS 设置 `white-space: nowrap` 来保证元素不换行,并对 ScrollView 内部元素设置 `display: inline-block` 来使其能够横向滚动。 * @classification viewContainer - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/ShareElement.d.ts b/packages/taro-components/types/ShareElement.d.ts index dde04fc6987b..79530a366c9e 100644 --- a/packages/taro-components/types/ShareElement.d.ts +++ b/packages/taro-components/types/ShareElement.d.ts @@ -8,6 +8,7 @@ interface ShareElementProps extends StandardProps { key?: string /** 映射标记 * @supported weapp + * @unique */ mapkey?: string /** 映射标记 @@ -68,7 +69,7 @@ interface ShareElementProps extends StandardProps { * * 共享元素是一种动画形式,类似于 [`flutter Hero`](https://flutterchina.club/animations/hero-animations/) 动画,表现为元素像是在页面间穿越一样。该组件需与 [`PageContainer`](/docs/components/viewContainer/page-container) 组件结合使用。 * 使用时需在当前页放置 `ShareElement` 组件,同时在 `PageContainer` 容器中放置对应的 `ShareElement` 组件,对应关系通过属性值 key 映射。当设置 `PageContainer` `显示时,transform` 属性为 `true` 的共享元素会产生动画。当前页面容器退出时,会产生返回动画。 - * @classification viewContainer + * @classification skyline * @supported weapp, alipay * @example_react * ```tsx diff --git a/packages/taro-components/types/Slider.d.ts b/packages/taro-components/types/Slider.d.ts index 5bba70198c4f..6d95bd3ec4a5 100644 --- a/packages/taro-components/types/Slider.d.ts +++ b/packages/taro-components/types/Slider.d.ts @@ -3,29 +3,34 @@ import { StandardProps, CommonEventFunction, FormItemProps } from './common' interface SliderProps extends StandardProps, FormItemProps { /** 最小值 * @default 0 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ min?: number /** 最大值 * @default 100 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ max?: number /** 步长,取值必须大于 0,并且可被(max - min)整除 * @default 1 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ step?: number /** 是否禁用 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ disabled?: boolean /** 当前取值 * @default 0 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ value?: number + /** 设置 React 非受控状态下的初始取值 + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid + * @unique + */ + defaultValue?: string /** 背景条的颜色(请使用 backgroundColor) * @default "#e9e9e9" * @supported weapp, tt, qq, jd @@ -38,27 +43,27 @@ interface SliderProps extends StandardProps, FormItemProps { selectedColor?: string /** 已选择的颜色 * @default "#1aad19" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ activeColor?: string /** 背景条的颜色 * @default "#e9e9e9" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ backgroundColor?: string /** 滑块的大小,取值范围为 12 - 28 * @default 28 - * @supported weapp, swan, tt, qq, jd, h5 + * @supported weapp, swan, tt, qq, jd, h5, harmony_hybrid */ blockSize?: number /** 滑块的颜色 * @default "#ffffff" - * @supported weapp, swan, tt, qq, jd, h5, rn + * @supported weapp, swan, tt, qq, jd, h5, rn, harmony_hybrid */ blockColor?: string /** 是否显示当前 value * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ showValue?: boolean /** 组件名字,用于表单提交获取数据。 @@ -84,11 +89,11 @@ interface SliderProps extends StandardProps, FormItemProps { */ ariaLabel?: string /** 完成一次拖动后触发的事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onChange?: CommonEventFunction /** 拖动过程中触发的事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onChanging?: CommonEventFunction } @@ -99,7 +104,7 @@ declare namespace SliderProps { } /** 滑动选择器 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/Slot.d.ts b/packages/taro-components/types/Slot.d.ts index 4f333e021834..f3a47059392a 100644 --- a/packages/taro-components/types/Slot.d.ts +++ b/packages/taro-components/types/Slot.d.ts @@ -1,6 +1,8 @@ -import { ComponentType } from 'react' +import { StandardProps } from './common' -interface SlotProps { +import type { ComponentType, ReactNode } from 'react' + +interface SlotProps extends StandardProps { /** 指定插入的 slot 位置 * @default none * @supported weapp, swan, alipay, tt, jd, qq @@ -15,7 +17,7 @@ interface SlotProps { /** slot 插槽 * @classification viewContainer - * @supported weapp, swan, alipay, tt, jd, qq, harmony, h5 + * @supported weapp, swan, alipay, tt, jd, qq, harmony, h5, harmony_hybrid * @example * ```tsx * import { Slot, View, Text } from '@tarojs/components' diff --git a/packages/taro-components/types/Snapshot.d.ts b/packages/taro-components/types/Snapshot.d.ts new file mode 100644 index 000000000000..a0c720c1ab32 --- /dev/null +++ b/packages/taro-components/types/Snapshot.d.ts @@ -0,0 +1,16 @@ +import { ComponentType } from 'react' + +import { StandardProps } from './common' + +interface SnapshotProps extends StandardProps { + id: string +} + +/** 截图组件。 + * 支持将其子节点的渲染结果导出成图片,该组件需配合 snapshot 接口使用。 目前仅在 Skyline 渲染引擎 下支持。 + * @classification skyline + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/component/snapshot.html + */ +declare const Snapshot: ComponentType +export { Snapshot, SnapshotProps } diff --git a/packages/taro-components/types/StickyHeader.d.ts b/packages/taro-components/types/StickyHeader.d.ts index 09b106fe1ba3..5250527ed882 100644 --- a/packages/taro-components/types/StickyHeader.d.ts +++ b/packages/taro-components/types/StickyHeader.d.ts @@ -4,7 +4,7 @@ interface StickyHeaderProps extends StandardProps {} /** * 吸顶布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点或 sticky-section 组件直接子节点。仅 Skyline 支持。 - * @classification viewContainer + * @classification skyline * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/component/sticky-header.html */ diff --git a/packages/taro-components/types/StickySection.d.ts b/packages/taro-components/types/StickySection.d.ts index 5a25a668adad..cbb2e51c50eb 100644 --- a/packages/taro-components/types/StickySection.d.ts +++ b/packages/taro-components/types/StickySection.d.ts @@ -9,7 +9,7 @@ interface StickySectionProps extends StandardProps { } /** * 吸顶布局容器,仅支持作为 scroll-view 自定义模式下的直接子节点。仅 Skyline 支持。 - * @classification viewContainer + * @classification skyline * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/component/sticky-section.html */ diff --git a/packages/taro-components/types/Swiper.d.ts b/packages/taro-components/types/Swiper.d.ts index b49a0c4cbbf2..e3e546204cb6 100644 --- a/packages/taro-components/types/Swiper.d.ts +++ b/packages/taro-components/types/Swiper.d.ts @@ -3,61 +3,63 @@ import { StandardProps, CommonEventFunction } from './common' interface SwiperProps extends StandardProps { /** 是否显示面板指示点 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ indicatorDots?: boolean /** 指示点颜色 * @default "rgba(0, 0, 0, .3)" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ indicatorColor?: string /** 当前选中的指示点颜色 * @default "#000000" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ indicatorActiveColor?: string /** 是否自动切换 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ autoplay?: boolean /** 当前所在滑块的 index * @default 0 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ current?: number /** 当前所在滑块的 item-id ,不能与 current 被同时指定 + * @supported swan, tt, qq, jd, h5, harmony_hybrid + * @weapp deprecated * @default "" */ currentItemId?: string /** 自动切换时间间隔 * @default 5000 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ interval?: number /** 滑动动画时长 * @default 500 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ duration?: number /** 是否采用衔接滑动 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ circular?: boolean /** 滑动方向是否为纵向 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ vertical?: boolean /** 前边距,可用于露出前一项的一小部分,接受 px 和 rpx 值 * @default "0px" - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ previousMargin?: string /** 后边距,可用于露出后一项的一小部分,接受 px 和 rpx 值 * @default "0px" - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ nextMargin?: string /** @@ -68,7 +70,7 @@ interface SwiperProps extends StandardProps { snapToEdge?: boolean /** 同时显示的滑块数量 * @default 1 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ displayMultipleItems?: number /** 是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息 @@ -88,12 +90,12 @@ interface SwiperProps extends StandardProps { disableTouch?: boolean /** 是否启用缩放 * @default false - * @supported h5 + * @supported h5, harmony_hybrid */ zoom?: boolean /** 是否开启全屏 * @default false - * @supported h5 + * @supported h5, harmony_hybrid */ full?: boolean /** swiper-item 可见时的 class。 @@ -150,7 +152,7 @@ interface SwiperProps extends StandardProps { */ cacheExtent?: number /** current 改变时会触发 change 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onChange?: CommonEventFunction /** swiper-item 的位置发生改变时会触发 transition 事件 @@ -158,7 +160,7 @@ interface SwiperProps extends StandardProps { */ onTransition?: CommonEventFunction /** 动画结束时会触发 animationfinish 事件 - * @supported weapp, swan, tt, qq, jd, h5, rn + * @supported weapp, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onAnimationFinish?: SwiperProps['onChange'] /** 动画结束时会触发 animationEnd 事件 @@ -213,7 +215,7 @@ declare namespace SwiperProps { /** 滑块视图容器。其中只可放置 swiper-item 组件,否则会导致未定义的行为。 * > 不要为 `SwiperItem` 设置 **style** 属性,可以通过 class 设置样式。[7147](https://github.com/NervJS/taro/issues/7147) * @classification viewContainer - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * class App extends Component { diff --git a/packages/taro-components/types/SwiperItem.d.ts b/packages/taro-components/types/SwiperItem.d.ts index 91880a013a47..c8908eea1440 100644 --- a/packages/taro-components/types/SwiperItem.d.ts +++ b/packages/taro-components/types/SwiperItem.d.ts @@ -2,7 +2,7 @@ import { ComponentType } from 'react' import { StandardProps } from './common' interface SwiperItemProps extends StandardProps { /** 该 swiper-item 的标识符 - * @supported weapp, swan, tt, jd, h5, rn + * @supported weapp, swan, tt, jd, h5, rn, harmony_hybrid */ itemId?: string /** 是否跳过未显示的滑块布局,设为 true 可优化复杂情况下的滑动性能,但会丢失隐藏状态滑块的布局信息 @@ -10,11 +10,16 @@ interface SwiperItemProps extends StandardProps { * @supported weapp */ skipHiddenItemLayout?: boolean + /** Swiper 循环状态下,前后垫片节点拷贝模式,用于修复 Vue 在 CustomElements 下的节点拷贝问题 + * @default false + * @supported h5 + */ + deep?: boolean } /** 仅可放置在 swiper 组件中,宽高自动设置为100% * > 不要为 `SwiperItem` 设置 **style** 属性,可以通过 class 设置样式。[7147](https://github.com/NervJS/taro/issues/7147) * @classification viewContainer - * @supported weapp, alipay, swan, tt, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * class App extends Component { diff --git a/packages/taro-components/types/Switch.d.ts b/packages/taro-components/types/Switch.d.ts index 40e551055941..e3bd221ed737 100644 --- a/packages/taro-components/types/Switch.d.ts +++ b/packages/taro-components/types/Switch.d.ts @@ -3,26 +3,31 @@ import { StandardProps, CommonEventFunction, FormItemProps } from './common' interface SwitchProps extends StandardProps, FormItemProps { /** 是否选中 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ checked?: boolean + /** 设置在 React 非受控状态下,当前是否选中 + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid + * @unique + */ + defaultChecked?: boolean /** 是否禁用 * @default false - * @supported weapp, alipay, swan, tt, qq, h5, rn + * @supported weapp, alipay, swan, tt, qq, h5, rn, harmony_hybrid */ disabled?: boolean /** 样式,有效值:switch, checkbox * @default "switch" - * @supported weapp, swan, tt, qq, jd, h5, rn + * @supported weapp, swan, tt, qq, jd, h5, rn, harmony_hybrid */ type?: 'switch' | 'checkbox' /** switch 的颜色,同 css 的 color * @default "#04BE02" - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ color?: string /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 组件名字,用于表单提交获取数据。 @@ -39,7 +44,7 @@ interface SwitchProps extends StandardProps, FormItemProps { */ ariaLabel?: string /** checked 改变时触发 change 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onChange?: CommonEventFunction } @@ -84,7 +89,7 @@ declare namespace SwitchProps { * * * ``` - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/component/switch.html */ declare const Switch: ComponentType diff --git a/packages/taro-components/types/Text.d.ts b/packages/taro-components/types/Text.d.ts index 429299c90f4e..d7b2af34fcbc 100644 --- a/packages/taro-components/types/Text.d.ts +++ b/packages/taro-components/types/Text.d.ts @@ -3,16 +3,16 @@ import { StandardProps } from './common' interface TextProps extends StandardProps { /** 文本是否可选 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ selectable?: boolean /** 文本是否可选,该属性会使文本节点显示为 inline-block * @default false - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid */ userSelect?: boolean /** 显示连续空格 - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ space?: keyof TextProps.TSpace /** 是否解码 @@ -43,7 +43,7 @@ declare namespace TextProps { } /** 文本 * @classification base - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/Textarea.d.ts b/packages/taro-components/types/Textarea.d.ts index 55e99b7ab482..f9fb83a96bd9 100644 --- a/packages/taro-components/types/Textarea.d.ts +++ b/packages/taro-components/types/Textarea.d.ts @@ -2,11 +2,16 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction, FormItemProps } from './common' interface TextareaProps extends StandardProps, FormItemProps { /** 输入框的内容 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ value?: string + /** 设置 React 非受控输入框的初始内容 + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid + * @unique + */ + defaultValue?: string /** 输入框为空时占位符 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ placeholder?: string /** 指定 placeholder 的样式 @@ -20,27 +25,27 @@ interface TextareaProps extends StandardProps, FormItemProps { placeholderClass?: string /** 是否禁用 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ disabled?: boolean /** 最大输入长度,设置为 -1 的时候不限制最大长度 * @default 140 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ maxlength?: number /** 自动聚焦,拉起键盘 * @default false - * @supported weapp, swan, qq, jd, h5 + * @supported weapp, swan, qq, jd, h5, harmony_hybrid */ autoFocus?: boolean /** 获取焦点 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ focus?: boolean /** 是否自动增高,设置 autoHeight 时,style.height不生效 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ autoHeight?: boolean /** 如果 Textarea 是在一个 `position:fixed` 的区域,需要显示指定属性 fixed 为 true @@ -89,7 +94,7 @@ interface TextareaProps extends StandardProps, FormItemProps { */ disableDefaultPadding?: boolean /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 设置键盘右下角按钮的文字 @@ -124,11 +129,11 @@ interface TextareaProps extends StandardProps, FormItemProps { */ adjustKeyboardTo?: boolean /** 输入框聚焦时触发 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onFocus?: CommonEventFunction /** 输入框失去焦点时触发 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onBlur?: CommonEventFunction /** 输入框行数变化时调用 @@ -138,11 +143,11 @@ interface TextareaProps extends StandardProps, FormItemProps { /** 当键盘输入时,触发 input 事件 * * **onInput 处理函数的返回值并不会反映到 textarea 上** - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onInput?: CommonEventFunction /** 点击完成时, 触发 confirm 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onConfirm?: CommonEventFunction /** 键盘高度发生变化的时候触发此事件 @@ -189,7 +194,7 @@ declare namespace TextareaProps { } /** 多行输入框。该组件是原生组件,使用时请注意相关限制 * @classification forms - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/Video.d.ts b/packages/taro-components/types/Video.d.ts index 5235424e7307..7cb6276134d9 100644 --- a/packages/taro-components/types/Video.d.ts +++ b/packages/taro-components/types/Video.d.ts @@ -2,49 +2,49 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction } from './common' interface VideoProps extends StandardProps { /** 要播放视频的资源地址 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ src: string /** 指定视频时长 - * @supported weapp, alipay, qq, h5, rn + * @supported weapp, alipay, qq, h5, rn, harmony_hybrid */ duration?: number /** 是否显示默认播放控件(播放/暂停按钮、播放进度、时间) * @default true - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ controls?: boolean /** 弹幕列表 - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ danmuList?: any[] /** 是否显示弹幕按钮,只在初始化时有效,不能动态变更 * @default false - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ danmuBtn?: boolean /** 是否展示弹幕,只在初始化时有效,不能动态变更 * @default false - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ enableDanmu?: boolean /** 是否自动播放 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ autoplay?: boolean /** 是否循环播放 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ loop?: boolean /** 是否静音播放 * @default false - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ muted?: boolean /** 指定视频初始播放位置 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ initialTime?: number /** 在非全屏模式下,是否开启亮度与音量调节手势 @@ -58,41 +58,41 @@ interface VideoProps extends StandardProps { direction?: number /** 若不设置,宽度大于240时才会显示 * @default true - * @supported weapp, swan, qq, h5 + * @supported weapp, swan, qq, h5, harmony_hybrid */ showProgress?: boolean /** 是否显示全屏按钮 * @default true - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ showFullscreenBtn?: boolean /** 是否显示视频底部控制栏的播放按钮 * @default true - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ showPlayBtn?: boolean /** 是否显示视频中间的播放按钮 * @default true - * @supported weapp, alipay, swan, qq, h5, rn + * @supported weapp, alipay, swan, qq, h5, rn, harmony_hybrid */ showCenterPlayBtn?: boolean /** 是否开启控制进度的手势 * @default true - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ enableProgressGesture?: boolean /** 当视频大小与 video 容器大小不一致时,视频的表现形式 * @default "contain" - * @supported weapp, alipay, swan, tt, qq, jd, h5 + * @supported weapp, alipay, swan, tt, qq, jd, h5, harmony_hybrid */ objectFit?: keyof VideoProps.ObjectFit /** 视频封面的图片网络资源地址,如果 controls 属性值为 false 则设置 poster 无效 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ poster?: string /** 是否显示静音按钮 * @default false - * @supported weapp, alipay, swan, tt, qq, h5 + * @supported weapp, alipay, swan, tt, qq, h5, harmony_hybrid */ showMuteBtn?: boolean /** 视频的标题,全屏时在顶部展示 @@ -109,7 +109,7 @@ interface VideoProps extends StandardProps { playBtnPosition?: keyof VideoProps.PlayBtnPosition /** 是否开启播放手势,即双击切换播放/暂停 * @default false - * @supported weapp, swan, tt, qq, h5 + * @supported weapp, swan, tt, qq, h5, harmony_hybrid */ enablePlayGesture?: boolean /** 当跳转到其它小程序页面时,是否自动暂停本页面的视频 @@ -124,12 +124,12 @@ interface VideoProps extends StandardProps { autoPauseIfOpenNative?: boolean /** 在非全屏模式下,是否开启亮度与音量调节手势(同 `page-gesture`) * @default false - * @supported weapp, swan, tt, h5 + * @supported weapp, swan, tt, h5, harmony_hybrid */ vslideGesture?: boolean /** 在全屏模式下,是否开启亮度与音量调节手势 * @default true - * @supported weapp, swan, tt, h5 + * @supported weapp, swan, tt, h5, harmony_hybrid */ vslideGestureInFullscreen?: boolean /** 视频前贴广告单元ID,更多详情可参考开放能力[视频前贴广告](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/ad/video-patch-ad.html) @@ -187,13 +187,14 @@ interface VideoProps extends StandardProps { */ backgroundPoster?: string /** 用于透传 `WebComponents` 上的属性到内部 H5 标签上 - * @supported h5 + * @supported h5, harmony_hybrid */ nativeProps?: Record /** 是否展示底部进度条 * @supported weapp + * @default true */ - showBottomProgress?: string + showBottomProgress?: boolean /** 是否在小窗模式下显示播放进度 * @supported weapp */ @@ -205,7 +206,7 @@ interface VideoProps extends StandardProps { /** 是否是 DRM 视频源 * @supported weapp */ - isDrm?: string + isDrm?: boolean /** DRM 设备身份认证 url,仅 is-drm 为 true 时生效 (Android) * @supported weapp */ @@ -235,7 +236,7 @@ interface VideoProps extends StandardProps { * * @supported alipay, jd */ - mobilenetHintType?: string + mobilenetHintType?: number /** 浮窗设置。暂时不支持全局浮窗。 * 可选值: * @@ -297,24 +298,24 @@ interface VideoProps extends StandardProps { */ definition?: string /** 当开始/继续播放时触发 play 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onPlay?: CommonEventFunction /** 当暂停播放时触发 pause 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onPause?: CommonEventFunction /** 当播放到末尾时触发 ended 事件 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onEnded?: CommonEventFunction /** 播放进度变化时触发, 触发频率 250ms 一次 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onTimeUpdate?: CommonEventFunction /** 当视频进入和退出全屏时触发 * - * @supported h5, rn + * @supported h5, rn, harmony_hybrid */ onFullscreenChange?: CommonEventFunction /** 视频出现缓冲时触发 @@ -323,11 +324,11 @@ interface VideoProps extends StandardProps { */ onWaiting?: CommonEventFunction /** 视频播放出错时触发 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ onError?: CommonEventFunction /** 加载进度变化时触发,只支持一段加载 - * @supported weapp, tt, qq, h5 + * @supported weapp, tt, qq, h5, harmony_hybrid */ onProgress?: CommonEventFunction /** 视频元数据加载完成时触发 @@ -487,6 +488,14 @@ declare namespace VideoProps { currentTime: number /** 持续时间 */ duration: number + /** 用户实际观看时长 + * @supported alipay + */ + userPlayDuration: number + /** 视频总时长 + * @supported alipay + */ + videoDuration: number } interface onFullscreenChangeEventDetail { /** 方向 */ @@ -548,7 +557,7 @@ declare namespace VideoProps { } /** 视频。相关api:Taro.createVideoContext * @classification media - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/View.d.ts b/packages/taro-components/types/View.d.ts index f934f0fd9ab3..45b297e39046 100644 --- a/packages/taro-components/types/View.d.ts +++ b/packages/taro-components/types/View.d.ts @@ -4,7 +4,7 @@ import { CommonEventFunction, StandardProps } from './common' interface ViewProps extends StandardProps { /** 指定按下去的样式类。当 `hover-class="none"` 时,没有点击态效果 * @default none - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid * @rn 由于 RN 不支持 hoverClass,故 RN 端的 View 组件实现了 `hoverStyle`属性,写法和 style 类似,只不过 `hoverStyle` 的样式是指定按下去的样式。 */ hoverClass?: string @@ -20,12 +20,12 @@ interface ViewProps extends StandardProps { hoverStopPropagation?: boolean /** 按住后多久出现点击态,单位毫秒 * @default 50 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ hoverStartTime?: number /** 手指松开后点击态保留时间,单位毫秒 * @default 400 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ hoverStayTime?: number /** 是否阻止区域内滚动页面。 @@ -117,7 +117,7 @@ interface ViewProps extends StandardProps { } /** 视图容器 * @classification viewContainer - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * export default class PageView extends Component { diff --git a/packages/taro-components/types/WebView.d.ts b/packages/taro-components/types/WebView.d.ts index 044ee9a89881..9c53e8ab12fd 100644 --- a/packages/taro-components/types/WebView.d.ts +++ b/packages/taro-components/types/WebView.d.ts @@ -2,7 +2,7 @@ import { ComponentType } from 'react' import { StandardProps, CommonEventFunction } from './common' interface WebViewProps extends StandardProps { /** webview 指向网页的链接。可打开关联的公众号的文章,其它网页需登录小程序管理后台配置业务域名。 - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony_hybrid */ src: string /** webview 的进度条颜色 @@ -19,11 +19,11 @@ interface WebViewProps extends StandardProps { */ onMessage?: CommonEventFunction /** 网页加载成功时候触发此事件。e.detail = { src } - * @supported weapp, alipay, tt, qq, h5, rn + * @supported weapp, alipay, tt, qq, h5, rn, harmony_hybrid */ onLoad?: CommonEventFunction /** 网页加载失败的时候触发此事件。e.detail = { src } - * @supported weapp, alipay, tt, qq, h5, rn + * @supported weapp, alipay, tt, qq, h5, rn, harmony_hybrid */ onError?: CommonEventFunction } @@ -43,7 +43,7 @@ declare namespace WebViewProps { } /** web-view 组件是一个可以用来承载网页的容器,会自动铺满整个小程序页面。个人类型与海外类型的小程序暂不支持使用。 * @classification open - * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony + * @supported weapp, alipay, swan, tt, qq, jd, h5, rn, harmony, harmony_hybrid * @example_react * ```tsx * class App extends Component { diff --git a/packages/taro-components/types/common.d.ts b/packages/taro-components/types/common.d.ts index ce57362e0297..ccd56263e377 100644 --- a/packages/taro-components/types/common.d.ts +++ b/packages/taro-components/types/common.d.ts @@ -26,6 +26,11 @@ export interface StandardProps = dangerouslySetInnerHTML?: { __html: string } + /** + * 是否开启编译模式 + * @supported weapp, harmony + */ + compileMode?: boolean } export interface FormItemProps { diff --git a/packages/taro-components/types/index.d.ts b/packages/taro-components/types/index.d.ts index e639277f5804..3ca5d9e6fb93 100644 --- a/packages/taro-components/types/index.d.ts +++ b/packages/taro-components/types/index.d.ts @@ -6,17 +6,12 @@ export * from './props' export { Block } from './Block' export { CoverImage } from './CoverImage' export { CoverView } from './CoverView' -export { GridView } from './GridView' -export { ListView } from './ListView' export { MatchMedia } from './MatchMedia' export { MovableArea } from './MovableArea' export { MovableView } from './MovableView' export { PageContainer } from './PageContainer' export { RootPortal } from './RootPortal' export { ScrollView } from './ScrollView' -export { ShareElement } from './ShareElement' -export { StickyHeader } from './StickyHeader' -export { StickySection } from './StickySection' export { Swiper } from './Swiper' export { SwiperItem } from './SwiperItem' export { View } from './View' @@ -45,6 +40,14 @@ export { Slider } from './Slider' export { Switch } from './Switch' export { Textarea } from './Textarea' +/** Skyline */ +export { GridView } from './GridView' +export { ListView } from './ListView' +export { ShareElement } from './ShareElement' +export { Snapshot } from './SnapShot' +export { StickyHeader } from './StickyHeader' +export { StickySection } from './StickySection' + /** 导航 */ export { FunctionalPageNavigator } from './FunctionalPageNavigator' export { Navigator } from './Navigator' @@ -83,3 +86,4 @@ export { PageMeta } from './PageMeta' export { CustomWrapper } from './CustomWrapper' export { Slot } from './Slot' export { NativeSlot } from './NativeSlot' +export { Script } from './Script' diff --git a/packages/taro-components/types/index.vue3.d.ts b/packages/taro-components/types/index.vue3.d.ts index 7fc883727701..d7cef457187e 100644 --- a/packages/taro-components/types/index.vue3.d.ts +++ b/packages/taro-components/types/index.vue3.d.ts @@ -65,6 +65,7 @@ import { ScrollViewProps } from './ScrollView' import { ShareElementProps } from './ShareElement' import { SliderProps } from './Slider' import { SlotProps } from './Slot' +import { SnapshotProps } from './SnapShot' import { StickyHeaderProps } from './StickyHeader' import { StickySectionProps } from './StickySection' import { SwiperProps } from './Swiper' @@ -108,17 +109,12 @@ export * from './props' export declare const Block: VueComponentType export declare const CoverImage: VueComponentType export declare const CoverView: VueComponentType -export declare const GridView: VueComponentType -export declare const ListView: VueComponentType export declare const MatchMedia: VueComponentType export declare const MovableArea: VueComponentType export declare const MovableView: VueComponentType export declare const PageContainer: VueComponentType export declare const RootPortal: VueComponentType export declare const ScrollView: VueComponentType -export declare const ShareElement: VueComponentType -export declare const StickyHeader: VueComponentType -export declare const StickySection: VueComponentType export declare const Swiper: VueComponentType export declare const SwiperItem: VueComponentType export declare const View: VueComponentType @@ -144,6 +140,13 @@ export declare const RadioGroup: VueComponentType export declare const Slider: VueComponentType export declare const Switch: VueComponentType export declare const Textarea: VueComponentType +/** Skyline */ +export declare const GridView: VueComponentType +export declare const ListView: VueComponentType +export declare const Snapshot: VueComponentType +export declare const ShareElement: VueComponentType +export declare const StickyHeader: VueComponentType +export declare const StickySection: VueComponentType /** 导航 */ export declare const FunctionalPageNavigator: VueComponentType export declare const Navigator: VueComponentType @@ -206,8 +209,6 @@ declare global { 'taro-root-portal-core': ElementAttrs> 'scroll-view': ElementAttrs> 'taro-scroll-view-core': ElementAttrs> - 'share-element': ElementAttrs> - 'taro-share-element-core': ElementAttrs> swiper: ElementAttrs> 'taro-swiper-core': ElementAttrs> 'swiper-item': ElementAttrs> @@ -256,6 +257,19 @@ declare global { 'taro-switch-core': ElementAttrs> textarea: ElementAttrs> 'taro-textarea-core': ElementAttrs> + /** Skyline */ + 'grid-view': ElementAttrs> + 'taro-grid-view-core': ElementAttrs> + 'list-view': ElementAttrs> + 'taro-list-view-core': ElementAttrs> + 'share-element': ElementAttrs> + 'taro-share-element-core': ElementAttrs> + 'snapshot': ElementAttrs> + 'taro-snapshot-core': ElementAttrs> + 'sticky-header': ElementAttrs> + 'taro-sticky-header-core': ElementAttrs> + 'sticky-section': ElementAttrs> + 'taro-sticky-section-core': ElementAttrs> /** 导航 */ 'functional-page-navigator': ElementAttrs> 'taro-functional-page-navigator-core': ElementAttrs> diff --git a/packages/taro/types/api/ai/visionkit.d.ts b/packages/taro/types/api/ai/visionkit.d.ts index 8c95d2e7f48c..24d4fd42bdcc 100644 --- a/packages/taro/types/api/ai/visionkit.d.ts +++ b/packages/taro/types/api/ai/visionkit.d.ts @@ -3,7 +3,7 @@ import Taro from '../../index' declare module '../../index' { namespace isVKSupport { /** vision kit 版本 */ - interface Version { + interface IVersion { /** 旧版本 */ v1 /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */ @@ -12,24 +12,24 @@ declare module '../../index' { } namespace createVKSession { /** vision kit 版本 */ - interface Version { + interface IVersion { /** 旧版本 */ v1 /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */ v2 } /** 跟踪配置 */ - interface Track { + interface ITrack { /** 平面跟踪配置 */ - plane: Plane + plane: IPlane } /** 平面跟踪配置 */ - interface Plane { + interface IPlane { /** 平面跟踪配置模式 */ - mode: keyof PlaneMode + mode: keyof IPlaneMode } /** 平面跟踪配置模式合法值 */ - interface PlaneMode { + interface IPlaneMode { /** 检测横向平面 */ 1 /** 检测纵向平面,只有 v2 版本支持 */ @@ -41,33 +41,59 @@ declare module '../../index' { /** anchor 对象,只有 v2 版本支持 * @supported weapp - * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKAnchor.html + * @ignore */ - interface VKAnchor { + type VKAnchor = VKBodyAnchor | VKDepthAnchor | VKFaceAnchor | VKHandAnchor | VKMarkerAnchor | VKOCRAnchor | VKPlaneAnchor + + /** 人体 anchor + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKBodyAnchor.html + */ + interface VKBodyAnchor { /** 唯一标识 */ id: number /** 类型 */ - type: keyof VKAnchor.Type - /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */ - transform: Float32Array - /** 尺寸,只有平面 anchor 支持 */ - size: VKAnchor.Size - /** 方向,只有平面 anchor 支持 */ - alignment: number + type: keyof VKBodyAnchor.IType + /** 识别序号 */ + detectId: number + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKBodyAnchor.ISize + /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + origin: VKBodyAnchor.IOrigin + /** 关键点的置信度 */ + confidence: number[] + /** 关键点 */ + points: VKBodyAnchor.IPoint[] + /** 总体置信值 */ + score: number } - namespace VKAnchor { - /** anchor 对象类型合法值 */ - interface Type { - /** 平面 */ - 0 + namespace VKBodyAnchor { + /** 类型 */ + interface IType { + /** 人体 */ + 5 } - /** anchor 对象类型合法值 */ - interface Size { + /** 相对视窗的尺寸*/ + interface ISize { /** 宽度 */ width: number /** 高度 */ height: number } + /** 相对视窗的位置信息 */ + interface IOrigin { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number + } + /** 关键点 */ + interface IPoint { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number + } } /** 相机对象 @@ -91,6 +117,296 @@ declare module '../../index' { ): Float32Array } + /** depth anchor + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKDepthAnchor.html + */ + interface VKDepthAnchor { + /** 唯一标识 */ + id: number + /** 类型 */ + type: keyof VKDepthAnchor.IType + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKDepthAnchor.ISize + /** 包含深度信息的数组 */ + depthArray: number[] + } + namespace VKDepthAnchor { + /** 类型 */ + interface IType { + /** DEPTH */ + 8 + } + /** 相对视窗的尺寸 */ + interface ISize { + /** 宽度 */ + width: number + /** 高度 */ + height: number + } + } + + /** 人脸 anchor + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFaceAnchor.html + */ + interface VKFaceAnchor { + /** 唯一标识 */ + id: number + /** 类型 */ + type: keyof VKFaceAnchor.IType + /** 识别序号 */ + detectId: number + /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + origin: VKFaceAnchor.IOrigin + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKFaceAnchor.ISize + /** 人脸 106 个关键点的坐标 */ + points: VKFaceAnchor.IPoint[] + /** 人脸角度信息 */ + angle: number[] + /** 关键点的置信度 */ + confidence: number + } + namespace VKFaceAnchor { + /** 类型 */ + interface IType { + /** 人脸 */ + 3 + } + /** 相对视窗的尺寸*/ + interface ISize { + /** 宽度 */ + width: number + /** 高度 */ + height: number + } + /** 相对视窗的位置信息 */ + interface IOrigin { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number + } + /** 关键点 */ + interface IPoint { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number + } + } + + /** 手势 anchor + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKHandAnchor.html + */ + interface VKHandAnchor { + /** 唯一标识 */ + id: number + /** 类型 */ + type: keyof VKHandAnchor.IType + /** 识别序号 */ + detectId: number + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + size: VKHandAnchor.ISize + /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + origin: VKHandAnchor.IOrigin + /** 关键点的置信度 */ + confidence: number[] + /** 关键点 */ + points: VKHandAnchor.IPoint[] + /** 总体置信值 */ + score: number + /** 手势分类, 返回整数 -1 到 18, -1 表示无效手势 */ + gesture: keyof VKHandAnchor.IGesture | -1 + } + namespace VKHandAnchor { + /** 类型 */ + interface IType { + /** 手势 */ + 7 + } + /** 相对视窗的尺寸*/ + interface ISize { + /** 宽度 */ + width: number + /** 高度 */ + height: number + } + /** 相对视窗的位置信息 */ + interface IOrigin { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number + } + /** 关键点 */ + interface IPoint { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number + } + /** 手势分类 */ + interface IGesture { + /**单手比心 */ + 0 + /** 布(数字5)*/ + 1 + /** 剪刀(数字2) */ + 2 + /** 握拳 */ + 3 + /** 数字1 */ + 4 + /** 热爱 */ + 5 + /** 点赞 */ + 6 + /** 数字3 */ + 7 + /** 摇滚 */ + 8 + /** 数字6 */ + 9 + /** 数字8 */ + 10 + /** 双手抱拳(恭喜发财) */ + 11 + /** 数字4 */ + 12 + /** 比ok */ + 13 + /** 不喜欢(踩) */ + 14 + /** 双手比心 */ + 15 + /** 祈祷(双手合十) */ + 16 + /** 双手抱拳 */ + 17 + /** 无手势动作 */ + 18 + } + } + + /** marker anchor + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKMarkerAnchor.html + */ + interface VKMarkerAnchor { + /** 唯一标识 */ + id: number + /** 类型 */ + type: keyof VKMarkerAnchor.IType + /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */ + transform: Float32Array + /** marker id */ + markerId: number + /** 图片路径 */ + path: string + } + namespace VKMarkerAnchor { + /** 类型 */ + interface IType { + /** marker */ + 1 + } + } + + /** OCR anchor + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOCRAnchor.html + */ + interface VKOCRAnchor { + /** 唯一标识 */ + id: number + /** 类型 */ + type: keyof VKOCRAnchor.IType + /** 识别的文字结果 */ + text: string + } + namespace VKOCRAnchor { + /** 类型 */ + interface IType { + /** OCR */ + 6 + } + } + + /** OSD anchor + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKOSDAnchor.html + */ + interface VKOSDAnchor { + /** 唯一标识 */ + id: number + /** 类型 */ + type: keyof VKOSDAnchor.IType + /** marker id */ + markerId: number + /** 相对视窗的尺寸,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘*/ + size: VKOSDAnchor.ISize + /** 图片路径 */ + path: string + /** 相对视窗的位置信息,取值范围为 [0, 1],0 为左/上边缘,1 为右/下边缘 */ + origin: VKOSDAnchor.IOrigin + } + namespace VKOSDAnchor { + /** 类型 */ + interface IType { + /** OSD */ + 2 + } + /** 相对视窗的尺寸*/ + interface ISize { + /** 宽度 */ + width: number + /** 高度 */ + height: number + } + /** 相对视窗的位置信息 */ + interface IOrigin { + /** 横坐标 */ + x: number + /** 纵坐标 */ + y: number + } + } + + /** 平面 anchor,只有 v2 版本支持 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKPlaneAnchor.html + */ + interface VKPlaneAnchor { + /** 唯一标识 */ + id: number + /** 类型 */ + type: keyof VKPlaneAnchor.IType + /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */ + transform: Float32Array + /** 尺寸 */ + size: VKPlaneAnchor.ISize + /** 方向 */ + alignment: number + } + + namespace VKPlaneAnchor { + /** 类型 */ + interface IType { + /** 平面 */ + 0 + } + /** 相对视窗的尺寸*/ + interface ISize { + /** 宽度 */ + width: number + /** 高度 */ + height: number + } + } + /** vision kit 会话对象 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.html @@ -104,7 +420,14 @@ declare module '../../index' { * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraTexture.html */ - getCameraTexture(ctx: WebGLRenderingContext): VKFrame.getCameraTextureResult + getCameraTexture(ctx: WebGLRenderingContext): VKFrame.IGetCameraTextureResult + /** 获取当前帧 rgba buffer。iOS 端微信在 v8.0.20 开始支持,安卓端微信在 v8.0.30 开始支持。 + * 按 aspect-fill 规则裁剪,此接口要求在创建 VKSession 对象时必须传入 gl 参数。 + * 此接口仅建议拿来做帧分析使用,上屏请使用 getCameraTexture 来代替。 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getCameraBuffer.html + */ + getCameraBuffer(widht: number, height: number): ArrayBuffer /** 获取纹理调整矩阵。默认获取到的纹理是未经裁剪调整的纹理,此矩阵可用于在着色器中根据帧对象尺寸对纹理进行裁剪 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKFrame.getDisplayTransform.html @@ -114,7 +437,7 @@ declare module '../../index' { namespace VKFrame { /** 帧纹理对象 */ - interface getCameraTextureResult { + interface IGetCameraTextureResult { /** Y 分量纹理 */ yTexture: WebGLTexture /** UV 分量纹理 */ @@ -128,11 +451,27 @@ declare module '../../index' { */ interface VKSession { /** 会话状态 */ - state: keyof VKSession.State + state: keyof VKSession.IState /** 会话配置 */ - config: VKSession.Config + config: VKSession.IConfig /** 相机尺寸 */ - cameraSize: VKSession.Size + cameraSize: VKSession.ISize + /** 添加一个 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.addMarker.html + */ + addMarker( + /** 图片路径,目前只支持本地用户图片 */ + path: string + ): number + /** 添加一个 OSD marker(one-shot detection marker),要求调 Taro.createVKSession 时传入的 track.OSD 为 true + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.addOSDMarker.html + */ + addOSDMarker( + /** 图片路径,目前只支持本地用户图片 */ + path: string + ): number /** 取消由 requestAnimationFrame 添加到计划中的动画帧请求 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.cancelAnimationFrame.html @@ -143,6 +482,36 @@ declare module '../../index' { * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.destroy.html */ destroy(): void + /** 静态图像人体关键点检测。当 Taro.createVKSession 参数传入 {track: {body: {mode: 2} } } 时可用。 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectBody.html + */ + detectBody(option: VKSession.IDetectBodyOption): void + /** 深度识别。当 Taro.createVKSession 参数传入 {track: {depth: {mode: 2} } } 时可用。 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectDepth.html + */ + detectDepth(option: VKSession.IDetectDepthOption): void + /** 静态图像人脸关键点检测。当 Taro.createVKSession 参数传入 {track: {face: {mode: 2} } } 时可用。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectFace.html + */ + detectFace(option: VKSession.IDetectFaceOption): void + /** 静态图像手势关键点检测。当 Taro.createVKSession 参数传入 {track: {hand: {mode: 2} } } 时可用。 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.detectHand.html + */ + detectHand(option: VKSession.IDetectHandOption): void + /** 获取所有 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getAllMarker.html + */ + getAllMarker(): VKSession.IMarker[] + /** 获取所有 OSD marker,要求调 Taro.createVKSession 时传入的 track.OSD 为 true + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getAllOSDMarker.html + */ + getAllOSDMarker(): VKSession.IOSDMarker[] /** 获取帧对象,每调用一次都会触发一次帧分析过程 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.getVKFrame.html @@ -166,7 +535,7 @@ declare module '../../index' { y: number, /** 是否需要重新识别其他平面,v2 版本不再需要此参数 */ reset?: boolean - ): VKSession.hitTestResult[] + ): VKSession.IHitTestResult[] /** 取消监听会话事件。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.off.html @@ -175,7 +544,7 @@ declare module '../../index' { /** 事件名称 */ eventName: string, /** 事件监听函数 */ - fn: Function + fn: TaroGeneral.EventCallback ): void /** 监听会话事件。 * @supported weapp @@ -183,68 +552,125 @@ declare module '../../index' { */ on( /** 事件名称 */ - eventName: string, + eventName: 'resize' | 'addAnchors' | 'updateAnchors' | 'removeAnchors' | string, /** 事件监听函数 */ - fn: Function + fn: TaroGeneral.EventCallback ): void + /** 删除一个 marker,要求调 Taro.createVKSession 时传入的 track.marker 为 true + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.removeMarker.html + */ + removeMarker( + /** marker id */ + markerId: number + ): number + /** 删除一个 OSD marker,要求调 Taro.createVKSession 时传入的 track.OSD 为 true + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.removeOSDMarker.html + */ + removeOSDMarker( + /** marker id */ + markerId: number + ): number /** 在下次进行重绘时执行。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.requestAnimationFrame.html */ requestAnimationFrame( - /** 执行函数 */ - callback: Function + /** 执行函数 */ + callback: TaroGeneral.TFunc ): number + /** 静态图像 OCR 检测。当 Taro.createVKSession 参数传入 {track: {OCR: {mode: 2} } } 时可用。 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.runOCR.html + */ + runOCR(option: VKSession.IRunOCROption): void /** 开启会话。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.start.html */ start( - /** 开启会话回调 */ - callback: (status: keyof VKSession.StartStatus) => void + /** 开启会话回调 */ + callback: (status: keyof VKSession.IStartStatus) => void ): void /** 停止会话。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.stop.html */ - stop(): void + stop(): void + /** 开启 3D 模式 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.update3DMode.html + */ + update3DMode( + /** 是否开启 */ + open3d: boolean + ): void + /** 更新 OSD 识别精确度,要求调 Taro.createVKSession 时传入的 track.OSD 为 true + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/VKSession.updateOSDThreshold.html + */ + updateOSDThreshold( + /** 阈值 */ + threshold: number + ): void } namespace VKSession { /** state 的合法值 */ - interface State { + interface IState { /** 不可用 */ 0 /** 运行中 */ 1 /** 暂停中 */ 2 + /** 初始化中 */ + 3 } /** 会话配置 */ - interface Config { + interface IConfig { /** 不可用 */ - version: keyof version + version: keyof IVersion /** 运行中 */ - track: track + track: ITrack + /** marker 跟踪配置,基础库(3.0.0)开始允许同时支持v2的水平面检测能力 */ + marker: boolean + /** OSD 跟踪配置 */ + OSD: boolean + /** 深度识别配置 */ + depth: IDepth + /** 人脸检测配置。安卓微信8.0.25开始支持,iOS微信8.0.24开始支持。 */ + face: IFace + /** OCR 检测配置。 */ + OCR: IOCR + /** 人体检测配置。 */ + body: IBody + /** 手势检测配置。 */ + hand: IHand + /** 提供基础AR功能,输出相机旋转的3个自由度的位姿,利用手机陀螺仪传感器,实现快速稳定的AR定位能力,适用于简单AR场景。 */ + threeDof: boolean + /** 绑定的 WebGLRenderingContext 对象 */ + gl: WebGLRenderingContext } /** vision kit 版本 */ - interface version { + interface IVersion { /** 旧版本 */ v1 /** v2 版本,目前只有 iOS 基础库 2.22.0 以上支持 */ v2 } /** 跟踪配置 */ - interface track { + interface ITrack { /** 平面跟踪配置 */ - plane: plane + plane: IPlane } /** 平面跟踪配置 */ - interface plane { + interface IPlane { /** 平面跟踪配置模式 */ - mode: keyof PlaneMode + mode: keyof IPlaneMode } /** 平面跟踪配置模式合法值 */ - interface PlaneMode { + interface IPlaneMode { /** 检测横向平面 */ 1 /** 检测纵向平面,只有 v2 版本支持 */ @@ -252,22 +678,167 @@ declare module '../../index' { /** 检测横向和纵向平面,只有 v2 版本支持 */ 3 } + /** 深度识别配置 */ + interface IDepth { + mode: keyof IDepthMode + } + /** 深度识别模式 */ + interface IDepthMode { + /** 通过摄像头实时检测 */ + 1 + /** 静态图片检测 */ + 2 + } + /** 人脸检测模式 */ + interface IFace { + mode: keyof IFaceMode + } + /** 人脸检测模式 */ + interface IFaceMode { + /** 通过摄像头实时检测 */ + 1 + /** 静态图片检测 */ + 2 + } + /** OCR 检测配置 */ + interface IOCR { + mode: keyof IOCRMode + } + /** OCR 检测模式 */ + interface IOCRMode { + /** 通过摄像头实时检测 */ + 1 + /** 静态图片检测 */ + 2 + } + /** 人体检测模式 */ + interface IBody { + mode: keyof IBodyMode + } + /** 人体检测模式 */ + interface IBodyMode { + /** 通过摄像头实时检测 */ + 1 + /** 静态图片检测 */ + 2 + } + /** 手势检测配置 */ + interface IHand { + mode: keyof IHandMode + } + /** 手势检测模式 */ + interface IHandMode { + /** 通过摄像头实时检测 */ + 1 + /** 静态图片检测 */ + 2 + } /** 相机尺寸 */ - interface Size { + interface ISize { /** 宽度 */ width: number /** 高度 */ height: number } - + interface IDetectBodyOption { + /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像宽度 */ + width: number + /** 图像高度 */ + height: number + /** 评分阈值。正常情况传入 0.8 即可。默认值 0.8 */ + scoreThreshold?: number + /** 图像源类型。正常情况传入 1 即可。当输入的图片是来自一个连续视频的每一帧图像时,sourceType 传入 0 会得到更优的效果。默认值1 */ + sourceType?: keyof ISourceType + } + /** 图像源类型。 */ + interface ISourceType { + /** 表示输入的图片是随机的图片 */ + 1 + /** 表示输入的图片是来自一个连续视频的每一帧图像 */ + 0 + } + interface IDetectDepthOption { + /** 人需要识别深度的图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像宽度 */ + width: number + /** 图像高度 */ + height: number + } + interface IDetectFaceOption { + /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像宽度 */ + width: number + /** 图像高度 */ + height: number + /** 评分阈值。正常情况传入 0.8 即可。默认值 0.8 */ + scoreThreshold?: number + /** 图像源类型。正常情况传入 1 即可。当输入的图片是来自一个连续视频的每一帧图像时,sourceType 传入 0 会得到更优的效果。默认值1 */ + sourceType?: keyof ISourceType + /** 算法模型类型。正常情况传入 1 即可。0、1、2 分别表示小、中、大模型,模型越大识别准确率越高,但资源占用也越高。建议根据用户设备性能进行选择。 */ + modelModel?: keyof IModelModel + } + /** 算法模型类型 */ + interface IModelModel { + /** 小模型 */ + 0 + /** 中模型 */ + 1 + /** 大模型 */ + 2 + } + interface IDetectHandOption { + /** 人脸图像像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像宽度 */ + width: number + /** 图像高度 */ + height: number + /** 评分阈值。正常情况传入 0.8 即可。默认值0.8 */ + scoreThreshold?: number + /** 算法检测模式 */ + algoMode?: keyof IAlgoMode + } + /** 算法检测模式 */ + interface IAlgoMode { + /** 检测模式,输出框和点 */ + 0 + /** 手势模式,输出框和手势分类 */ + 1 + /** 结合0和1模式,输出框、点、手势分类 */ + 2 + } + interface IMarker { + /** marker id */ + markerId: number + /** 图片路径 */ + path: string + } + /** OSD marker */ + interface IOSDMarker { + /** marker id */ + markerId: number + /** 图片路径 */ + path: string + } + interface IRunOCROption { + /** 待识别图像的像素点数据,每四项表示一个像素点的 RGBA */ + frameBuffer: ArrayBuffer + /** 图像宽度 */ + width: number + /** 图像高度 */ + height: number + } /** hitTest 检测结果 */ - interface hitTestResult { + interface IHitTestResult { /** 包含位置、旋转、放缩信息的矩阵,以列为主序 */ transform: Float32Array } - /** start status 的合法值 */ - interface StartStatus { + interface IStartStatus { /** 成功 */ 0 /** 系统错误 */ @@ -292,12 +863,12 @@ declare module '../../index' { * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.isVKSupport.html */ - isVKSupport (version: keyof isVKSupport.Version): boolean /** 是否支持对应版本的 vision kit */ + isVKSupport (version: keyof isVKSupport.IVersion): boolean /** 是否支持对应版本的 vision kit */ /** 创建 vision kit 会话对象 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/ai/visionkit/wx.createVKSession.html */ - createVKSession (version: keyof createVKSession.Version): VKSession /** vision kit 会话对象 */ + createVKSession (version: keyof createVKSession.IVersion): VKSession /** vision kit 会话对象 */ } } diff --git a/packages/taro/types/api/base/debug.d.ts b/packages/taro/types/api/base/debug.d.ts index c674deb392ce..09d72b8904b5 100644 --- a/packages/taro/types/api/base/debug.d.ts +++ b/packages/taro/types/api/base/debug.d.ts @@ -39,12 +39,12 @@ declare module '../../index' { * **注意** * - 由于 vConsole 功能有限,以及不同客户端对 console 方法的支持情况有差异,建议开发者在小程序中只使用本文档中提供的方法。 * - 部分内容展示的限制请参见调试 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.html */ interface console { /** 向调试面板中打印 debug 日志 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.debug.html */ debug( @@ -52,7 +52,7 @@ declare module '../../index' { ...args: any[] ): void /** 向调试面板中打印 error 日志 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.error.html */ error( @@ -63,7 +63,7 @@ declare module '../../index' { * * **注意** * 仅在工具中有效,在 vConsole 中为空函数实现。 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.group.html */ group( @@ -74,12 +74,12 @@ declare module '../../index' { * * **注意** * 仅在工具中有效,在 vConsole 中为空函数实现。 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.groupEnd.html */ groupEnd(): void /** 向调试面板中打印 info 日志 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.info.html */ info( @@ -87,7 +87,7 @@ declare module '../../index' { ...args: any[] ): void /** 向调试面板中打印 log 日志 - * @supported weapp, tt + * @supported weapp, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.log.html */ log( @@ -95,7 +95,7 @@ declare module '../../index' { ...args: any[] ): void /** 向调试面板中打印 warn 日志 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/debug/console.warn.html */ warn( diff --git a/packages/taro/types/api/base/env.d.ts b/packages/taro/types/api/base/env.d.ts index cea58e940280..4af6ec22599a 100644 --- a/packages/taro/types/api/base/env.d.ts +++ b/packages/taro/types/api/base/env.d.ts @@ -3,7 +3,7 @@ import Taro from '../../index' declare module '../../index' { interface TaroStatic { /** - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/env/envObj.html */ env: { diff --git a/packages/taro/types/api/base/index.d.ts b/packages/taro/types/api/base/index.d.ts index 118ccf64bb62..2c82f6957286 100644 --- a/packages/taro/types/api/base/index.d.ts +++ b/packages/taro/types/api/base/index.d.ts @@ -3,7 +3,7 @@ import Taro from '../../index' declare module '../../index' { interface TaroStatic { /** 判断小程序的 API,回调,参数,组件等是否在当前版本可用。 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @example * ```tsx * Taro.canIUse('openBluetoothAdapter') @@ -44,7 +44,7 @@ declare module '../../index' { /** * 将 Base64 字符串转成 ArrayBuffer 数据。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * const base64 = 'CxYh' @@ -59,7 +59,7 @@ declare module '../../index' { /** * 将 ArrayBuffer 数据转成 Base64 字符串。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * const arrayBuffer = new Uint8Array([11, 22, 33]) diff --git a/packages/taro/types/api/base/performance.d.ts b/packages/taro/types/api/base/performance.d.ts index cade9108d954..71b7a9c6c21a 100644 --- a/packages/taro/types/api/base/performance.d.ts +++ b/packages/taro/types/api/base/performance.d.ts @@ -32,7 +32,7 @@ declare module '../../index' { * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.createObserver.html */ - createObserver(callback: Function): PerformanceObserver + createObserver(callback: TaroGeneral.TFunc): PerformanceObserver /** 该方法返回当前缓冲区中的所有性能数据 * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/Performance.getEntries.html @@ -191,7 +191,7 @@ declare module '../../index' { src: string } interface Option { - data: AssetsObjectType[] + data: AssetsObject[] /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -222,23 +222,23 @@ declare module '../../index' { /** 预加载下个页面的 WebView * @supported weapp - * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadWebview.html + * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadWebview.html */ preloadWebview(option: preloadWebview.Option): Promise /**预加载下个页面所需要的 Skyline 运行环境 * @supported weapp - * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadSkylineView.html + * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadSkylineView.html */ preloadSkylineView(option: preloadSkylineView.Option): Promise /** 为视图层预加载媒体资源文件, 目前支持:font,image * @supported weapp - * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadAssets.html + * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/performance/wx.preloadAssets.html */ preloadAssets(option: preloadAssets.Option): Promise /** 小程序测速上报。使用前,需要在小程序管理后台配置。 详情参见[小程序测速](https://developers.weixin.qq.com/miniprogram/dev/framework/performanceReport/index.html)指南。 - * + * * **注意** * - 目前,当开启代码 [按需注入](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/lazyload.html) `时,evaluateScript` 将仅包含公有部分代码,页面和组件的代码注入的时间会包含在 `firstRender` 中(因为页面和组件的代码注入过程成为了首次渲染过程的一部分)。因此开启按需注入后,脚本耗时降低,渲染时间提高属于正常现象,优化效果可以关注整体启动耗时(`appLaunch`)来评估。 * - `firstPaint` 和 `firstContentfulPaint` 指标在开启 `vconsole` 的情况下,由于绘制 `vconsoel` 的面板,会导致数据提前。 diff --git a/packages/taro/types/api/base/system.d.ts b/packages/taro/types/api/base/system.d.ts index 262b7305c5a6..09bd8430117f 100644 --- a/packages/taro/types/api/base/system.d.ts +++ b/packages/taro/types/api/base/system.d.ts @@ -510,7 +510,7 @@ declare module '../../index' { openAppAuthorizeSetting(option: openAppAuthorizeSetting.Option): Promise /** 获取窗口信息 - * @supported weapp + * @supported weapp, harmony_hybrid * @h5 不支持 statusBarHeight、safeArea * @example * ```tsx @@ -530,7 +530,7 @@ declare module '../../index' { getWindowInfo(): getWindowInfo.Result /** 获取设备设置 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @h5 不支持 bluetoothEnabled、locationEnabled、wifiEnabled * @example * ```tsx @@ -546,7 +546,7 @@ declare module '../../index' { getSystemSetting(): getSystemSetting.Result /** [Taro.getSystemInfo](./getSystemInfo) 的同步版本 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @h5 不支持 version、statusBarHeight、fontSizeSetting、SDKVersion * @weapp 小程序可以在微信和企业微信中调用此接口,但是在企业微信中调用此接口时,会额外返回一个 environment 字段(微信中不返回),如此字段值为 wxwork,则表示当前小程序运行在企业微信环境中。 * @example @@ -591,7 +591,7 @@ declare module '../../index' { getSystemInfoAsync(res?: getSystemInfoAsync.Option): Promise /** 获取系统信息,支持 `Promise` 化使用。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @h5 不支持 version、statusBarHeight、fontSizeSetting、SDKVersion * @weapp 小程序可以在微信和企业微信中调用此接口,但是在企业微信中调用此接口时,会额外返回一个 environment 字段(微信中不返回),如此字段值为 wxwork,则表示当前小程序运行在企业微信环境中。 * @example @@ -659,7 +659,7 @@ declare module '../../index' { getDeviceInfo(): getDeviceInfo.Result /** 获取微信APP基础信息 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @h5 不支持 SDKVersion、host、version * @example * ```tsx @@ -681,7 +681,7 @@ declare module '../../index' { * - 'authorized' 表示已经获得授权,无需再次请求授权; * - 'denied' 表示请求授权被拒绝,无法再次请求授权;(此情况需要引导用户[打开系统设置](https://developers.weixin.qq.com/miniprogram/dev/api/base/system/wx.openAppAuthorizeSetting.html),在设置页中打开权限) * - 'non determined' 表示尚未请求授权,会在微信下一次调用系统相应权限时请求;(仅 iOS 会出现。此种情况下引导用户打开系统设置,不展示开关) - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @h5 暂未支持设置权限 * @example * ```tsx diff --git a/packages/taro/types/api/base/weapp/app-event.d.ts b/packages/taro/types/api/base/weapp/app-event.d.ts index 72a35a95aac9..9613b3c9c72d 100644 --- a/packages/taro/types/api/base/weapp/app-event.d.ts +++ b/packages/taro/types/api/base/weapp/app-event.d.ts @@ -113,7 +113,7 @@ declare module '../../../index' { * * **注意** * - 所有的 unhandledRejection 都可以被这一监听捕获,但只有 Error 类型的才会在小程序后台触发报警。 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onUnhandledRejection.html */ onUnhandledRejection(callback: onUnhandledRejection.Callback): void @@ -131,13 +131,13 @@ declare module '../../../index' { * - 开发者可以在回调中进行页面重定向,但必须在回调中**同步**处理,异步处理(例如 `setTimeout` 异步执行)无效。 * - 若开发者没有调用 [Taro.onPageNotFound](/docs/apis/base/weapp/app-event/onPageNotFound) 绑定监听,也没有声明 `App.onPageNotFound`,当跳转页面不存在时,将推入微信客户端原生的页面不存在提示页面。 * - 如果回调中又重定向到另一个不存在的页面,将推入微信客户端原生的页面不存在提示页面,并且不再第二次回调。 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onPageNotFound.html */ onPageNotFound(callback: onPageNotFound.Callback): void /** 监听小程序错误事件。如脚本错误或 API 调用报错等。该事件与 [`App.onError`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onerrorstring-error) 的回调时机与参数一致。 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onError.html */ onError(callback: onError.Callback): void @@ -178,7 +178,7 @@ declare module '../../../index' { * **注意** * * 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppShow.html */ onAppShow( @@ -187,7 +187,7 @@ declare module '../../../index' { ): void /** 监听小程序切后台事件。该事件与 [`App.onHide`](https://developers.weixin.qq.com/miniprogram/dev/reference/api/App.html#onhide) 的回调时机一致。 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.onAppHide.html */ onAppHide( @@ -196,7 +196,7 @@ declare module '../../../index' { ): void /** 取消监听未处理的 Promise 拒绝事件 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offUnhandledRejection.html */ offUnhandledRejection(callback: onUnhandledRejection.Callback): void @@ -208,7 +208,7 @@ declare module '../../../index' { offThemeChange(callback: onThemeChange.Callback): void /** 取消监听小程序要打开的页面不存在事件 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offPageNotFound.html */ offPageNotFound( @@ -217,7 +217,7 @@ declare module '../../../index' { ): void /** 取消监听音频播放错误事件 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/InnerAudioContext.offError.html */ @@ -245,7 +245,7 @@ declare module '../../../index' { ): void /** 取消监听小程序切前台事件 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppShow.html */ offAppShow( @@ -254,7 +254,7 @@ declare module '../../../index' { ): void /** 取消监听小程序切后台事件 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/app-event/wx.offAppHide.html */ offAppHide( diff --git a/packages/taro/types/api/base/weapp/life-cycle.d.ts b/packages/taro/types/api/base/weapp/life-cycle.d.ts index d58d74849ecf..f2986b923d35 100644 --- a/packages/taro/types/api/base/weapp/life-cycle.d.ts +++ b/packages/taro/types/api/base/weapp/life-cycle.d.ts @@ -137,7 +137,7 @@ declare module '../../../index' { * * **注意** * 部分版本在无`referrerInfo`的时候会返回 `undefined`,建议使用 `options.referrerInfo && options.referrerInfo.appId` 进行判断。 - * @supported weapp, tt + * @supported weapp, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/base/app/life-cycle/wx.getLaunchOptionsSync.html */ getLaunchOptionsSync(): getLaunchOptionsSync.LaunchOptions diff --git a/packages/taro/types/api/canvas/index.d.ts b/packages/taro/types/api/canvas/index.d.ts index 5eb40ce64dfc..99ea3407615e 100644 --- a/packages/taro/types/api/canvas/index.d.ts +++ b/packages/taro/types/api/canvas/index.d.ts @@ -35,6 +35,10 @@ declare module '../../index' { interface SuccessCallbackResult extends TaroGeneral.CallbackResult { /** 生成文件的临时路径 */ tempFilePath: string + /** 图片路径(本地临时文件)。 + * @supported alipay + */ + apFilePath?: string /** 调用结果 */ errMsg: string } @@ -137,7 +141,46 @@ declare module '../../index' { /** 画布宽度 */ width?: number /** 在自定义组件下,当前组件实例的 this,以操作组件内 [canvas](/docs/components/canvas) 组件 */ - component?: TaroGeneral.IAnyObject, + compInst?: TaroGeneral.IAnyObject, + } + } + + namespace toTempFilePath { + interface Option { + /** 指定的画布区域的左上角横坐标 */ + x?: number + /** 指定的画布区域的左上角纵坐标 */ + y?: number + /** 指定的画布区域的宽度 */ + width?: number + /** 指定的画布区域的高度 */ + height?: number + /** 输出的图片的高度 */ + destHeight?: number + /** 输出的图片的宽度 */ + destWidth?: number + /** 目标文件的类型 + * @default "png" + */ + fileType?: keyof FileType + /** 图片的质量,目前仅对 jpg 有效。取值范围为 (0, 1],不在范围内时当作 1.0 处理。 */ + quality?: number + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (result: SuccessCallbackResult) => void + } + interface FileType { + /** jpg 图片 */ + jpg + /** png 图片 */ + png + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 生成文件的临时路径 */ + tempFilePath: string } } @@ -150,7 +193,7 @@ declare module '../../index' { /** 画布宽度 */ width: number /** 取消由 requestAnimationFrame 添加到计划中的动画帧请求。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。 - * @supported weapp + * @supported weapp, alipay, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.cancelAnimationFrame.html */ cancelAnimationFrame(requestID: number): void @@ -160,7 +203,7 @@ declare module '../../index' { */ createImageData(): ImageData /** 创建一个图片对象。 支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法。 - * @supported weapp + * @supported weapp, alipay, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.createImage.html */ createImage(): Image @@ -172,7 +215,7 @@ declare module '../../index' { path: Path2D ): Path2D /** 支持获取 2D 和 WebGL 绘图上下文 - * @supported weapp + * @supported weapp, alipay, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Canvas.getContext.html */ getContext(contextType: string): RenderingContext @@ -194,6 +237,11 @@ declare module '../../index' { /** 在指定图片格式为 image/jpeg 或 image/webp的情况下,可以从 0 到 1 的区间内选择图片的质量。如果超出取值范围,将会使用默认值 0.92。其他参数会被忽略。 */ encoderOptions: number ): string + /** 把当前画布指定区域保存为图片 + * @supported alipay + * @see https://opendocs.alipay.com/mini/api/toTempFilePath?pathHash=e79fe218 + */ + toTempFilePath(oprion: toTempFilePath.Option): void } /** canvas 组件的绘图上下文 @@ -242,7 +290,7 @@ declare module '../../index' { * - 绿色: 圆心 (100, 75) * - 红色: 起始弧度 (0) * - 蓝色: 终止弧度 (1.5 * Math.PI) - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -298,9 +346,13 @@ declare module '../../index' { eAngle: number, /** 弧度的方向是否是逆时针 */ counterclockwise?: boolean, + /** 弧度的方向是否是逆时针 + * @supported tt + */ + anticlockwise?: boolean ): void /** 根据控制点和半径绘制圆弧路径。 - * @supported weapp, h5 + * @supported weapp, alipay, jd, qq, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.arcTo.html */ arcTo( @@ -319,7 +371,7 @@ declare module '../../index' { * * - 在最开始的时候相当于调用了一次 `beginPath`。 * - 同一个路径内的多次 `setFillStyle`、`setStrokeStyle`、`setLineWidth`等设置,以最后一次设置为准。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -349,7 +401,7 @@ declare module '../../index' { * - 红色:起始点(20, 20) * - 蓝色:两个控制点(20, 100) (200, 100) * - 绿色:终止点(200, 20) - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -404,7 +456,7 @@ declare module '../../index' { y: number, ): void /** 清除画布上在该矩形区域内的内容 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * clearRect 并非画一个白色的矩形在地址区域,而是清空,为了有直观感受,对 canvas 加了一层背景色。 * ```html @@ -432,7 +484,7 @@ declare module '../../index' { height: number, ): void /** 从原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内(不能访问画布上的其他区域)。可以在使用 `clip` 方法前通过使用 `save` 方法对当前画布区域进行保存,并在以后的任意时间通过`restore`方法对其进行恢复。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -453,7 +505,7 @@ declare module '../../index' { */ clip(): void /** 关闭一个路径。会连接起点和终点。如果关闭路径后没有调用 `fill` 或者 `stroke` 并开启了新的路径,那之前的路径将不会被渲染。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -486,7 +538,7 @@ declare module '../../index' { */ closePath(): void /** 创建一个圆形的渐变颜色。起点在圆心,终点在圆环。返回的`CanvasGradient`对象需要使用 [CanvasGradient.addColorStop()](/docs/apis/canvas/CanvasGradient#addcolorstop) 来指定渐变点,至少要两个。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -510,7 +562,7 @@ declare module '../../index' { r: number, ): CanvasGradient /** 创建一个线性的渐变颜色。返回的`CanvasGradient`对象需要使用 [CanvasGradient.addColorStop()](/docs/apis/canvas/CanvasGradient#addcolorstop) 来指定渐变点,至少要两个。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -536,7 +588,7 @@ declare module '../../index' { y1: number, ): CanvasGradient /** 对指定的图像创建模式的方法,可在指定的方向上重复元图像 - * @supported weapp, h5 + * @supported weapp, alipay, jd, qq, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.createPattern.html */ createPattern( @@ -546,7 +598,7 @@ declare module '../../index' { repetition: keyof CanvasContext.Repetition, ): CanvasPattern | null | Promise /** 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @h5 第二次调用 draw 前需要等待上一次 draw 调用结束后再调用,否则新的一次 draw 调用栈不会清空而导致结果异常。 * @example * 第二次 draw() reserve 为 true。所以保留了上一次的绘制结果,在上下文设置的 fillStyle 'red' 也变成了默认的 'black'。 @@ -579,9 +631,13 @@ declare module '../../index' { reserve?: boolean, /** 绘制完成后执行的回调函数 */ callback?: (...args: any[]) => any, + /** 是否使用硬件加速 + * @supported jd + */ + useHardwareAccelerate?: boolean ): void | Promise /** 绘制图像到画布 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @example * 有三个版本的写法: * @@ -609,7 +665,7 @@ declare module '../../index' { dy: number, ): void /** 绘制图像到画布 - * @supported weapp, h5 + * @supported weapp, alipay, h5, harmony_hybrid * @example * 有三个版本的写法: * @@ -641,7 +697,7 @@ declare module '../../index' { dHeight: number, ): void /** 绘制图像到画布 - * @supported weapp, h5 + * @supported weapp, swan, jd, qq, tt, h5, harmony_hybrid * @example * 有三个版本的写法: * @@ -681,7 +737,7 @@ declare module '../../index' { dHeight: number, ): void /** 对当前路径中的内容进行填充。默认的填充色为黑色。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * 如果当前路径没有闭合,fill() 方法会将起点和终点进行连接,然后填充。 * @@ -718,7 +774,7 @@ declare module '../../index' { */ fill(): void /** 填充一个矩形。用 [`setFillStyle`](/docs/apis/canvas/CanvasContext#setfillstyle) 设置矩形的填充色,如果没设置默认是黑色。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -739,7 +795,7 @@ declare module '../../index' { height: number, ): void /** 在画布上绘制被填充的文本 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -761,7 +817,8 @@ declare module '../../index' { maxWidth?: number, ): void /** 增加一个新点,然后创建一条从上次指定点到目标点的线。用 `stroke` 方法来画线条 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid + * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -779,8 +836,8 @@ declare module '../../index' { /** 目标位置的 y 坐标 */ y: number, ): void - /** 测量文本尺寸信息。目前仅返回文本宽度。同步接口。 - * @supported weapp, h5 + /** 测量文本尺寸信息。目前仅返回文本宽度(width)。同步接口。 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.measureText.html */ measureText( @@ -788,7 +845,7 @@ declare module '../../index' { text: string, ): TextMetrics /** 把路径移动到画布中的指定点,不创建线条。用 `stroke` 方法来画线条 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -814,7 +871,7 @@ declare module '../../index' { * - 红色:起始点(20, 20) * - 蓝色:控制点(20, 100) * - 绿色:终止点(200, 20) - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -861,7 +918,7 @@ declare module '../../index' { y: number, ): void /** 创建一个矩形路径。需要用 [`fill`](/docs/apis/canvas/CanvasContext#fill) 或者 [`stroke`](/docs/apis/canvas/CanvasContext#stroke) 方法将矩形真正的画到 `canvas` 中 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -882,8 +939,13 @@ declare module '../../index' { /** 矩形路径的高度 */ height: number, ): void + /** 重置绘图上下文状态 + * @supported h5, harmony_hybrid + * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/reset + */ + reset(): void /** 恢复之前保存的绘图上下文 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -900,7 +962,7 @@ declare module '../../index' { */ restore(): void /** 以原点为中心顺时针旋转当前坐标轴。多次调用旋转的角度会叠加。原点可以用 `translate` 方法修改。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -918,7 +980,7 @@ declare module '../../index' { rotate: number, ): void /** 保存绘图上下文。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -935,7 +997,7 @@ declare module '../../index' { */ save(): void /** 在调用后,之后创建的路径其横纵坐标会被缩放。多次调用倍数会相乘。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -955,7 +1017,7 @@ declare module '../../index' { scaleHeight: number, ): void /** 设置填充色。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -970,7 +1032,7 @@ declare module '../../index' { color: string | CanvasGradient, ): void /** 设置字体的字号 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -991,7 +1053,7 @@ declare module '../../index' { fontSize: number, ): void /** 设置全局画笔透明度。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1011,7 +1073,7 @@ declare module '../../index' { alpha: number, ): void /** 设置线条的端点样式 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1046,7 +1108,7 @@ declare module '../../index' { lineCap: keyof CanvasContext.LineCap, ): void /** 设置虚线样式。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1066,7 +1128,7 @@ declare module '../../index' { offset: number, ): void /** 设置线条的交点样式 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1105,7 +1167,7 @@ declare module '../../index' { lineJoin: keyof CanvasContext.LineJoin, ): void /** 设置线条的宽度 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1137,7 +1199,7 @@ declare module '../../index' { lineWidth: number, ): void /** 设置最大斜接长度。斜接长度指的是在两条线交汇处内角和外角之间的距离。当 [CanvasContext.setLineJoin()](/docs/apis/canvas/CanvasContext#setlinejoin) 为 miter 时才有效。超过最大倾斜长度的,连接处将以 lineJoin 为 bevel 来显示。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1182,7 +1244,7 @@ declare module '../../index' { miterLimit: number, ): void /** 设定阴影样式。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1204,7 +1266,7 @@ declare module '../../index' { color: string, ): void /** 设置描边颜色。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1219,7 +1281,7 @@ declare module '../../index' { color: string | CanvasGradient, ): void /** 设置文字的对齐 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1230,11 +1292,13 @@ declare module '../../index' { * ctx.setFontSize(15) * ctx.setTextAlign('left') * ctx.fillText('textAlign=left', 150, 60) + * await ctx.draw(true) * ctx.setTextAlign('center') * ctx.fillText('textAlign=center', 150, 80) + * await ctx.draw(true) * ctx.setTextAlign('right') * ctx.fillText('textAlign=right', 150, 100) - * ctx.draw() + * await ctx.draw(true) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTextAlign.html */ @@ -1243,7 +1307,7 @@ declare module '../../index' { align: keyof CanvasContext.Align, ): void /** 设置文字的竖直对齐 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1254,13 +1318,16 @@ declare module '../../index' { * ctx.setFontSize(20) * ctx.setTextBaseline('top') * ctx.fillText('top', 5, 75) + * await ctx.draw(true) * ctx.setTextBaseline('middle') * ctx.fillText('middle', 50, 75) + * await ctx.draw(true) * ctx.setTextBaseline('bottom') * ctx.fillText('bottom', 120, 75) + * await ctx.draw(true) * ctx.setTextBaseline('normal') * ctx.fillText('normal', 200, 75) - * ctx.draw() + * await ctx.draw(true) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTextBaseline.html */ @@ -1269,10 +1336,46 @@ declare module '../../index' { textBaseline: keyof CanvasContext.TextBaseline, ): void /** 使用矩阵重新设置(覆盖)当前变换的方法 - * @supported weapp, h5 + * @supported weapp, swan, jd, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.setTransform.html */ setTransform( + /** 水平缩放 */ + scaleX: number, + /** 水平倾斜 */ + skewX: number, + /** 垂直倾斜 */ + skewY: number, + /** 垂直缩放 */ + scaleY: number, + /** 水平移动 */ + translateX: number, + /** 垂直移动 */ + translateY: number, + ): void + /** 使用矩阵重新设置(覆盖)当前变换的方法 + * @supported alipay + * @see https://opendocs.alipay.com/mini/api/wt6glg?pathHash=1d428fc1 + */ + setTransform( + /** 水平缩放 */ + scaleX: number, + /** 垂直倾斜 */ + skewY: number, + /** 水平倾斜 */ + skewX: number, + /** 垂直缩放 */ + scaleY: number, + /** 水平移动 */ + translateX: number, + /** 垂直移动 */ + translateY: number, + ): void + /** 使用矩阵重新设置(覆盖)当前变换的方法 + * @supported qq + * @see https://q.qq.com/wiki/develop/miniprogram/API/canvas/canvasContext.html#settransform + */ + setTransform( /** 水平缩放 */ scaleX: number, /** 垂直缩放 */ @@ -1287,7 +1390,7 @@ declare module '../../index' { translateY: number, ): void /** 画出当前路径的边框。默认颜色色为黑色。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1322,7 +1425,7 @@ declare module '../../index' { */ stroke(): void /** 画一个矩形(非填充)。 用 [`setStrokeStyle`](/docs/apis/canvas/CanvasContext#setstrokestyle) 设置矩形线条的颜色,如果没设置默认是黑色。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1343,7 +1446,7 @@ declare module '../../index' { height: number, ): void /** 给定的 (x, y) 位置绘制文本描边的方法 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.strokeText.html */ strokeText( @@ -1357,9 +1460,45 @@ declare module '../../index' { maxWidth?: number, ): void /** 使用矩阵多次叠加当前变换的方法 - * @supported weapp, h5 + * @supported weapp, jd, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/CanvasContext.transform.html */ + transform( + /** 水平缩放 */ + scaleX: number, + /** 水平倾斜 */ + skewX: number, + /** 垂直倾斜 */ + skewY: number, + /** 垂直缩放 */ + scaleY: number, + /** 水平移动 */ + translateX: number, + /** 垂直移动 */ + translateY: number, + ): void + /** 使用矩阵叠加当前变换。矩阵由方法的参数进行描述,可以缩放、旋转、移动和倾斜上下文 + * @supported alipay + * @see https://opendocs.alipay.com/mini/api/fv97do?pathHash=42ccd479 + */ + transform( + /** 水平缩放 */ + scaleX: number, + /** 垂直倾斜 */ + skewY: number, + /** 水平倾斜 */ + skewX: number, + /** 垂直缩放 */ + scaleY: number, + /** 水平移动 */ + translateX: number, + /** 垂直移动 */ + translateY: number, + ): void + /** 使用矩阵多次叠加当前变换的方法 + * @supported qq + * @see https://q.qq.com/wiki/develop/miniprogram/API/canvas/canvasContext.html#transform + */ transform( /** 水平缩放 */ scaleX: number, @@ -1375,7 +1514,7 @@ declare module '../../index' { translateY: number, ): void /** 对当前坐标系的原点 (0, 0) 进行变换。默认的坐标系原点为页面左上角。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1437,13 +1576,34 @@ declare module '../../index' { } /** 参数 textBaseline 可选值 */ interface TextBaseline { - /** 顶部对齐 */ + /** 顶部对齐 + * @supported weapp, alipay, swan, jd, qq, tt, h5 + */ top - /** 底部对齐 */ + /** 底部对齐 + * @supported weapp, alipay, swan, jd, qq, tt, h5 + */ bottom - /** 居中对齐 */ + /** 居中对齐 + * @supported weapp, alipay, swan, jd, qq, tt, h5 + */ middle + /** + * @supported weapp, alipay, swan, jd, qq, tt, h5 + */ normal + /** 文本基线为悬挂基线。 + * @supported alipay, tt, h5 + */ + hanging + /** 文本基线是标准的字母基线 + * @supported alipay, tt, h5 + */ + alphabetic + /** 文字基线是表意字基线。如果字符本身超出了alphabetic 基线,那么ideograhpic基线位置在字符本身的底部。 + * @supported alipay, tt, h5 + */ + ideographic } } @@ -1453,7 +1613,7 @@ declare module '../../index' { */ interface CanvasGradient { /** 添加颜色的渐变点。小于最小 stop 的部分会按最小 stop 的 color 来渲染,大于最大 stop 的部分会按最大 stop 的 color 来渲染 - * @supported weapp + * @supported weapp, alipay, swan, jd, qq, tt * @example * ```tsx * const ctx = Taro.createCanvasContext('myCanvas') @@ -1660,6 +1820,7 @@ declare module '../../index' { /** origin: 发送完整的referrer; no-referrer: 不发送。 * * 格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本 + * @supported weapp */ referrerPolicy: string /** 图片加载发生错误后触发的回调函数 */ @@ -1686,6 +1847,10 @@ declare module '../../index' { * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.html */ interface OffscreenCanvas { + /** 画布宽度 */ + width: number + /** 画布高度 */ + height: number /** 创建一个图片对象。支持在 2D Canvas 和 WebGL Canvas 下使用, 但不支持混用 2D 和 WebGL 的方法 * * > 注意不允许混用 webgl 和 2d 画布创建的图片对象,使用时请注意尽量使用 canvas 自身的 createImage 创建图片对象。 @@ -1696,17 +1861,143 @@ declare module '../../index' { /** 该方法返回 OffscreenCanvas 的绘图上下文 * * > 当前仅支持获取 WebGL 绘图上下文 - * @supported weapp + * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/OffscreenCanvas.getContext.html */ - getContext(contextType: string): RenderingContext + getContext(contextType: 'webgl' | '2d'): RenderingContext } /** Canvas 2D API 的接口 Path2D 用来声明路径,此路径稍后会被CanvasRenderingContext2D 对象使用。CanvasRenderingContext2D 接口的 路径方法 也存在于 Path2D 这个接口中,允许你在 canvas 中根据需要创建可以保留并重用的路径。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/Path2D.html */ - interface Path2D {} + interface Path2D { + /** 添加路径到当前路径。 + * @supported weapp + */ + addPath( + /** 添加的 Path2D 路径 */ + path: Path2D + ): void + /** 添加一段圆弧路径 + * @supported weapp + */ + arc( + /** 圆心横坐标 */ + x: number, + /** 圆心纵坐标 */ + y: number, + /** 圆形半径,必须为正数 */ + radius: number, + /** 圆弧开始角度 */ + startAngle: number, + /** 圆弧结束角度 */ + endAngle: number, + /** 是否逆时针绘制。如果传 true, 则会从 endAngle 开始绘制到 startAngle */ + counterclockwise: boolean + ): void + /** 通过给定控制点添加一段圆弧路径 + * @supported weapp + */ + arcTo( + /** 第一个控制点横坐标 */ + x1: number, + /** 第一个控制点纵坐标 */ + y1: number, + /** 第二个控制点横坐标 */ + x2: number, + /** 第二个控制点纵坐标 */ + y2: number, + /** 圆形半径,必须为非负数 */ + radius: number + ): void + /** 添加三次贝塞尔曲线路径 + * @supported weapp + */ + bezierCurveTo( + /** 第一个控制点横坐标 */ + cp1x: number, + /** 第一个控制点纵坐标 */ + cp1y: number, + /** 第二个控制点横坐标 */ + cp2x: number, + /** 第二个控制点纵坐标 */ + cp2y: number, + /** 结束点横坐标 */ + x: number, + /** 结束点纵坐标 */ + y: number + ): void + /** 闭合路径到起点 + * @supported weapp + */ + closePath(): void + /** 添加椭圆弧路径 + * @supported weapp + */ + ellipse( + /** 椭圆圆心横坐标 */ + x: number, + /** 椭圆圆心纵坐标 */ + y: number, + /** 椭圆长轴半径,必须为非负数 */ + radiusX: number, + /** 椭圆短轴半径,必须为非负数 */ + radiusY: number, + /** 椭圆旋转角度 */ + rotation: number, + /** 圆弧开始角度 */ + startAngle: number, + /** 圆弧结束角度 */ + endAngle: number, + /** 是否逆时针绘制。如果传 true, 则会从 endAngle 开始绘制到 startAngle */ + counterclockwise: boolean + ): void + /** 添加直线路径 + * @supported weapp + */ + lineTo( + /** 结束点横坐标 */ + x: number, + /** 结束点纵坐标 */ + y: number + ): void + /** 移动路径开始点 + * @supported weapp + */ + moveTo( + /** 横坐标 */ + x: number, + /** 纵坐标 */ + y: number + ): void + /** 添加二次贝塞尔曲线路径 + * @supported weapp + */ + quadraticCurveTo( + /** 控制点横坐标 */ + cpx: number, + /** 控制点纵坐标 */ + cpy: number, + /** 结束点横坐标 */ + x: number, + /** 结束点纵坐标 */ + y: number + ): void + /** 添加方形路径 + * @supported weapp + */ + rect( + /** 开始点横坐标 */ + x: number, + /** 开始点纵坐标 */ + y: number, + /** 方形宽度,正数向右,负数向左 */ + width: number, + /** 方形高度,正数向下,负数向上 */ + height: number + ): void + } /** Canvas 绘图上下文。 * @@ -1714,14 +2005,37 @@ declare module '../../index' { * * - 通过 Canvas.getContext('2d') 接口可以获取 CanvasRenderingContext2D 对象,实现了 [HTML Canvas 2D Context](https://www.w3.org/TR/2dcontext/) 定义的属性、方法。 * - 通过 Canvas.getContext('webgl') 或 OffscreenCanvas.getContext('webgl') 接口可以获取 WebGLRenderingContext 对象,实现了 [WebGL 1.0](https://www.khronos.org/registry/webgl/specs/latest/1.0/) 定义的所有属性、方法、常量。 - * @supported weapp + * - CanvasRenderingContext2D 的 drawImage 方法 2.10.0 起支持传入通过 SelectorQuery 获取的 video 对象,2.29.0 起支持传入开启了自定义渲染的 LivePusherContext 对象。 + * @supported weapp, alipay, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/RenderingContext.html */ interface RenderingContext {} interface TaroStatic { /** 创建离屏 canvas 实例 - * @supported weapp + * @supported weapp, tt + * @example + * ```tsx + * // 创建离屏 2D canvas 实例 + * const canvas = Taro.createOffscreenCanvas({type: '2d', width: 300, height: 150}) + * // 获取 context。注意这里必须要与创建时的 type 一致 + * const context = canvas.getContext('2d') + * + * // 创建一个图片 + * const image = canvas.createImage() + * // 等待图片加载 + * await new Promise(resolve => { + * image.onload = resolve + * image.src = IMAGE_URL // 要加载的图片 url + * }) + * + * // 把图片画到离屏 canvas 上 + * context.clearRect(0, 0, 300, 150) + * context.drawImage(image, 0, 0, 300, 150) + * + * // 获取画完后的数据 + * const imgData = context.getImageData(0, 0, 300, 150) + * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.createOffscreenCanvas.html * * 有两个版本的写法: @@ -1734,7 +2048,7 @@ declare module '../../index' { /** 创建 canvas 的绘图上下文 [CanvasContext](/docs/apis/canvas/CanvasContext) 对象 * * **Tip**: 需要指定 canvasId,该绘图上下文只作用于对应的 ``;另外,Web 端需要在 `useReady` 回调中执行它,否则会因为底层 canvas 渲染出来之前而去获取 CanvasContext,导致其底层的 context 为 `undefined`,从而不能正常绘图。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * import { useReady } from '@tarojs/taro' @@ -1788,7 +2102,7 @@ declare module '../../index' { * } * }) * ``` - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/canvas/wx.canvasToTempFilePath.html */ canvasToTempFilePath( @@ -1798,7 +2112,7 @@ declare module '../../index' { ): Promise /** 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 `` 组件 - * @supported weapp, h5 + * @supported weapp, swan, jd, qq, h5, harmony_hybrid * @example * ```tsx * const data = new Uint8ClampedArray([255, 0, 0, 1]) @@ -1820,7 +2134,7 @@ declare module '../../index' { ): Promise /** 获取 canvas 区域隐含的像素数据。 - * @supported weapp, h5 + * @supported weapp, swan, jd, qq, h5, harmony_hybrid * @example * ```tsx * Taro.canvasGetImageData({ diff --git a/packages/taro/types/api/data-analysis/index.d.ts b/packages/taro/types/api/data-analysis/index.d.ts index 3af0bddfa205..ba66a83c2e13 100644 --- a/packages/taro/types/api/data-analysis/index.d.ts +++ b/packages/taro/types/api/data-analysis/index.d.ts @@ -1,6 +1,33 @@ import Taro from '../../index' declare module '../../index' { + namespace getCommonConfig { + interface Option { + /** 需要获取的数据指标的对象数组,每个string的格式约定:配置类型_分表key */ + keys?: string[] + /** 0:通用配置模式 1:实验模式, 参数与返回结果的使用等效于接口wx.getExptInfoSync */ + mode: 0 | 1 + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 错误码 */ + errcode: number + /** 错误信息 */ + errmsg: string + /** 配置类型, 1-表类型 2-kv类型 */ + conf_type: number + /** 根据conf_type来确定conf内容, conf_type为1时conf是一个json数组, 类似"[{xxx},{xxx}]", 每一项对应表类型每一行配置内容, 其中conf_type为2时conf是一个json对象,类似"{xxxx}" */ + conf: string + /** 过期时间,单位秒. 0表示当次有效 */ + expire_sec: number + } + } + interface TaroStatic { /** 自定义业务数据监控上报接口。 * @@ -21,7 +48,7 @@ declare module '../../index' { ): void /** 自定义分析数据上报接口。使用前,需要在小程序管理后台自定义分析中新建事件,配置好事件名与字段。 - * @supported weapp, tt + * @supported weapp, swan, tt * @example * ```tsx * Taro.reportAnalytics('purchase', { @@ -68,5 +95,28 @@ declare module '../../index' { /** 实验参数数组,不填则获取所有实验参数 */ keys?: Array ): TaroGeneral.IAnyObject + + /** 给定实验参数数组,获取对应的实验参数值 + * @supported weapp + * @example + * ```tsx + * Taro.getCommonConfig({ + * keys:["key1", "key2"], + * mode: 0, + * success: (res) => { + * console.log("success") + * console.log(res) + * }, + * fail: (res) => { + * console.log("fail") + * console.log(res) + * } + * }) + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/data-analysis/wx.getCommonConfig.html + */ + getCommonConfig( + option: getCommonConfig.Option + ): Promise } } diff --git a/packages/taro/types/api/device/accelerometer.d.ts b/packages/taro/types/api/device/accelerometer.d.ts index 7ee333d89d92..02cf4b7a0e2c 100644 --- a/packages/taro/types/api/device/accelerometer.d.ts +++ b/packages/taro/types/api/device/accelerometer.d.ts @@ -56,7 +56,7 @@ declare module '../../index' { * ```tsx * Taro.startAccelerometer({ interval: 'game' }) * ``` - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.startAccelerometer.html */ startAccelerometer (res?: startAccelerometer.Option): Promise @@ -67,14 +67,14 @@ declare module '../../index' { * ```tsx * Taro.stopAccelerometer() * ``` - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.stopAccelerometer.html */ stopAccelerometer (res?: stopAccelerometer.Option): Promise /** * 监听加速度数据,频率:5次/秒,接口调用后会自动开始监听,可使用 `Taro.stopAccelerometer` 停止监听。 - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn * @example * ```tsx * Taro.onAccelerometerChange(res => { @@ -85,16 +85,18 @@ declare module '../../index' { * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.onAccelerometerChange.html */ - onAccelerometerChange (callback: onAccelerometerChange.Callback): void + onAccelerometerChange( + callback: onAccelerometerChange.Callback + ): void /** * 取消监听加速度数据事件,参数为空,则取消所有的事件监听。 - * @supported weapp, h5, rn + * @supported weapp, alipay, swan, jd, tt, h5, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accelerometer/wx.offAccelerometerChange.html */ offAccelerometerChange( /** 加速度数据事件的回调函数 */ - callback?: (...args: any[]) => any, + callback?: onAccelerometerChange.Callback ): void } } diff --git a/packages/taro/types/api/device/accessibility.d.ts b/packages/taro/types/api/device/accessibility.d.ts index f1dbcc9aa52b..66da3352c417 100644 --- a/packages/taro/types/api/device/accessibility.d.ts +++ b/packages/taro/types/api/device/accessibility.d.ts @@ -18,7 +18,7 @@ declare module '../../index' { interface TaroStatic { /** 检测是否开启视觉无障碍功能。 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/accessibility/wx.checkIsOpenAccessibility.html */ checkIsOpenAccessibility(option: checkIsOpenAccessibility.Option): Promise diff --git a/packages/taro/types/api/device/battery.d.ts b/packages/taro/types/api/device/battery.d.ts index a1795a16f2ee..58baf1180378 100644 --- a/packages/taro/types/api/device/battery.d.ts +++ b/packages/taro/types/api/device/battery.d.ts @@ -6,7 +6,7 @@ declare module '../../index' { /** 是否正在充电中 */ isCharging: boolean /** 设备电量,范围 1 - 100 */ - level: string + level: number } } @@ -32,13 +32,13 @@ declare module '../../index' { interface TaroStatic { /** Taro.getBatteryInfo 的同步版本 - * @supported weapp + * @supported weapp, alipay, swan, jd, qq * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/battery/wx.getBatteryInfoSync.html */ getBatteryInfoSync(): getBatteryInfoSync.Result /** 获取设备电量。同步 API Taro.getBatteryInfoSync 在 iOS 上不可用。 - * @supported weapp, h5 + * @supported weapp, alipay, swan, jd, qq, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/battery/wx.getBatteryInfo.html */ getBatteryInfo(option?: getBatteryInfo.Option): Promise diff --git a/packages/taro/types/api/device/bluetooth-ble.d.ts b/packages/taro/types/api/device/bluetooth-ble.d.ts index 8c2ca65a4ba2..5459d5cc99a5 100644 --- a/packages/taro/types/api/device/bluetooth-ble.d.ts +++ b/packages/taro/types/api/device/bluetooth-ble.d.ts @@ -15,6 +15,8 @@ declare module '../../index' { serviceId: string /** 蓝牙设备特征值对应的二进制值 */ value: ArrayBuffer + /** 蓝牙特征值的写模式设置,有两种模式,iOS 优先 write,安卓优先 writeNoResponse 。(基础库 2.22.0 开始支持) */ + writeType?: keyof WriteType /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.BluetoothError) => void /** 接口调用失败的回调函数 */ @@ -22,6 +24,12 @@ declare module '../../index' { /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.BluetoothError) => void } + interface WriteType { + /** 强制回复写,不支持时报错 */ + write + /** 强制无回复写,不支持时报错 */ + writeNoResponse + } } namespace setBLEMTU { @@ -122,6 +130,10 @@ declare module '../../index' { serviceId: string /** 是否启用 notify */ state: boolean + /** 设置特征订阅类型,有效值有 notification 和 indication + * @default "indication" + */ + type?: keyof Type /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.BluetoothError) => void /** 接口调用失败的回调函数 */ @@ -129,6 +141,10 @@ declare module '../../index' { /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.BluetoothError) => void } + interface Type { + notification + indication + } } namespace getBLEMTU { @@ -138,7 +154,7 @@ declare module '../../index' { /** 写模式 (iOS 特有参数) * @default "write" */ - writeType: keyof WriteType + writeType?: keyof WriteType /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.BluetoothError) => void /** 接口调用失败的回调函数 */ @@ -244,6 +260,10 @@ declare module '../../index' { read: boolean /** 该特征值是否支持 write 操作 */ write: boolean + /** 该特征是否支持无回复写操作 */ + writeNoResponse: boolean + /** 该特征是否支持有回复写操作 */ + writeDefault: boolean } } @@ -291,7 +311,7 @@ declare module '../../index' { * - 小程序不会对写入数据包大小做限制,但系统与蓝牙设备会限制蓝牙4.0单次传输的数据大小,超过最大字节数后会发生写入错误,建议每次写入不超过20字节。 * - 若单次写入数据过长,iOS 上存在系统不会有任何回调的情况(包括错误回调)。 * - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * // 向蓝牙设备发送一个0x00的16进制数据 @@ -319,7 +339,10 @@ declare module '../../index' { ): Promise /** 协商设置蓝牙低功耗的最大传输单元 (Maximum Transmission Unit, MTU) - * @supported weapp + * + * - 需在 Taro.createBLEConnection 调用成功后调用 + * - 仅安卓系统 5.1 以上版本有效,iOS 因系统限制不支持。 + * @supported weapp, alipay, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.setBLEMTU.html */ setBLEMTU( @@ -331,7 +354,7 @@ declare module '../../index' { * **注意** * - 并行调用多次会存在读失败的可能性。 * - 接口读取到的信息需要在 `onBLECharacteristicValueChange` 方法注册的回调中获取。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * // 必须在这里的回调才能获取 @@ -372,7 +395,7 @@ declare module '../../index' { ): void /** 监听低功耗蓝牙连接状态的改变事件。包括开发者主动连接或断开连接,设备丢失,连接异常断开等等 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.onBLEConnectionStateChange(function (res) { @@ -388,7 +411,7 @@ declare module '../../index' { ): void /** 监听低功耗蓝牙设备的特征值变化事件。必须先启用 `notifyBLECharacteristicValueChange` 接口才能接收到设备推送的 notification。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * // ArrayBuffer转16进制字符串示例 @@ -419,20 +442,20 @@ declare module '../../index' { */ offBLEMTUChange( /** 蓝牙低功耗的最大传输单元变化事件的回调函数 */ - callback: onBLEMTUChange.Callback, + callback?: onBLEMTUChange.Callback, ): void /** 取消监听蓝牙低功耗连接状态的改变事件 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html */ offBLEConnectionStateChange( /** 蓝牙低功耗连接状态的改变事件的回调函数 */ - callback: onBLEConnectionStateChange.Callback, + callback?: onBLEConnectionStateChange.Callback, ): void /** 取消监听蓝牙低功耗设备的特征值变化事件 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLECharacteristicValueChange.html */ offBLECharacteristicValueChange( @@ -447,7 +470,7 @@ declare module '../../index' { * **注意** * - 订阅操作成功后需要设备主动更新特征值的 value,才会触发 Taro.onBLECharacteristicValueChange 回调。 * - 安卓平台上,在调用 `notifyBLECharacteristicValueChange` 成功后立即调用 `writeBLECharacteristicValue` 接口,在部分机型上会发生 10008 系统错误 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.notifyBLECharacteristicValueChange({ @@ -474,7 +497,7 @@ declare module '../../index' { * 注意: * - 小程序中 MTU 为 ATT_MTU,包含 Op-Code 和 Attribute Handle 的长度,实际可以传输的数据长度为 ATT_MTU - 3 * - iOS 系统中 MTU 为固定值;安卓系统中,MTU 会在系统协商成功之后发生改变,建议使用 [Taro.onBLEMTUChange](/docs/apis/device/bluetooth-ble/onBLEMTUChange) 监听。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.getBLEMTU({ @@ -492,7 +515,7 @@ declare module '../../index' { ): Promise /** 获取蓝牙设备所有服务(service)。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.getBLEDeviceServices({ @@ -510,7 +533,7 @@ declare module '../../index' { ): Promise /** 获取蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI)。 - * @supported weapp + * @supported weapp, alipay, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceRSSI.html */ getBLEDeviceRSSI( @@ -518,7 +541,7 @@ declare module '../../index' { ): Promise /** 获取蓝牙设备某个服务中所有特征值(characteristic)。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.getBLEDeviceCharacteristics({ @@ -545,7 +568,7 @@ declare module '../../index' { * - 请保证尽量成对的调用 `createBLEConnection` 和 `closeBLEConnection` 接口。安卓如果多次调用 `createBLEConnection` 创建连接,有可能导致系统持有同一设备多个连接的实例,导致调用 `closeBLEConnection` 的时候并不能真正的断开与设备的连接。 * - 蓝牙连接随时可能断开,建议监听 Taro.onBLEConnectionStateChange 回调事件,当蓝牙设备断开时按需执行重连操作 * - 若对未连接的设备或已断开连接的设备调用数据读写操作的接口,会返回 10006 错误,建议进行重连操作。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.createBLEConnection({ @@ -561,7 +584,7 @@ declare module '../../index' { createBLEConnection(option: createBLEConnection.Option): Promise /** 断开与低功耗蓝牙设备的连接。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.closeBLEConnection({ diff --git a/packages/taro/types/api/device/bluetooth-peripheral.d.ts b/packages/taro/types/api/device/bluetooth-peripheral.d.ts index 623da307e61f..e8f63a72a752 100644 --- a/packages/taro/types/api/device/bluetooth-peripheral.d.ts +++ b/packages/taro/types/api/device/bluetooth-peripheral.d.ts @@ -13,7 +13,7 @@ declare module '../../index' { /** server 的 UUID */ serverId: string /** 连接目前状态 */ - connected: string + connected: boolean } } @@ -38,7 +38,7 @@ declare module '../../index' { */ interface BLEPeripheralServer { /** 添加服务 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.addService.html */ addService(option: BLEPeripheralServer.addService.Option): Promise @@ -48,20 +48,20 @@ declare module '../../index' { */ close(option: BLEPeripheralServer.close.Option): Promise /** 取消监听已连接的设备请求读当前外围设备的特征值事件 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicReadRequest.html */ offCharacteristicReadRequest( /** 已连接的设备请求读当前外围设备的特征值事件的回调函数 */ - callback: BLEPeripheralServer.onCharacteristicReadRequest.Callback, + callback?: BLEPeripheralServer.onCharacteristicReadRequest.Callback, ): void /** 取消监听特征订阅事件 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicSubscribed.html */ offCharacteristicSubscribed( /** 特征订阅事件的回调函数 */ - callback: BLEPeripheralServer.onCharacteristicSubscribed.Callback, + callback?: BLEPeripheralServer.onCharacteristicSubscribed.Callback, ): void /** 取消监听取消特征订阅事件 * @supported weapp @@ -69,20 +69,20 @@ declare module '../../index' { */ offCharacteristicUnsubscribed( /** 取消特征订阅事件的回调函数 */ - callback: BLEPeripheralServer.onCharacteristicUnsubscribed.Callback, + callback?: BLEPeripheralServer.onCharacteristicUnsubscribed.Callback, ): void /** 取消监听已连接的设备请求写当前外围设备的特征值事件 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.offCharacteristicWriteRequest.html */ offCharacteristicWriteRequest( /** 已连接的设备请求写当前外围设备的特征值事件的回调函数 */ - callback: BLEPeripheralServer.onCharacteristicWriteRequest.Callback, + callback?: BLEPeripheralServer.onCharacteristicWriteRequest.Callback, ): void /** 监听已连接的设备请求读当前外围设备的特征值事件 * * 收到该消息后需要立刻调用 [writeCharacteristicValue](/docs/apis/device/bluetooth-peripheral/BLEPeripheralServer#writecharacteristicvalue) 写回数据,否则主机不会收到响应。 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicReadRequest.html */ onCharacteristicReadRequest( @@ -90,7 +90,7 @@ declare module '../../index' { callback: BLEPeripheralServer.onCharacteristicReadRequest.Callback, ): void /** 监听特征订阅事件,仅 iOS 支持 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicSubscribed.html */ onCharacteristicSubscribed( @@ -98,7 +98,7 @@ declare module '../../index' { callback: BLEPeripheralServer.onCharacteristicSubscribed.Callback, ): void /** 监听取消特征订阅事件,仅 iOS 支持 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicUnsubscribed.html */ onCharacteristicUnsubscribed( @@ -106,7 +106,7 @@ declare module '../../index' { callback: BLEPeripheralServer.onCharacteristicUnsubscribed.Callback, ): void /** 监听已连接的设备请求写当前外围设备的特征值事件 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.onCharacteristicWriteRequest.html */ onCharacteristicWriteRequest( @@ -114,22 +114,22 @@ declare module '../../index' { callback: BLEPeripheralServer.onCharacteristicWriteRequest.Callback, ): void /** 移除服务 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.removeService.html */ removeService(option: BLEPeripheralServer.removeService.Option): Promise /** 开始广播本地创建的外围设备 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.startAdvertising.html */ startAdvertising(option: BLEPeripheralServer.startAdvertising.Option): Promise /** 停止广播 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.stopAdvertising.html */ stopAdvertising(option: BLEPeripheralServer.stopAdvertising.Option): Promise /** 往指定特征写入二进制数据值,并通知已连接的主机,从机的特征值已发生变化,该接口会处理是走回包还是走订阅 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/BLEPeripheralServer.writeCharacteristicValue.html */ writeCharacteristicValue(option: BLEPeripheralServer.writeCharacteristicValue.Option): Promise @@ -157,13 +157,13 @@ declare module '../../index' { /** characteristic 的 UUID */ uuid: string /** 特征支持的操作 */ - properties: properties + properties?: properties /** 特征权限 */ - permission: characteristicPermission + permission?: characteristicPermission /** 特征对应的二进制值 */ - value: ArrayBuffer + value?: ArrayBuffer /** 描述符数据 */ - descriptors: descriptor[] + descriptors?: descriptor[] } /** 特征支持的操作 */ interface properties { @@ -212,7 +212,7 @@ declare module '../../index' { /** Descriptor 的 UUID */ uuid: string /** 描述符的权限 */ - permission: descriptorPermission + permission?: descriptorPermission /** 描述符数据 */ value: ArrayBuffer } @@ -402,7 +402,7 @@ declare module '../../index' { interface TaroStatic { /** 监听当前外围设备被连接或断开连接事件 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.onBLEPeripheralConnectionStateChanged.html */ onBLEPeripheralConnectionStateChanged( @@ -411,16 +411,16 @@ declare module '../../index' { ): void /** 取消监听当前外围设备被连接或断开连接事件 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.offBLEPeripheralConnectionStateChanged.html */ offBLEPeripheralConnectionStateChanged( /** 当前外围设备被连接或断开连接事件的回调函数 */ - callback: onBLEPeripheralConnectionStateChanged.Callback, + callback?: onBLEPeripheralConnectionStateChanged.Callback, ): void /** 建立本地作为蓝牙低功耗外围设备的服务端,可创建多个 - * @supported weapp + * @supported weapp, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-peripheral/wx.createBLEPeripheralServer.html */ createBLEPeripheralServer( diff --git a/packages/taro/types/api/device/bluetooth.d.ts b/packages/taro/types/api/device/bluetooth.d.ts index a9ff7c18f3e8..9775de7c4b06 100644 --- a/packages/taro/types/api/device/bluetooth.d.ts +++ b/packages/taro/types/api/device/bluetooth.d.ts @@ -32,13 +32,26 @@ declare module '../../index' { interval?: number /** 要搜索的蓝牙设备主 service 的 uuid 列表。某些蓝牙设备会广播自己的主 service 的 uuid。如果设置此参数,则只搜索广播包有对应 uuid 的主服务的蓝牙设备。建议主要通过该参数过滤掉周边不需要处理的其他蓝牙设备。 */ services?: string[] + /** 扫描模式,越高扫描越快,也越耗电。仅安卓微信客户端 7.0.12 及以上支持。 */ + powerLevel?: keyof PowerLevel /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.BluetoothError) => void } + + interface PowerLevel { + /** 低 */ + low, + /** 中 */ + medium, + /** 高 */ + high + } } namespace openBluetoothAdapter { interface Option { + /** 蓝牙模式,可作为主/从设备,仅 iOS 需要。 */ + mode?: keyof Mode; /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.BluetoothError) => void /** 接口调用失败的回调函数 */ @@ -47,6 +60,13 @@ declare module '../../index' { success?: (res: TaroGeneral.BluetoothError) => void } + interface Mode { + /** 主机模式 */ + central + /** 从机(外围设备)模式 */ + peripheral + } + /** object.fail 回调函数返回的 state 参数(仅 iOS) */ interface state { /** 未知 */ @@ -73,7 +93,7 @@ declare module '../../index' { } /** 新搜索到的设备 */ interface CallbackResultBlueToothDevice { - /** 当前蓝牙设备的信号强度 */ + /** 当前蓝牙设备的信号强度,单位 dBm */ RSSI: number /** 当前蓝牙设备的广播数据段中的 ManufacturerData 数据段。 */ advertisData: ArrayBuffer @@ -87,6 +107,8 @@ declare module '../../index' { name: string /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */ serviceData: TaroGeneral.IAnyObject + /** 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) */ + connectable?: boolean } } @@ -193,6 +215,8 @@ declare module '../../index' { name: string /** 当前蓝牙设备的广播数据段中的 ServiceData 数据段 */ serviceData: TaroGeneral.IAnyObject + /** 当前蓝牙设备是否可连接( Android 8.0 以下不支持返回该值 ) */ + connectable?: boolean } } @@ -229,7 +253,7 @@ declare module '../../index' { interface TaroStatic { /** 停止搜寻附近的蓝牙外围设备。若已经找到需要的蓝牙设备并不需要继续搜索时,建议调用该接口停止蓝牙搜索。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.stopBluetoothDevicesDiscovery({ @@ -245,7 +269,7 @@ declare module '../../index' { ): Promise /** 开始搜寻附近的蓝牙外围设备。**此操作比较耗费系统资源,请在搜索并连接到设备后调用 Taro.stopBluetoothDevicesDiscovery 方法停止搜索。** - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * // 以微信硬件平台的蓝牙智能灯为例,主服务的 UUID 是 FEE7。传入这个参数,只搜索主服务 UUID 为 FEE7 的设备 @@ -267,7 +291,7 @@ declare module '../../index' { * **注意** * - 其他蓝牙相关 API 必须在 Taro.openBluetoothAdapter 调用之后使用。否则 API 会返回错误(errCode=10000)。 * - 在用户蓝牙开关未开启或者手机不支持蓝牙功能的情况下,调用 Taro.openBluetoothAdapter 监听手机蓝牙状态的改变,也可以调用蓝牙模块的所有API。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.openBluetoothAdapter({ @@ -285,7 +309,7 @@ declare module '../../index' { * **注意** * - 若在 Taro.onBluetoothDeviceFound 回调了某个设备,则此设备会添加到 Taro.getBluetoothDevices 接口获取到的数组中。 * - 安卓下部分机型需要有位置权限才能搜索到设备,需留意是否开启了位置权限 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * // ArrayBuffer转16进度字符串示例 @@ -313,7 +337,7 @@ declare module '../../index' { ): void /** 监听蓝牙适配器状态变化事件 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.onBluetoothAdapterStateChange(function (res) { @@ -328,7 +352,7 @@ declare module '../../index' { ): void /** 取消监听寻找到新设备的事件 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothDeviceFound.html */ offBluetoothDeviceFound( @@ -337,7 +361,7 @@ declare module '../../index' { ): void /** 取消监听蓝牙适配器状态变化事件 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.offBluetoothAdapterStateChange.html */ offBluetoothAdapterStateChange( @@ -357,10 +381,10 @@ declare module '../../index' { * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth/wx.isBluetoothDevicePaired.html */ - isBluetoothDevicePaired(option: isBluetoothDevicePaired.Option): boolean + isBluetoothDevicePaired(option: isBluetoothDevicePaired.Option): Promise /** 根据 uuid 获取处于已连接状态的设备。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.getConnectedBluetoothDevices({ @@ -380,7 +404,7 @@ declare module '../../index' { * **注意事项** * - 该接口获取到的设备列表为**蓝牙模块生效期间所有搜索到的蓝牙设备**,若在蓝牙模块使用流程结束后未及时调用 Taro.closeBluetoothAdapter 释放资源,会存在调用该接口会返回之前的蓝牙使用流程中搜索到的蓝牙设备,可能设备已经不在用户身边,无法连接。 * - 蓝牙设备在被搜索到时,系统返回的 name 字段一般为广播包中的 LocalName 字段中的设备名称,而如果与蓝牙设备建立连接,系统返回的 name 字段会改为从蓝牙设备上获取到的 `GattName`。若需要动态改变设备名称并展示,建议使用 `localName` 字段。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * // ArrayBuffer转16进度字符串示例 @@ -407,7 +431,7 @@ declare module '../../index' { getBluetoothDevices(option?: getBluetoothDevices.Option): Promise /** 获取本机蓝牙适配器状态。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.getBluetoothAdapterState({ @@ -423,7 +447,7 @@ declare module '../../index' { ): Promise /** 关闭蓝牙模块。调用该方法将断开所有已建立的连接并释放系统资源。建议在使用蓝牙流程后,与 Taro.openBluetoothAdapter 成对调用。 - * @supported weapp + * @supported weapp, alipay, jd * @example * ```tsx * Taro.closeBluetoothAdapter({ diff --git a/packages/taro/types/api/device/calendar.d.ts b/packages/taro/types/api/device/calendar.d.ts index c33eaf89363b..d39f291607b4 100644 --- a/packages/taro/types/api/device/calendar.d.ts +++ b/packages/taro/types/api/device/calendar.d.ts @@ -28,7 +28,7 @@ declare module '../../index' { /** 重复周期,默认 month 每月重复 * @default "month" */ - repeatInterval?: string + repeatInterval?: keyof RepeatInterval /** 重复周期结束时间的 unix 时间戳,不填表示一直重复 */ repeatEndTime?: number /** 接口调用结束的回调函数(调用成功、失败都会执行) */ @@ -38,6 +38,16 @@ declare module '../../index' { /** 接口调用成功的回调函数 */ success?: (result: TaroGeneral.CallbackResult) => void } + interface RepeatInterval { + /** 每天重复 */ + day + /** 每周重复 */ + week + /** 每月重复。该模式日期不能大于 28 日 */ + month + /** 每年重复 */ + year + } } namespace addPhoneCalendar { diff --git a/packages/taro/types/api/device/clipboard.d.ts b/packages/taro/types/api/device/clipboard.d.ts index 3796515e7c1a..6294af99e554 100644 --- a/packages/taro/types/api/device/clipboard.d.ts +++ b/packages/taro/types/api/device/clipboard.d.ts @@ -43,7 +43,7 @@ declare module '../../index' { interface TaroStatic { /** 设置系统剪贴板的内容。调用成功后,会弹出 toast 提示"内容已复制",持续 1.5s - * @supported weapp, h5, rn, tt + * @supported weapp, swan, jd, qq, h5, rn, tt, harmony_hybrid * @h5 部分实现 * @example * ```tsx @@ -60,22 +60,22 @@ declare module '../../index' { * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/clipboard/wx.setClipboardData.html */ - setClipboardData(option: setClipboardData.Option): Promise + setClipboardData(option: setClipboardData.Option): Promise - /** - * 获取系统剪贴板内容 - * @supported weapp, h5, rn, tt - * @h5 部分实现 - * @example - * ```tsx - * Taro.getClipboardData({ - * success: function (res){ - * console.log(res.data) - * } - * }) - * ``` - * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/clipboard/wx.getClipboardData.html - */ - getClipboardData(res?: getClipboardData.Option): Promise + /** + * 获取系统剪贴板内容 + * @supported weapp, swan, jd, qq, h5, rn, tt, harmony_hybrid + * @h5 部分实现 + * @example + * ```tsx + * Taro.getClipboardData({ + * success: function (res){ + * console.log(res.data) + * } + * }) + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/clipboard/wx.getClipboardData.html + */ + getClipboardData(res?: getClipboardData.Option): Promise } } diff --git a/packages/taro/types/api/device/compass.d.ts b/packages/taro/types/api/device/compass.d.ts index 67fece4344d5..4351ae30c603 100644 --- a/packages/taro/types/api/device/compass.d.ts +++ b/packages/taro/types/api/device/compass.d.ts @@ -59,7 +59,7 @@ declare module '../../index' { interface TaroStatic { /** 停止监听罗盘数据 - * @supported weapp, h5, tt + * @supported weapp, swan, qq, h5, tt * @example * ```tsx * Taro.stopCompass() @@ -69,7 +69,7 @@ declare module '../../index' { stopCompass(option?: stopCompass.Option): Promise /** 开始监听罗盘数据 - * @supported weapp, h5, tt + * @supported weapp, swan, qq, h5, tt * @example * ```js * Taro.startCompass() @@ -79,7 +79,7 @@ declare module '../../index' { startCompass(option?: startCompass.Option): Promise /** 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 Taro.stopCompass 停止监听。 - * @supported weapp, h5, tt + * @supported weapp, swan, qq, h5, tt * @example * ```tsx * Taro.onCompassChange(function (res) { @@ -94,12 +94,12 @@ declare module '../../index' { ): void /** 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。 - * @supported weapp, h5 + * @supported weapp, swan, qq, h5 * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/compass/wx.offCompassChange.html */ offCompassChange( /** 罗盘数据变化事件的回调函数 */ - callback: (...args: any[]) => any, + callback?: onCompassChange.Callback, ): void } } diff --git a/packages/taro/types/api/device/gyroscope.d.ts b/packages/taro/types/api/device/gyroscope.d.ts index 7e6eb8631620..c5fc08ac518e 100644 --- a/packages/taro/types/api/device/gyroscope.d.ts +++ b/packages/taro/types/api/device/gyroscope.d.ts @@ -53,7 +53,7 @@ declare module '../../index' { interface TaroStatic { /** 停止监听陀螺仪数据。 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/gyroscope/wx.stopGyroscope.html */ stopGyroscope(option?: stopGyroscope.Option): Promise @@ -65,7 +65,7 @@ declare module '../../index' { startGyroscope(option: startGyroscope.Option): Promise /** 监听陀螺仪数据变化事件。频率根据 Taro.startGyroscope() 的 interval 参数。可以使用 Taro.stopGyroscope() 停止监听。 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/gyroscope/wx.onGyroscopeChange.html */ onGyroscopeChange( @@ -74,12 +74,12 @@ declare module '../../index' { ): void /** 取消监听陀螺仪数据变化事件。 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, tt, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/gyroscope/wx.offGyroscopeChange.html */ offGyroscopeChange( /** 陀螺仪数据变化事件的回调函数 */ - callback?: (...args: any[]) => any, + callback?: onGyroscopeChange.Callback, ): void } } diff --git a/packages/taro/types/api/device/iBeacon.d.ts b/packages/taro/types/api/device/iBeacon.d.ts index dc4eb77e2a74..b853f11bb72f 100644 --- a/packages/taro/types/api/device/iBeacon.d.ts +++ b/packages/taro/types/api/device/iBeacon.d.ts @@ -20,7 +20,9 @@ declare module '../../index' { complete?: (res: TaroGeneral.IBeaconError) => void /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.IBeaconError) => void - /** 是否校验蓝牙开关,仅在 iOS 下有效 */ + /** 是否校验蓝牙开关,仅在 iOS 下有效 + * @default false + */ ignoreBluetoothAvailable?: boolean /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.IBeaconError) => void @@ -100,7 +102,7 @@ declare module '../../index' { interface TaroStatic { /** 停止搜索附近的 iBeacon 设备 - * @supported weapp + * @supported weapp, alipay * @example * ```tsx * Taro.stopBeaconDiscovery(params).then(...) @@ -110,7 +112,7 @@ declare module '../../index' { stopBeaconDiscovery(option?: stopBeaconDiscovery.Option): Promise /** 开始搜索附近的 iBeacon 设备 - * @supported weapp + * @supported weapp, alipay * @example * ```tsx * Taro.startBeaconDiscovery({ @@ -122,7 +124,7 @@ declare module '../../index' { startBeaconDiscovery(option: startBeaconDiscovery.Option): Promise /** 监听 iBeacon 设备更新事件,仅能注册一个监听 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.onBeaconUpdate.html */ onBeaconUpdate( @@ -131,7 +133,7 @@ declare module '../../index' { ): void /** 监听 iBeacon 服务状态变化事件,仅能注册一个监听 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.onBeaconServiceChange.html */ onBeaconServiceChange( @@ -140,7 +142,7 @@ declare module '../../index' { ): void /** 取消监听 iBeacon 设备更新事件 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.offBeaconUpdate.html */ offBeaconUpdate( @@ -149,7 +151,7 @@ declare module '../../index' { ): void /** 取消监听 iBeacon 服务状态变化事件 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.offBeaconServiceChange.html */ offBeaconServiceChange( @@ -158,7 +160,7 @@ declare module '../../index' { ): void /** 获取所有已搜索到的 iBeacon 设备 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/ibeacon/wx.getBeacons.html */ getBeacons(option?: getBeacons.Option): Promise diff --git a/packages/taro/types/api/device/keyboard.d.ts b/packages/taro/types/api/device/keyboard.d.ts index 07b4ad06bd90..a49f6830adfc 100644 --- a/packages/taro/types/api/device/keyboard.d.ts +++ b/packages/taro/types/api/device/keyboard.d.ts @@ -43,7 +43,7 @@ declare module '../../index' { interface TaroStatic { /** 在input、textarea等focus拉起键盘之后,手动调用此接口收起键盘 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, tt, rn, harmony_hybrid * @example * ```tsx * Taro.hideKeyboard({ @@ -71,7 +71,7 @@ declare module '../../index' { getSelectedTextRange(option?: getSelectedTextRange.Option): Promise /** 监听键盘高度变化 - * @supported weapp, rn + * @supported weapp, swan, jd, qq, rn * @example * ```tsx * Taro.onKeyboardHeightChange(res => { @@ -80,16 +80,18 @@ declare module '../../index' { * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.onKeyboardHeightChange.html */ - onKeyboardHeightChange(callback: onKeyboardHeightChange.Callback): void + onKeyboardHeightChange( + callback: onKeyboardHeightChange.Callback + ): void /** * 取消监听键盘高度变化事件。 - * @supported weapp, rn + * @supported weapp, swan, jd, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/keyboard/wx.offKeyboardHeightChange.html */ offKeyboardHeightChange( /** 键盘高度变化事件的回调函数 */ - callback?: (...args: any[]) => any, + callback?: onKeyboardHeightChange.Callback ): void } } diff --git a/packages/taro/types/api/device/memory.d.ts b/packages/taro/types/api/device/memory.d.ts index 48aa21a18a48..94516403951f 100644 --- a/packages/taro/types/api/device/memory.d.ts +++ b/packages/taro/types/api/device/memory.d.ts @@ -26,7 +26,7 @@ declare module '../../index' { /** 监听内存不足告警事件。 * * 当 iOS/Android 向小程序进程发出内存警告时,触发该事件。触发该事件不意味小程序被杀,大部分情况下仅仅是告警,开发者可在收到通知后回收一些不必要资源避免进一步加剧内存紧张。 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, tt * @example * ```tsx * Taro.onMemoryWarning(function () { @@ -41,13 +41,12 @@ declare module '../../index' { ): void /** 取消监听内存不足告警事件。 - * @supported weapp + * @supported weapp, alipay, swan * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/memory/wx.offMemoryWarning.html */ offMemoryWarning( /** 取消监听内存不足告警事件 */ - callback: onMemoryWarning.Callback, + callback?: onMemoryWarning.Callback, ): void - } } diff --git a/packages/taro/types/api/device/motion.d.ts b/packages/taro/types/api/device/motion.d.ts index 789f8da12ce5..e18e1d5c3633 100644 --- a/packages/taro/types/api/device/motion.d.ts +++ b/packages/taro/types/api/device/motion.d.ts @@ -51,7 +51,7 @@ declare module '../../index' { interface TaroStatic { /** 开始监听设备方向的变化。 - * @supported weapp, h5, rn + * @supported weapp, swan, jd, h5, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.startDeviceMotionListening.html */ startDeviceMotionListening( @@ -60,7 +60,7 @@ declare module '../../index' { /** * 停止监听设备方向的变化。 - * @supported weapp, h5, rn + * @supported weapp, swan, jd, h5, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.stopDeviceMotionListening.html */ stopDeviceMotionListening( @@ -69,18 +69,20 @@ declare module '../../index' { /** * 监听设备方向变化事件。频率根据 Taro.startDeviceMotionListening() 的 interval 参数。可以使用 Taro.stopDeviceMotionListening() 停止监听。 - * @supported weapp, h5, rn + * @supported weapp, alipay, swan, jd, h5, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.onDeviceMotionChange.html */ - onDeviceMotionChange (callback: onDeviceMotionChange.Callback): void + onDeviceMotionChange( + callback: onDeviceMotionChange.Callback + ): void /** 取消监听设备方向变化事件,参数为空,则取消所有的事件监听。 - * @supported weapp, h5, rn + * @supported weapp, alipay, swan, jd, h5, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/motion/wx.offDeviceMotionChange.html */ offDeviceMotionChange( /** 设备方向变化事件的回调函数 */ - callback?: (...args: any[]) => any, + callback?: onDeviceMotionChange.Callback ): void } } diff --git a/packages/taro/types/api/device/network.d.ts b/packages/taro/types/api/device/network.d.ts index be82737b6f08..82fa43b82583 100644 --- a/packages/taro/types/api/device/network.d.ts +++ b/packages/taro/types/api/device/network.d.ts @@ -41,6 +41,10 @@ declare module '../../index' { interface SuccessCallbackResult extends TaroGeneral.CallbackResult { /** 网络类型 */ networkType: keyof NetworkType + /** 信号强弱,单位 dbm */ + signalStrength?: number + /** 设备是否使用了网络代理 */ + hasSystemProxy?: boolean /** 调用结果 */ errMsg: string } @@ -76,6 +80,8 @@ declare module '../../index' { interface SuccessCallbackResult extends TaroGeneral.CallbackResult { /** 本机局域网IP地址 */ localip: string + /** ,基础库 2.24.0 开始支持 */ + netmask?: string /** 调用结果 */ errMsg: string } @@ -83,7 +89,7 @@ declare module '../../index' { interface TaroStatic { /** 监听弱网状态变化事件 - * @supported weapp + * @supported weapp, swan, qq, tt * @example * ```tsx * Taro.onNetworkWeakChange(function (res) { @@ -101,7 +107,7 @@ declare module '../../index' { ): void /** 监听网络状态变化。 - * @supported weapp, h5, rn, tt + * @supported weapp, swan, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.onNetworkStatusChange(function (res) { @@ -117,16 +123,16 @@ declare module '../../index' { ): void /** 取消监听弱网状态变化事件 - * @supported weapp + * @supported weapp, swan * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.offNetworkWeakChange.html */ offNetworkWeakChange( /** 弱网状态变化事件的回调函数 */ - callback: onNetworkWeakChange.Callback, + callback?: onNetworkWeakChange.Callback, ): void /** 取消监听网络状态变化事件,参数为空,则取消所有的事件监听。 - * @supported weapp, h5, rn + * @supported weapp, swan, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/network/wx.offNetworkStatusChange.html */ offNetworkStatusChange( @@ -135,7 +141,7 @@ declare module '../../index' { ): void /** 获取网络类型。 - * @supported weapp, h5, rn, tt + * @supported weapp, swan, qq, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.getNetworkType({ diff --git a/packages/taro/types/api/device/nfc.d.ts b/packages/taro/types/api/device/nfc.d.ts index acea053ccb14..bb58f232b13c 100644 --- a/packages/taro/types/api/device/nfc.d.ts +++ b/packages/taro/types/api/device/nfc.d.ts @@ -187,7 +187,7 @@ declare module '../../index' { namespace transceive { interface Option { /** 需要传递的二进制数据 */ - transceive: ArrayBuffer + data: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.NFCError) => void /** 接口调用失败的回调函数 */ @@ -298,7 +298,7 @@ declare module '../../index' { namespace transceive { interface Option { /** 需要传递的二进制数据 */ - transceive: ArrayBuffer + data: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.NFCError) => void /** 接口调用失败的回调函数 */ @@ -409,7 +409,7 @@ declare module '../../index' { namespace transceive { interface Option { /** 需要传递的二进制数据 */ - transceive: ArrayBuffer + data: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.NFCError) => void /** 接口调用失败的回调函数 */ @@ -521,11 +521,11 @@ declare module '../../index' { namespace writeNdefMessage { interface Option { /** uri 数组 */ - uris: string[] + uris?: string[] /** text 数组 */ - texts: string[] + texts?: string[] /** 二进制对象数组, 需要指明 id, type 以及 payload (均为 ArrayBuffer 类型) */ - records: record[] + records?: record[] /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.NFCError) => void /** 接口调用失败的回调函数 */ @@ -676,7 +676,7 @@ declare module '../../index' { namespace transceive { interface Option { /** 需要传递的二进制数据 */ - transceive: ArrayBuffer + data: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.NFCError) => void /** 接口调用失败的回调函数 */ @@ -741,7 +741,7 @@ declare module '../../index' { */ offDiscovered( /** 监听 NFC Tag的回调函数 */ - callback: NFCAdapter.onDiscovered.Callback, + callback?: NFCAdapter.onDiscovered.Callback, ): void /** 监听 NFC Tag * @supported weapp, tt @@ -778,7 +778,7 @@ declare module '../../index' { /** NFC标签的UID * @supported tt */ - uid?: ArrayBuffer + id?: ArrayBuffer } interface NdefMessage { @@ -906,7 +906,7 @@ declare module '../../index' { namespace transceive { interface Option { /** 需要传递的二进制数据 */ - transceive: ArrayBuffer + data: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.NFCError) => void /** 接口调用失败的回调函数 */ @@ -1017,7 +1017,7 @@ declare module '../../index' { namespace transceive { interface Option { /** 需要传递的二进制数据 */ - transceive: ArrayBuffer + data: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.NFCError) => void /** 接口调用失败的回调函数 */ @@ -1128,7 +1128,7 @@ declare module '../../index' { namespace transceive { interface Option { /** 需要传递的二进制数据 */ - transceive: ArrayBuffer + data: ArrayBuffer /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.NFCError) => void /** 接口调用失败的回调函数 */ @@ -1212,7 +1212,7 @@ declare module '../../index' { */ offHCEMessage( /** 接收 NFC 设备消息事件的回调函数 */ - callback: (...args: any[]) => any, + callback: onHCEMessage.Callback, ): void /** 获取 NFC 实例 diff --git a/packages/taro/types/api/device/phone.d.ts b/packages/taro/types/api/device/phone.d.ts index 846e583036dd..72e268820c1e 100644 --- a/packages/taro/types/api/device/phone.d.ts +++ b/packages/taro/types/api/device/phone.d.ts @@ -16,7 +16,7 @@ declare module '../../index' { interface TaroStatic { /** 拨打电话 - * @supported weapp, h5, rn, tt + * @supported weapp, swan, jd, qq, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.makePhoneCall({ diff --git a/packages/taro/types/api/device/scan.d.ts b/packages/taro/types/api/device/scan.d.ts index 49e55e829c69..ebb77e6a2ab2 100644 --- a/packages/taro/types/api/device/scan.d.ts +++ b/packages/taro/types/api/device/scan.d.ts @@ -7,7 +7,9 @@ declare module '../../index' { complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void - /** 是否只能从相机扫码,不允许从相册选择图片 */ + /** 是否只能从相机扫码,不允许从相册选择图片 + * @default false + */ onlyFromCamera?: boolean /** 扫码类型 */ scanType?: (keyof ScanType)[] @@ -85,7 +87,7 @@ declare module '../../index' { interface TaroStatic { /** * 调起客户端扫码界面,扫码成功后返回对应的结果 - * @supported weapp, h5, rn, tt + * @supported weapp, swan, jd, qq, tt, h5, rn * @example * ```tsx * // 允许从相机和相册扫码 @@ -94,7 +96,7 @@ declare module '../../index' { * console.log(res) * } * }) - * // 只允许从相机扫码 + * // 只允许从相机扫码 * Taro.scanCode({ * onlyFromCamera: true, * success: (res) => { diff --git a/packages/taro/types/api/device/screen.d.ts b/packages/taro/types/api/device/screen.d.ts index 18e66d9263f9..4851daaa0137 100644 --- a/packages/taro/types/api/device/screen.d.ts +++ b/packages/taro/types/api/device/screen.d.ts @@ -77,10 +77,10 @@ declare module '../../index' { success?: (option: SuccessCallbackResult) => void } interface ScreenRecordingState { - /** 开始录屏 */ - start - /** 结束录屏 */ - stop + /** 开启 */ + on + /** 关闭 */ + off } interface SuccessCallbackResult { /** 录屏状态 */ @@ -106,13 +106,13 @@ declare module '../../index' { interface TaroStatic { /** 设置截屏/录屏时屏幕表现,仅支持在 Android 端调用 - * @supported weapp + * @supported weapp, alipay * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.setVisualEffectOnCapture.html */ setVisualEffectOnCapture(option: setVisualEffectOnCapture.Option): Promise /** 设置屏幕亮度。 - * @supported weapp, rn, tt + * @supported weapp, swan, jd, qq, tt, rn * @example * ```tsx * Taro.setScreenBrightness(params).then(...) @@ -123,7 +123,7 @@ declare module '../../index' { /** * 设置是否保持常亮状态。仅在当前小程序生效,离开小程序后设置失效。 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, rn, harmony_hybrid * @example * ```tsx * // 保持屏幕常亮 @@ -137,7 +137,7 @@ declare module '../../index' { /** * 监听用户主动截屏事件,用户使用系统截屏按键截屏时触发此事件 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, tt, harmony_hybrid * @example * ```tsx * Taro.onUserCaptureScreen(function (res) { @@ -154,6 +154,14 @@ declare module '../../index' { /** 监听用户录屏事件 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.onScreenRecordingStateChanged.html + * @example + * ```tsx + * // 监听用户录屏事件 + * const handler = function (res) { + * console.log(res.state) + * } + * Taro.onScreenRecordingStateChanged(handler) + * ``` */ onScreenRecordingStateChanged( /** 用户录屏事件的监听函数 */ @@ -161,7 +169,7 @@ declare module '../../index' { ): void /** 用户主动截屏事件。取消事件监听。 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.offUserCaptureScreen.html */ offUserCaptureScreen( @@ -175,12 +183,20 @@ declare module '../../index' { */ offScreenRecordingStateChanged( /** 用户录屏事件的监听函数 */ - callback: onScreenRecordingStateChanged.Callback + callback?: onScreenRecordingStateChanged.Callback ): void /** 查询用户是否在录屏 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.getScreenRecordingState.html + * @example + * ```tsx + * Taro.getScreenRecordingState({ + * success: function (res) { + * console.log(res.state) + * }, + * }) + * ``` */ getScreenRecordingState( option?: getScreenRecordingState.Option @@ -191,7 +207,7 @@ declare module '../../index' { * * **说明** * - 若安卓系统设置中开启了自动调节亮度功能,则屏幕亮度会根据光线自动调整,该接口仅能获取自动调节亮度之前的值,而非实时的亮度值。 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/screen/wx.getScreenBrightness.html */ getScreenBrightness( diff --git a/packages/taro/types/api/device/sms.d.ts b/packages/taro/types/api/device/sms.d.ts index afda304c7997..9222ab4fd216 100644 --- a/packages/taro/types/api/device/sms.d.ts +++ b/packages/taro/types/api/device/sms.d.ts @@ -18,7 +18,7 @@ declare module '../../index' { interface TaroStatic { /** 拉起手机发送短信界面 - * @supported weap + * @supported weapp, tt * @see declare module '../../index' */ sendSms(option: sendSms.Option): Promise diff --git a/packages/taro/types/api/device/vibrate.d.ts b/packages/taro/types/api/device/vibrate.d.ts index 0c305ba119a6..7e3838b5d3de 100644 --- a/packages/taro/types/api/device/vibrate.d.ts +++ b/packages/taro/types/api/device/vibrate.d.ts @@ -4,7 +4,7 @@ declare module '../../index' { namespace vibrateShort { interface Option { /** 震动强度类型,有效值为:heavy、medium、light */ - type: 'heavy' | 'medium' | 'light' + type?: 'heavy' | 'medium' | 'light' /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -27,9 +27,9 @@ declare module '../../index' { interface TaroStatic { /** 使手机发生较短时间的振动(15 ms)。仅在 iPhone `7 / 7 Plus` 以上及 Android 机型生效 - * @h5 不支持 type 参数 - * @rn 不支持 type 参数 - * @supported weapp, h5, rn, tt + * + * 仅微信小程序平台支持 type 参数 + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn * @example * ```tsx * Taro.vibrateShort(params).then(...) @@ -39,7 +39,7 @@ declare module '../../index' { vibrateShort(option?: vibrateShort.Option): Promise /** 使手机发生较长时间的振动(400ms) - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn * @example * ```tsx * Taro.vibrateLong(params).then(...) diff --git a/packages/taro/types/api/device/wifi.d.ts b/packages/taro/types/api/device/wifi.d.ts index 5b40a0f9d260..0625a1b4429d 100644 --- a/packages/taro/types/api/device/wifi.d.ts +++ b/packages/taro/types/api/device/wifi.d.ts @@ -90,6 +90,10 @@ declare module '../../index' { namespace getConnectedWifi { interface Option { + /** 是否需要返回部分 Wi-Fi 信息 + * @default false + */ + partialInfo?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.WifiError) => void /** 接口调用失败的回调函数 */ @@ -113,6 +117,14 @@ declare module '../../index' { password: string /** Wi-Fi 设备 BSSID */ BSSID?: string + /** 跳转到系统设置页进行连接 + * @default false + */ + maunal?: boolean + /** 是否需要返回部分 Wi-Fi 信息,仅安卓生效 + * @default false + */ + partialInfo?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.WifiError) => void /** 接口调用失败的回调函数 */ @@ -142,7 +154,7 @@ declare module '../../index' { interface TaroStatic { /** 关闭 Wi-Fi 模块。 - * @supported weapp + * @supported weapp, alipay, swan, jd * @example * ```tsx * Taro.stopWifi({ @@ -156,7 +168,7 @@ declare module '../../index' { stopWifi(option?: stopWifi.Option): Promise /** 初始化 Wi-Fi 模块。 - * @supported weapp + * @supported weapp, alipay, swan, jd * @example * ```tsx * Taro.startWifi({ @@ -175,7 +187,7 @@ declare module '../../index' { * - 该接口只能在 `onGetWifiList` 回调之后才能调用。 * - 此时客户端会挂起,等待小程序设置 Wi-Fi 信息,请务必尽快调用该接口,若无数据请传入一个空数组。 * - 有可能随着周边 Wi-Fi 列表的刷新,单个流程内收到多次带有存在重复的 Wi-Fi 列表的回调。 - * @supported weapp + * @supported weapp, swan, jd * @example * ```tsx * Taro.onGetWifiList(function (res) { @@ -209,7 +221,7 @@ declare module '../../index' { ): void /** 监听连接上 Wi-Fi 的事件。 - * @supported weapp + * @supported weapp, alipay, swan, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.onWifiConnected.html */ onWifiConnected( @@ -218,7 +230,7 @@ declare module '../../index' { ): void /** 监听获取到 Wi-Fi 列表数据事件 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.onGetWifiList.html */ onGetWifiList( @@ -232,39 +244,39 @@ declare module '../../index' { */ offWifiConnectedWithPartialInfo( /** 连接上 Wi-Fi 的事件的回调函数 */ - callback: onWifiConnectedWithPartialInfo.Callback, + callback?: onWifiConnectedWithPartialInfo.Callback, ): void /** * 取消监听连接上 Wi-Fi 的事件。 - * @supported weapp + * @supported weapp, alipay, swan, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offWifiConnected.html */ offWifiConnected( /** 连接上 Wi-Fi 的事件的回调函数 */ - callback: onWifiConnected.Callback, + callback?: onWifiConnected.Callback, ): void /** * 取消监听获取到 Wi-Fi 列表数据事件。 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.offGetWifiList.html */ offGetWifiList( /** 获取到 Wi-Fi 列表数据事件的回调函数 */ - callback: onGetWifiList.Callback, + callback?: onGetWifiList.Callback, ): void /** 请求获取 Wi-Fi 列表。在 `onGetWifiList` 注册的回调中返回 `wifiList` 数据。 **Android 调用前需要 [用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.userLocation。** * * iOS 将跳转到系统的 Wi-Fi 界面,Android 不会跳转。 iOS 11.0 及 iOS 11.1 两个版本因系统问题,该方法失效。但在 iOS 11.2 中已修复。 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getWifiList.html */ getWifiList(option?: getWifiList.Option): Promise /** 获取已连接中的 Wi-Fi 信息。 - * @supported weapp + * @supported weapp, alipay, swan, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.getConnectedWifi.html */ getConnectedWifi(option?: getConnectedWifi.Option): Promise @@ -281,7 +293,7 @@ declare module '../../index' { * } * }) * ``` - * @supported weapp + * @supported weapp, alipay, swan, jd * @see https://developers.weixin.qq.com/miniprogram/dev/api/device/wifi/wx.connectWifi.html */ connectWifi(option: connectWifi.Option): Promise diff --git a/packages/taro/types/api/files/index.d.ts b/packages/taro/types/api/files/index.d.ts index 494f82114980..8ab00efa1eb0 100644 --- a/packages/taro/types/api/files/index.d.ts +++ b/packages/taro/types/api/files/index.d.ts @@ -24,6 +24,10 @@ declare module '../../index' { fail?: (result: FailCallbackResult) => void /** 要存储的文件路径 */ filePath?: string + /** 要保存的本地临时文件路径 + * @supported alipay + */ + apFilePath?: string /** 接口调用成功的回调函数 */ success?: (result: SuccessCallbackResult) => void } @@ -120,6 +124,10 @@ declare module '../../index' { createTime: number /** 本地路径 */ filePath: string + /** 文件路径 + * @supported alipay + */ + apFilePath?: string /** 本地文件大小,以字节为单位 */ size: number } @@ -129,6 +137,10 @@ declare module '../../index' { interface Option { /** 文件路径 */ filePath: string + /** 文件路径 + * @supported alipay + */ + apFilePath?: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -150,6 +162,10 @@ declare module '../../index' { interface Option { /** 要读取的文件路径 */ filePath: string + /** 本地文件路径 + * @supported alipay + */ + apFilePath?: string /** * 计算文件摘要的算法 * @default 'md5' @@ -180,17 +196,17 @@ declare module '../../index' { } /** 文件管理器,可通过 [Taro.getFileSystemManager](./getFileSystemManager) 获取。 - * @supported weapp, tt + * @supported weapp, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.html */ interface FileSystemManager { /** 判断文件/目录是否存在 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.access.html */ access(option: FileSystemManager.AccessOption): void /** [FileSystemManager.access](#access) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.accessSync.html */ accessSync( @@ -198,12 +214,12 @@ declare module '../../index' { path: string, ): void /** 在文件结尾追加内容 - * @supported weapp + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFile.html */ appendFile(option: FileSystemManager.AppendFileOption): void /** [FileSystemManager.appendFile](#appendfile) 的同步版本 - * @supported weapp + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.appendFileSync.html */ appendFileSync( @@ -225,12 +241,12 @@ declare module '../../index' { */ closeSync(option: FileSystemManager.CloseSyncOption): void /** 复制文件 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFile.html */ copyFile(option: FileSystemManager.CopyFileOption): void /** [FileSystemManager.copyFile](#copyfile) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.copyFileSync.html */ copyFileSync( @@ -260,22 +276,22 @@ declare module '../../index' { */ ftruncateSync(option: FileSystemManager.FtruncateSyncOption): void /** 获取该小程序下的 `本地临时文件` 或 `本地缓存文件` 信息 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.getFileInfo.html */ getFileInfo(option: FileSystemManager.getFileInfoOption): void /** 获取该小程序下已保存的本地缓存文件列表 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.getSavedFileList.html */ getSavedFileList(option?: FileSystemManager.getSavedFileListOption): void /** 创建目录 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdir.html */ mkdir(option: FileSystemManager.MkdirOption): void /** [FileSystemManager.mkdir](#mkdir) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.mkdirSync.html */ mkdirSync( @@ -310,12 +326,12 @@ declare module '../../index' { */ readCompressedFileSync(option: FileSystemManager.readCompressedFileSync.Option): ArrayBuffer /** 文件读取结果 */ /** 读取目录内文件列表 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdir.html */ readdir(option: FileSystemManager.ReaddirOption): void /** [FileSystemManager.readdir](#readdir) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readdirSync.html */ readdirSync( @@ -323,12 +339,12 @@ declare module '../../index' { dirPath: string, ): string[] /** 读取本地文件内容 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFile.html */ readFile(option: FileSystemManager.ReadFileOption): void /** [FileSystemManager.readFile](#readfile) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.readFileSync.html */ readFileSync( @@ -359,17 +375,17 @@ declare module '../../index' { */ readZipEntry(option: FileSystemManager.readZipEntry.Option): Promise /** 删除该小程序下已保存的本地缓存文件 - * @supported weapp + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.removeSavedFile.html */ removeSavedFile(option: FileSystemManager.RemoveSavedFileOption): void /** 重命名文件。可以把文件从 oldPath 移动到 newPath - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.rename.html */ rename(option: FileSystemManager.RenameOption): void /** [FileSystemManager.rename](#rename) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.renameSync.html */ renameSync( @@ -394,12 +410,12 @@ declare module '../../index' { recursive?: boolean, ): void /** 保存临时文件到本地。此接口会移动临时文件,因此调用成功后,tempFilePath 将不可用。 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFile.html */ saveFile(option: FileSystemManager.SaveFileOption): void /** [FileSystemManager.saveFile](#savefile) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.saveFileSync.html */ saveFileSync( @@ -409,12 +425,12 @@ declare module '../../index' { filePath?: string, ): string /** 获取文件 Stats 对象 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.stat.html */ stat(option: FileSystemManager.StatOption): void /** [FileSystemManager.stat](#stat) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.statSync.html */ statSync( @@ -424,22 +440,22 @@ declare module '../../index' { recursive?: boolean, ): Stats | TaroGeneral.IAnyObject /** 对文件内容进行截断操作 - * @supported weapp + * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncate.html */ truncate(option: FileSystemManager.TruncateOption): void /** 对文件内容进行截断操作 ([truncate](#truncate) 的同步版本) - * @supported weapp + * @supported weapp, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.truncateSync.html */ truncateSync(option: FileSystemManager.TruncateSyncOption): void /** 删除文件 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlink.html */ unlink(option: FileSystemManager.UnlinkOption): void /** [FileSystemManager.unlink](#unlink) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unlinkSync.html */ unlinkSync( @@ -447,7 +463,7 @@ declare module '../../index' { filePath: string, ): void /** 解压文件 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.unzip.html */ unzip(option: FileSystemManager.UnzipOption): void @@ -457,12 +473,12 @@ declare module '../../index' { */ write(option: FileSystemManager.WriteOption): void /** 写文件 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFile.html */ writeFile(option: FileSystemManager.WriteFileOption): void /** [FileSystemManager.writeFile](#writefile) 的同步版本 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/FileSystemManager.writeFileSync.html */ writeFileSync( @@ -543,10 +559,10 @@ declare module '../../index' { data: string | ArrayBuffer /** 要追加内容的文件路径 */ filePath: string - /** 接口调用结束的回调函数(调用成功、失败都会执行) */ - complete?: (res: TaroGeneral.CallbackResult) => void /** 指定写入文件的字符编码 */ encoding?: keyof FileSystemManager.Encoding + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (result: AppendFileFailCallbackResult) => void /** 接口调用成功的回调函数 */ @@ -590,6 +606,11 @@ declare module '../../index' { interface getFileInfoOption { /** 要读取的文件路径 */ filePath: string + /** + * 计算文件摘要的算法 + * @default 'md5' + */ + digestAlgorithm?: 'md5' | 'sha1' /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -608,6 +629,8 @@ declare module '../../index' { interface GetFileInfoSuccessCallbackResult extends TaroGeneral.CallbackResult { /** 文件大小,以字节为单位 */ size: number + /** 按照传入的 digestAlgorithm 计算得出的的文件摘要 */ + digest?: string /** 调用结果 */ errMsg: string } @@ -640,12 +663,15 @@ declare module '../../index' { interface MkdirOption { /** 创建的目录路径 */ dirPath: string + /** 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。 + * 如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 + * @default false + */ + recursive?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (result: MkdirFailCallbackResult) => void - /** 是否在递归创建该目录的上级目录后再创建该目录。如果对应的上级目录已经存在,则不创建该上级目录。如 dirPath 为 a/b/c/d 且 recursive 为 true,将创建 a 目录,再在 a 目录下创建 b 目录,以此类推直至创建 a/b/c 目录下的 d 目录。 */ - recursive?: boolean /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.CallbackResult) => void } @@ -789,6 +815,10 @@ declare module '../../index' { interface RemoveSavedFileOption { /** 需要删除的文件路径 */ filePath: string + /** 本地缓存文件路径 + * @supported alipay + */ + apFilePath?: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -1286,12 +1316,12 @@ declare module '../../index' { /** 文件最后一次被修改的时间,UNIX 时间戳,对应 POSIX stat.st_mtime */ lastModifiedTime: number /** 判断当前文件是否一个目录 - * @supported weapp + * @supported weapp, alipay, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.isDirectory.html */ isDirectory(): boolean /** 判断当前文件是否一个普通文件 - * @supported weapp + * @supported weapp, aliapy, jd, qq, tt * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/Stats.isFile.html */ isFile(): boolean @@ -1308,7 +1338,7 @@ declare module '../../index' { interface TaroStatic { /** 保存文件系统的文件到用户磁盘,仅在 PC 端支持 - * @supported weapp + * @supported weapp, alipay * @example * ```tsx * Taro.saveFileToDisk({ @@ -1326,7 +1356,7 @@ declare module '../../index' { saveFileToDisk(option: saveFileToDisk.Option): Promise /** 保存文件到本地。**注意:saveFile 会把临时文件移动,因此调用成功后传入的 tempFilePath 将不可用** - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, rn * @example * ```tsx * Taro.chooseImage({ @@ -1367,9 +1397,9 @@ declare module '../../index' { removeSavedFile(option: removeSavedFile.Option): Promise /** 新开页面打开文档,支持格式 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt * @example - ```tsx + * ```tsx * Taro.downloadFile({ * url: 'https://example.com/somefile.pdf', * success: function (res) { @@ -1388,7 +1418,7 @@ declare module '../../index' { openDocument(option: openDocument.Option): Promise /** 获取本地已保存的文件列表 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, rn * @example * ```tsx * Taro.getSavedFileList({ @@ -1402,7 +1432,7 @@ declare module '../../index' { getSavedFileList(option?: getSavedFileList.Option): Promise /** 获取本地文件的文件信息。此接口只能用于获取已保存到本地的文件,若需要获取临时文件信息,请使用 [Taro.getFileInfo](/docs/apis/files/getFileInfo) 接口。 - * @supported weapp, rn + * @supported weapp, alipay, swan, jd, qq, rn * @example * ```tsx * Taro.getSavedFileInfo({ @@ -1419,7 +1449,7 @@ declare module '../../index' { /** * 获取该小程序下的 本地临时文件 或 本地缓存文件 信息 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, rn * @example * ```tsx * Taro.getFileInfo({ @@ -1434,7 +1464,7 @@ declare module '../../index' { getFileInfo(option: getFileInfo.Option): Promise /** 获取全局唯一的文件管理器 - * @supported weapp, tt + * @supported weapp, alipay, swan, jd, qq, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/file/wx.getFileSystemManager.html */ getFileSystemManager(): FileSystemManager diff --git a/packages/taro/types/api/framework/index.d.ts b/packages/taro/types/api/framework/index.d.ts index 64e7c430843d..f16e37a3ee41 100644 --- a/packages/taro/types/api/framework/index.d.ts +++ b/packages/taro/types/api/framework/index.d.ts @@ -33,7 +33,7 @@ declare module '../../index' { * __注意:__ * - __不要尝试修改页面栈,会导致路由以及页面状态错误。__ * - 不要在 `App.onLaunch` 的时候调用 `getCurrentPages()`,此时 `page` 还没有生成。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.getCurrentPages().length @@ -43,7 +43,7 @@ declare module '../../index' { getCurrentPages(): Page[] /** 获取到小程序全局唯一的 App 实例。 - * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp + * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/reference/api/getApp.html */ getApp(opts?: getApp.Option): getApp.Instance diff --git a/packages/taro/types/api/location/index.d.ts b/packages/taro/types/api/location/index.d.ts index 82816c3f807c..9be76e5ab502 100644 --- a/packages/taro/types/api/location/index.d.ts +++ b/packages/taro/types/api/location/index.d.ts @@ -7,16 +7,23 @@ declare module '../../index' { latitude: number /** 经度,范围为-180~180,负数表示西经。使用 gcj02 国测局坐标系 */ longitude: number + /** 缩放比例 + * @weapp 范围 5~18,默认值18 + * @alipay 范围 3~19,默认值15 + */ + scale?: number + /** 位置名 */ + name?: string /** 地址的详细说明 */ address?: string + /** 定义在拉起的地图 App 面板中需要被屏蔽的地图类 App + * @supported swan + */ + ignoredApps?: Array /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void - /** 位置名 */ - name?: string - /** 缩放比例,范围5~18 */ - scale?: number /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.CallbackResult) => void } @@ -24,20 +31,32 @@ declare module '../../index' { namespace getLocation { interface Option { - /** 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 */ - altitude?: string + /** 传入 true 会返回高度信息,由于获取高度需要较高精确度,会减慢接口返回速度 + * @default false + */ + altitude?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void /** 高精度定位超时时间(ms),指定时间内返回最高精度,该值3000ms以上高精度定位才有效果 */ highAccuracyExpireTime?: number - /** 开启高精度定位 */ + /** 开启高精度定位 + * @default false + */ isHighAccuracy?: boolean /** 接口调用成功的回调函数 */ success?: (result: SuccessCallbackResult) => void - /** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 */ + /** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 + * @default "wgs84" + */ type?: string + /** 针对 iOS14/Android12 及以上的新特性,其他情况本参数忽略。默认情况宿主是精确定位就返回精确定位信息。 + * 传入 true 会强制使用精确定位信息,iOS14/Android12 及以上如果没有精确定位权限,会弹出精确定位授权弹框 + * @supported swan + * @default false + */ + needFullAccuracy?: boolean } interface SuccessCallbackResult extends TaroGeneral.CallbackResult { /** 位置的精确度 */ @@ -54,6 +73,42 @@ declare module '../../index' { speed: number /** 垂直精度,单位 m(Android 无法获取,返回 0) */ verticalAccuracy: number + /** 城市名称 + * @supported swan + */ + street?: string + /** 国家代码 + * @supported swan + */ + cityCode?: string + /** 城市名称 + * @supported swan, tt + */ + city?: string + /** 国家 + * @supported swan + */ + country?: string + /** 国家代码 + * @supported swan + */ + countryCode?: string + /** 省份 + * @supported swan + */ + province?: string + /** 街道号码 + * @supported swan + */ + streetNumber?: string + /** 区 + * @supported swan + */ + district?: string + /** 是不是精确定位信息 + * @supported swan + */ + isFullAccuracy?: boolean /** 调用结果 */ errMsg: string } @@ -97,6 +152,12 @@ declare module '../../index' { * @see https://lbs.qq.com/webApi/component/componentGuide/componentPicker */ mapOpts?: Record + /** 页面显示标题 + * @supported alipay + * @alipay 安卓默认值为 位置,iOS、IDE 默认值为 你在哪里? + * @see https://opendocs.alipay.com/mini/api/location?pathHash=951b46a1 + */ + title?: string /** 接口调用成功的回调函数 */ success?: (result: SuccessCallbackResult) => void /** 接口调用失败的回调函数 */ @@ -114,6 +175,30 @@ declare module '../../index' { longitude: number /** 位置名称 */ name: string + /** 区县代码 + * @supported alipay + */ + adCode?: number + /** 区县名称 + * @supported alipay + */ + adName?: string + /** 城市代码 + * @supported alipay + */ + cityCode?: string + /** 城市名称 + * @supported alipay + */ + cityName?: string + /** 省份代码 + * @supported alipay + */ + provinceCode?: number + /** 省份名称 + * @supported alipay + */ + provinceName?: string /** 调用结果 */ errMsg: string } @@ -132,6 +217,10 @@ declare module '../../index' { namespace startLocationUpdateBackground { interface Option { + /** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 + * @default "gcj02" + */ + type?: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -143,6 +232,16 @@ declare module '../../index' { namespace startLocationUpdate { interface Option { + /** wgs84 返回 gps 坐标,gcj02 返回可用于 wx.openLocation 的坐标 + * @default "gcj02" + */ + type?: string + /** 针对 iOS14/Android12 及以上的新特性,其他情况本参数忽略。默认情况宿主是精确定位就返回精确定位信息。 + * 传入 true 会强制使用精确定位信息,iOS14/Android12 及以上如果没有精确定位权限,会弹出精确定位授权弹框 + * @supported swan + * @default false + */ + needFullAccuracy?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -161,6 +260,11 @@ declare module '../../index' { interface CallbackResult { /** 错误码 */ errCode: number + /** 错误信息 + * @supported tt + * @tt 最低支持版本 2.48.0 + */ + errMsg?: string } } @@ -185,13 +289,50 @@ declare module '../../index' { speed: number /** 垂直精度,单位 m(Android 无法获取,返回 0) */ verticalAccuracy: number + /** 街道名称 + * @supported swan + */ + street?: string + /** 城市编码 + * @supported swan + */ + cityCode?: string + /** 城市名称 + * @supported swan, tt + * @tt iOS 不支持 + */ + city?: string + /** 国家 + * @supported swan + */ + country?: string + /** 国家代码 + * @supported swan + */ + countryCode?: string + /** 省份 + * @supported swan + */ + province?: string + /** 街道号码 + * @supported swan + */ + streetNumber?: string + /** 区 + * @supported swan + */ + district?: string + /** 是不是精确定位信息 + * @supported swan + */ + isFullAccuracy?: boolean } } namespace getFuzzyLocation { interface Option { /** wgs84 返回 gps 坐标,gcj02 返回可用于 Taro.openLocation 的坐标 */ - type?: 'wgs84' | 'gcj02' + type?: keyof Type /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -200,6 +341,13 @@ declare module '../../index' { success?: (result: SuccessCallbackResult) => void } + interface Type { + /** 返回 gps 坐标 */ + wgs84 + /** 返回 gcj02 坐标*/ + gcj02 + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { /** 纬度,范围为 -90~90,负数表示南纬 */ latitude: number @@ -210,7 +358,7 @@ declare module '../../index' { interface TaroStatic { /** 关闭监听实时位置变化,前后台都停止消息接收 - * @supported weapp, rn, tt + * @supported weapp, swan, tt, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.stopLocationUpdate.html */ stopLocationUpdate(option?: stopLocationUpdate.Option): void @@ -232,13 +380,13 @@ declare module '../../index' { * * **注意** * - 获取位置信息需配置[地理位置用途说明](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#permission)。 - * @supported weapp, rn, tt + * @supported weapp, swan, tt, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.startLocationUpdate.html */ startLocationUpdate(option?: startLocationUpdate.Option): void /** 使用微信内置地图查看位置 - * @supported weapp, h5, tt + * @supported weapp, alipay, swan, jd, tt, h5, harmony_hybrid * @example * ```tsx * Taro.getLocation({ @@ -268,7 +416,7 @@ declare module '../../index' { ): void /** 监听实时地理位置变化事件,需结合 Taro.startLocationUpdateBackground、Taro.startLocationUpdate 使用。 - * @supported weapp, rn, tt + * @supported weapp, swan, tt, rn * @example * ```tsx * const _locationChangeFn = function (res) { @@ -290,16 +438,16 @@ declare module '../../index' { */ offLocationChangeError( /** 监听持续定位接口返回失败时触发的回调函数 */ - callback: onLocationChangeError.Callback, + callback?: onLocationChangeError.Callback, ): void /** 取消监听实时地理位置变化事件 - * @supported weapp, rn, tt + * @supported weapp, swan, tt, rn * @see https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.offLocationChange.html */ offLocationChange( /** 实时地理位置变化事件的回调函数 */ - callback: (res: TaroGeneral.CallbackResult) => void, + callback?: onLocationChange.Callback, ): void /** 获取当前的地理位置、速度。当用户离开小程序后,此接口无法调用。开启高精度定位,接口耗时会增加,可指定 highAccuracyExpireTime 作为超时时间。 @@ -307,7 +455,7 @@ declare module '../../index' { * **注意** * - 工具中定位模拟使用IP定位,可能会有一定误差。且工具目前仅支持 gcj02 坐标。 * - 使用第三方服务进行逆地址解析时,请确认第三方服务默认的坐标系,正确进行坐标转换。 - * @supported weapp, rn, tt + * @supported weapp, swan, jd, qq, tt, rn, harmony_hybrid * @example * ```tsx * Taro.getLocation({ @@ -333,7 +481,7 @@ declare module '../../index' { /** 打开地图选择位置。 * * `chooseLocation` api功能是依赖于腾讯位置服务,所以需要使用 api 密钥。如果您没有,可以前往腾讯位置服务[开发者控制台](https://lbs.qq.com/console/mykey.html?console=mykey)进行申请。 - * @supported weapp, h5, tt + * @supported weapp, alipay, swan, jd, tt, h5, harmony_hybrid * @example * ```tsx * // config/index.js @@ -351,7 +499,7 @@ declare module '../../index' { chooseLocation(option: chooseLocation.Option): Promise /** 获取当前的模糊地理位置 - * @supported weapp + * @supported weapp, harmony_hybrid * @example * ```tsx * Taro.getFuzzyLocation({ diff --git a/packages/taro/types/api/media/audio.d.ts b/packages/taro/types/api/media/audio.d.ts index 1f3ff4543954..0d8eedcac9f0 100644 --- a/packages/taro/types/api/media/audio.d.ts +++ b/packages/taro/types/api/media/audio.d.ts @@ -160,17 +160,17 @@ declare module '../../index' { /** `AudioContext` 实例,可通过 `Taro.createAudioContext` 获取。 * * `AudioContext` 通过 `id` 跟一个 `audio` 组件绑定,操作对应的 audio 组件。 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.html */ interface AudioContext { /** 暂停音频。 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.pause.html */ pause(): void /** 播放音频。 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/AudioContext.play.html */ play(): void @@ -270,7 +270,7 @@ declare module '../../index' { /** origin: 发送完整的 referrer; no-referrer: 不发送 */ referrerPolicy?: 'origin' | 'no-referrer' | string /** 播放 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ play(): void /** 暂停 @@ -278,7 +278,7 @@ declare module '../../index' { */ pause(): void /** 停止 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ stop(): void /** 跳转到指定位置,单位 s @@ -294,7 +294,7 @@ declare module '../../index' { */ onCanplay(callback?: InnerAudioContext.OnCanplayCallback): void /** 音频播放事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onPlay(callback?: InnerAudioContext.OnPlayCallback): void /** 音频暂停事件 @@ -302,11 +302,11 @@ declare module '../../index' { */ onPause(callback?: InnerAudioContext.OnPauseCallback): void /** 音频停止事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onStop(callback?: InnerAudioContext.OnStopCallback): void /** 音频自然播放结束事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onEnded(callback?: InnerAudioContext.OnEndedCallback): void /** 音频播放进度更新事件 @@ -314,7 +314,7 @@ declare module '../../index' { */ onTimeUpdate(callback?: InnerAudioContext.OnTimeUpdateCallback): void /** 音频播放错误事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ onError(callback?: InnerAudioContext.OnErrorCallback): void /** 音频加载中事件,当音频因为数据不足,需要停下来加载时会触发 @@ -800,6 +800,15 @@ declare module '../../index' { setPosition(...args: any[]): void } + namespace createInnerAudioContext { + interface Option { + /** 是否使用 WebAudio 作为底层音频驱动,默认关闭。对于短音频、播放频繁的音频建议开启此选项,开启后将获得更优的性能表现。由于开启此选项后也会带来一定的内存增长,因此对于长音频建议关闭此选项。 + * @supported weapp + */ + useWebAudioImplement: boolean + } + } + interface TaroStatic { /** 结束播放语音。 * **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](./createInnerAudioContext) 接口** @@ -963,7 +972,7 @@ declare module '../../index' { createMediaAudioPlayer(): MediaAudioPlayer /** 创建内部 audio 上下文 InnerAudioContext 对象。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * const innerAudioContext = Taro.createInnerAudioContext() @@ -979,11 +988,11 @@ declare module '../../index' { * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/audio/wx.createInnerAudioContext.html */ - createInnerAudioContext(): InnerAudioContext + createInnerAudioContext(option?: createInnerAudioContext.Option): InnerAudioContext /** 创建 audio 上下文 AudioContext 对象。 * **注意:1.6.0 版本开始,本接口不再维护。建议使用能力更强的 [Taro.createInnerAudioContext](./createInnerAudioContext) 接口** - * @supported weapp + * @supported weapp, harmony_hybrid * @example * ```tsx * const audioCtx = Taro.createAudioContext('myAudio') diff --git a/packages/taro/types/api/media/background-audio.d.ts b/packages/taro/types/api/media/background-audio.d.ts index b97567bf920a..5367ce0ac41d 100644 --- a/packages/taro/types/api/media/background-audio.d.ts +++ b/packages/taro/types/api/media/background-audio.d.ts @@ -274,7 +274,7 @@ declare module '../../index' { * 小程序切入后台,如果音频处于播放状态,可以继续播放。但是后台状态不能通过调用API操纵音频的播放状态。 * * 从微信客户端6.7.2版本开始,若需要在小程序切后台后继续播放音频,需要在 [app.json](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html) 中配置 `requiredBackgroundModes` 属性。开发版和体验版上可以直接生效,正式版还需通过审核。 - * @supported weapp, tt + * @supported weapp, tt, harmony_hybrid * @example * ```tsx * const backgroundAudioManager = Taro.getBackgroundAudioManager() diff --git a/packages/taro/types/api/media/camera.d.ts b/packages/taro/types/api/media/camera.d.ts index 26fb6bea9f0e..e292f0d7c8d0 100644 --- a/packages/taro/types/api/media/camera.d.ts +++ b/packages/taro/types/api/media/camera.d.ts @@ -90,15 +90,15 @@ declare module '../../index' { * @supported alipay */ height: string - /** 视频文件的宽度。 + /** 视频文件的宽度。 * @supported alipay */ width: string - /** 视频文件的尺寸。 + /** 视频文件的尺寸。 * @supported alipay */ size: string - /** 录制的持续时间。 + /** 录制的持续时间。 * @supported alipay */ duration: string @@ -152,6 +152,8 @@ declare module '../../index' { normal /** 低质量 */ low + /** 原图 */ + original } } @@ -192,6 +194,7 @@ declare module '../../index' { interface TaroStatic { /** 创建 camera 上下文 CameraContext 对象。 + * @alipay 支付宝小程序需指定 camera 组件中的 id 属性 * @supported weapp, rn, tt, alipay * @example * ```tsx diff --git a/packages/taro/types/api/media/image.d.ts b/packages/taro/types/api/media/image.d.ts index f24c0f189bec..2727569f398d 100644 --- a/packages/taro/types/api/media/image.d.ts +++ b/packages/taro/types/api/media/image.d.ts @@ -324,7 +324,7 @@ declare module '../../index' { interface TaroStatic { /** 保存图片到系统相册。需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.writePhotosAlbum - * @supported weapp, alipay, swan, tt, h5, rn + * @supported weapp, alipay, swan, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.saveImageToPhotosAlbum({ @@ -348,7 +348,7 @@ declare module '../../index' { previewMedia(option: previewMedia.Option): Promise /** 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。 - * @supported weapp, alipay, swan, tt, h5, rn + * @supported weapp, alipay, swan, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.previewImage({ @@ -361,7 +361,7 @@ declare module '../../index' { previewImage(option: previewImage.Option): Promise /** 获取图片信息。网络图片需先配置download域名才能生效。 - * @supported weapp, alipay, swan, tt, h5, rn + * @supported weapp, alipay, swan, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.getImageInfo({ @@ -421,7 +421,7 @@ declare module '../../index' { * type: 'image', * success: function (res) { * // tempFilePath可以作为img标签的src属性显示图片 - * const tempFilePaths = res.tempFilePaths + * const tempFilePaths = res.tempFiles * } * }) * ``` @@ -431,7 +431,7 @@ declare module '../../index' { /** * 从本地相册选择图片或使用相机拍照。 - * @supported weapp, alipay, swan, tt, h5, rn + * @supported weapp, alipay, swan, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.chooseImage({ diff --git a/packages/taro/types/api/media/video.d.ts b/packages/taro/types/api/media/video.d.ts index b1f92b73be99..fbf13418c9a4 100644 --- a/packages/taro/types/api/media/video.d.ts +++ b/packages/taro/types/api/media/video.d.ts @@ -89,7 +89,7 @@ declare module '../../index' { /** VideoContext 实例,可通过 [Taro.createVideoContext](./createVideoContext) 获取。 * * VideoContext 通过 id 跟一个 video 组件绑定,操作对应的 video 组件。 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.html */ interface VideoContext { @@ -99,7 +99,7 @@ declare module '../../index' { */ exitBackgroundPlayback(): void /** 退出全屏 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.exitFullScreen.html */ exitFullScreen(): void @@ -114,17 +114,17 @@ declare module '../../index' { */ hideStatusBar(): void /** 暂停视频 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.pause.html */ pause(): void /** 播放视频 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.play.html */ play(): void /** 设置倍速播放 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.playbackRate.html */ playbackRate( @@ -137,12 +137,12 @@ declare module '../../index' { */ requestBackgroundPlayback(): void /** 进入全屏 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.requestFullScreen.html */ requestFullScreen(option: VideoContext.RequestFullScreenOption): void /** 跳转到指定位置 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.seek.html */ seek( @@ -163,7 +163,7 @@ declare module '../../index' { */ showStatusBar(): void /** 停止视频 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/media/video/VideoContext.stop.html */ stop(): void @@ -414,7 +414,7 @@ declare module '../../index' { openVideoEditor(option: openVideoEditor.Option): Promise /** 获取视频详细信息 - * @supported weapp + * @supported weapp, harmony_hybrid * @example * ```tsx * Taro.downloadFile({ @@ -442,7 +442,7 @@ declare module '../../index' { getVideoInfo(option: getVideoInfo.Option): Promise /** 创建 video 上下文 VideoContext 对象。 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @example * ```tsx * videoContext = Taro.createVideoContext('myVideo') @@ -505,7 +505,7 @@ declare module '../../index' { chooseVideo(option: chooseVideo.Option): Promise /** 拍摄或从手机相册中选择图片或视频。 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @example * ```tsx * Taro.chooseMedia({ diff --git a/packages/taro/types/api/navigate/index.d.ts b/packages/taro/types/api/navigate/index.d.ts index ebbd6fb5bfca..d1a7d89c110c 100644 --- a/packages/taro/types/api/navigate/index.d.ts +++ b/packages/taro/types/api/navigate/index.d.ts @@ -17,6 +17,8 @@ declare module '../../index' { verify?: keyof Verify /** 不 reLaunch 目标小程序,直接打开目标跳转的小程序退后台时的页面,需满足以下条件:1. 目标跳转的小程序生命周期未被销毁;2. 且目标当次启动的path、query、apiCategory与上次启动相同。默认值为 false 。 */ noRelaunchIfPathUnchanged?: boolean + /** 打开的小程序是否支持全屏 */ + allowFullScreen?: boolean /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -239,7 +241,7 @@ declare module '../../index' { * **关于调试** * - 在开发者工具上调用此 API 并不会真实的跳转到另外的小程序,但是开发者工具会校验本次调用跳转是否成功。[详情](https://developers.weixin.qq.com/miniprogram/dev/devtools/different.html#跳转小程序调试支持) * - 开发者工具上支持被跳转的小程序处理接收参数的调试。[详情](https://developers.weixin.qq.com/miniprogram/dev/devtools/different.html#跳转小程序调试支持) - * @supported weapp, tt + * @supported weapp, tt, harmony_hybrid * @example * ```tsx * Taro.navigateToMiniProgram({ diff --git a/packages/taro/types/api/network/download.d.ts b/packages/taro/types/api/network/download.d.ts index c36360c37a90..1fbd846ee5be 100644 --- a/packages/taro/types/api/network/download.d.ts +++ b/packages/taro/types/api/network/download.d.ts @@ -85,7 +85,7 @@ declare module '../../index' { } /** 一个可以监听下载进度变化事件,以及取消下载任务的对象 - * @supported weapp, swan, alipay, h5, rn, tt + * @supported weapp, swan, alipay, h5, rn, tt, harmony_hybrid * @example * ```tsx * const downloadTask = Taro.downloadFile({ @@ -109,12 +109,12 @@ declare module '../../index' { */ interface DownloadTask { /** 中断下载任务 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.abort.html */ abort(): void /** 监听下载进度变化事件 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.onProgressUpdate.html */ onProgressUpdate( @@ -122,7 +122,7 @@ declare module '../../index' { callback: DownloadTask.OnProgressUpdateCallback, ): void /** 取消监听下载进度变化事件 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/download/DownloadTask.offProgressUpdate.html */ offProgressUpdate( @@ -151,7 +151,7 @@ declare module '../../index' { /** 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径,单次下载允许的最大文件为 50MB。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。 * * 注意:请在服务端响应的 header 中指定合理的 `Content-Type` 字段,以保证客户端正确处理文件类型。 - * @supported weapp, h5, alipay, swan, rn, tt + * @supported weapp, h5, alipay, swan, rn, tt, harmony_hybrid * @example * ```tsx * Taro.downloadFile({ diff --git a/packages/taro/types/api/network/request.d.ts b/packages/taro/types/api/network/request.d.ts index 5fe0f3aae7bb..416a73fba41c 100644 --- a/packages/taro/types/api/network/request.d.ts +++ b/packages/taro/types/api/network/request.d.ts @@ -13,8 +13,8 @@ declare module '../../index' { */ header?: TaroGeneral.IAnyObject /** 超时时间,单位为毫秒 - * @default 2000 - * @supported weapp, h5, tt, alipay + * @default 60000 + * @supported weapp, h5, tt, alipay, rn */ timeout?: number /** HTTP 请求方法 @@ -262,7 +262,7 @@ declare module '../../index' { } /** 网络请求任务对象 - * @supported weapp, h5, rn, alipay, swan, tt, qq + * @supported weapp, h5, rn, alipay, swan, tt, qq, harmony_hybrid * @example * 回调函数(Callback)用法: * @@ -316,12 +316,12 @@ declare module '../../index' { */ interface RequestTask extends Promise> { /** 中断请求任务 - * @supported weapp, tt + * @supported weapp, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/request/RequestTask.abort.html */ abort(): void /** 监听 HTTP Response Header 事件。会比请求完成事件更早 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/request/RequestTask.onHeadersReceived.html */ onHeadersReceived( @@ -329,7 +329,7 @@ declare module '../../index' { callback: RequestTask.onHeadersReceived.Callback ): void /** 取消监听 HTTP Response Header 事件 - * @supported weapp + * @supported weapp, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/request/RequestTask.offHeadersReceived.html */ offHeadersReceived( @@ -400,7 +400,7 @@ declare module '../../index' { * - 对于 `GET` 方法的数据,会将数据转换成 query string(`encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...`) * - 对于 `POST` 方法且 `header['content-type']` 为 `application/json` 的数据,会对数据进行 JSON 序列化 * - 对于 `POST` 方法且 `header['content-type']` 为 `application/x-www-form-urlencoded` 的数据,会将数据转换成 query string `(encodeURIComponent(k)=encodeURIComponent(v)&encodeURIComponent(k)=encodeURIComponent(v)...)` - * @supported weapp, h5, rn, alipay, swan, tt, qq + * @supported weapp, h5, rn, alipay, swan, tt, qq, harmony_hybrid * @example * ```tsx * Taro.request({ diff --git a/packages/taro/types/api/network/upload.d.ts b/packages/taro/types/api/network/upload.d.ts index f1143923b9c1..4fa7167d7cd6 100644 --- a/packages/taro/types/api/network/upload.d.ts +++ b/packages/taro/types/api/network/upload.d.ts @@ -84,7 +84,7 @@ declare module '../../index' { } /** 一个可以监听上传进度变化事件,以及取消上传任务的对象 - * @supported weapp, swan, alipay, h5, rn, tt + * @supported weapp, swan, alipay, h5, rn, tt, harmony_hybrid * @example * ```tsx * const uploadTask = Taro.uploadFile({ @@ -112,12 +112,12 @@ declare module '../../index' { */ interface UploadTask { /** 中断上传任务 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.abort.html */ abort(): void /** 监听上传进度变化事件 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.onProgressUpdate.html */ onProgressUpdate( @@ -125,7 +125,7 @@ declare module '../../index' { callback: UploadTask.OnProgressUpdateCallback, ): void /** 取消监听上传进度变化事件 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.offProgressUpdate.html */ offProgressUpdate( @@ -133,7 +133,7 @@ declare module '../../index' { callback: UploadTask.OnProgressUpdateCallback, ): void /** 监听 HTTP Response Header 事件。会比请求完成事件更早 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.onHeadersReceived.html */ onHeadersReceived( @@ -141,7 +141,7 @@ declare module '../../index' { callback: UploadTask.OnHeadersReceivedCallback, ): void /** 取消监听 HTTP Response Header 事件 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/upload/UploadTask.offHeadersReceived.html */ offHeadersReceived( @@ -152,7 +152,7 @@ declare module '../../index' { interface TaroStatic { /** 将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 `content-type` 为 `multipart/form-data`。使用前请注意阅读[相关说明](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。 - * @supported weapp, swan, alipay, h5, rn, tt + * @supported weapp, swan, alipay, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.chooseImage({ diff --git a/packages/taro/types/api/network/websocket.d.ts b/packages/taro/types/api/network/websocket.d.ts index e88bd4e03240..ea0a146749c5 100644 --- a/packages/taro/types/api/network/websocket.d.ts +++ b/packages/taro/types/api/network/websocket.d.ts @@ -138,22 +138,22 @@ declare module '../../index' { } /** WebSocket 任务,可通过 [Taro.connectSocket()](/docs/apis/network/websocket/SocketTask) 接口创建返回。 - * @supported weapp, h5, rn, alipay, swan + * @supported weapp, h5, rn, alipay, swan, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.html */ interface SocketTask { /** 通过 WebSocket 连接发送数据 - * @supported weapp, h5, rn, alipay, swan, tt + * @supported weapp, h5, rn, alipay, swan, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.send.html */ send(option: SocketTask.SendOption): void /** 关闭 WebSocket 连接 - * @supported weapp, h5, rn, alipay, swan, tt + * @supported weapp, h5, rn, alipay, swan, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.close.html */ close(option: SocketTask.CloseOption): void /** 监听 WebSocket 连接打开事件 - * @supported weapp, h5, rn, alipay, swan, tt + * @supported weapp, h5, rn, alipay, swan, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onOpen.html */ onOpen( @@ -161,7 +161,7 @@ declare module '../../index' { callback: SocketTask.OnOpenCallback ): void /** 监听 WebSocket 连接关闭事件 - * @supported weapp, h5, rn, alipay, swan, tt + * @supported weapp, h5, rn, alipay, swan, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onClose.html */ onClose( @@ -169,7 +169,7 @@ declare module '../../index' { callback: SocketTask.OnCloseCallback ): void /** 监听 WebSocket 错误事件 - * @supported weapp, h5, rn, alipay, swan, tt + * @supported weapp, h5, rn, alipay, swan, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onError.html */ onError( @@ -177,7 +177,7 @@ declare module '../../index' { callback: SocketTask.OnErrorCallback ): void /** 监听 WebSocket 接受到服务器的消息事件 - * @supported weapp, h5, rn, alipay, swan, tt + * @supported weapp, h5, rn, alipay, swan, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/websocket/SocketTask.onMessage.html */ onMessage( @@ -320,7 +320,7 @@ declare module '../../index' { * **并发数** * - 1.7.0 及以上版本,最多可以同时存在 5 个 WebSocket 连接。 * - 1.7.0 以下版本,一个小程序同时只能有一个 WebSocket 连接,如果当前已存在一个 WebSocket 连接,会自动关闭该连接,并重新创建一个 WebSocket 连接。 - * @supported weapp, h5, rn, alipay, swan + * @supported weapp, h5, rn, alipay, swan, harmony_hybrid * @example * ```tsx * Taro.connectSocket({ diff --git a/packages/taro/types/api/open-api/account.d.ts b/packages/taro/types/api/open-api/account.d.ts index a09d5e82eec0..fa0be248ff5e 100644 --- a/packages/taro/types/api/open-api/account.d.ts +++ b/packages/taro/types/api/open-api/account.d.ts @@ -35,7 +35,7 @@ declare module '../../index' { interface TaroStatic { /** 获取当前帐号信息 - * @supported weapp + * @supported weapp, alipay, qq * @example * ```tsx * const accountInfo = Taro.getAccountInfoSync(); diff --git a/packages/taro/types/api/open-api/address.d.ts b/packages/taro/types/api/open-api/address.d.ts index 804cce8840a6..312da39cca75 100644 --- a/packages/taro/types/api/open-api/address.d.ts +++ b/packages/taro/types/api/open-api/address.d.ts @@ -14,7 +14,9 @@ declare module '../../index' { interface SuccessCallbackResult extends TaroGeneral.CallbackResult { /** 收货人姓名 */ userName: string - /** 邮编 */ + /** 邮编 + * @supported weapp, qq + */ postalCode: string /** 国标收货地址第一级地址 */ provinceName: string @@ -22,13 +24,19 @@ declare module '../../index' { cityName: string /** 国标收货地址第三级地址 */ countyName: string - /** 国标收货地址第四级地址 */ + /** 国标收货地址第四级地址 + * @supported weapp, qq + */ streetName: string /** 详细收货地址信息 */ detailInfo: string - /** 新选择器详细收货地址信息 */ + /** 新选择器详细收货地址信息 + * @supported weapp, qq + */ detailInfoNew: string - /** 收货地址国家码 */ + /** 收货地址国家码 + * @supported weapp, qq + */ nationalCode: string /** 收货人手机号码 */ telNumber: string @@ -37,7 +45,7 @@ declare module '../../index' { interface TaroStatic { /** 获取用户收货地址。调起用户编辑收货地址原生界面,并在编辑完成后返回用户选择的地址。 - * @supported weapp, tt + * @supported weapp, qq, tt, jd * @example * ```tsx * Taro.chooseAddress({ diff --git a/packages/taro/types/api/open-api/authorize.d.ts b/packages/taro/types/api/open-api/authorize.d.ts index 3c846953c85f..271427182db7 100644 --- a/packages/taro/types/api/open-api/authorize.d.ts +++ b/packages/taro/types/api/open-api/authorize.d.ts @@ -55,7 +55,7 @@ declare module '../../index' { authorizeForMiniProgram(option: authorizeForMiniProgram.Option): Promise /** 提前向用户发起授权请求。调用后会立刻弹窗询问用户是否同意授权小程序使用某项功能或获取用户的某些数据,但不会实际调用对应接口。如果用户之前已经同意授权,则不会出现弹窗,直接返回成功。更多用法详见 [用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html)。 - * @supported weapp, rn, tt + * @supported weapp, swan, qq, tt, rn * @example * ```tsx * // 可以通过 Taro.getSetting 先查询一下用户是否授权了 "scope.record" 这个 scope diff --git a/packages/taro/types/api/open-api/channels.d.ts b/packages/taro/types/api/open-api/channels.d.ts index 03db01e8d80e..650391a06d28 100644 --- a/packages/taro/types/api/open-api/channels.d.ts +++ b/packages/taro/types/api/open-api/channels.d.ts @@ -118,6 +118,8 @@ declare module '../../index' { nickname: string /** 是否可预约 */ reservable: boolean + /** 除最近的一条预告信息外,其他的预告信息列表(注意:每次最多返回按时间戳增序排列的15个预告信息,其中时间最近的那个预告信息会在接口其他的返回参数中展示,其余的预告信息会在该字段中展示)。 */ + otherInfos?: string[] } interface Status { /** 可用 */ @@ -154,6 +156,10 @@ declare module '../../index' { headUrl: string /** 视频号昵称 */ nickname: string + /** 直播回放状态 */ + replayStatus: keyof ReplayStatus | number + /** 除最近的一条直播外,其他的直播列表(注意:每次最多返回按时间戳增序排列的15个直播信息,其中时间最近的那个直播会在接口其他的返回参数中展示,其余的直播会在该字段中展示)。 */ + otherInfos?: string[] } interface Status { /** 直播中 */ @@ -161,6 +167,16 @@ declare module '../../index' { /** 直播结束 */ 3 } + interface ReplayStatus { + /** 未生成 */ + 0 + /** 已生成 */ + 1 + /** 生成中 */ + 3 + /** 已过期 */ + 6 + } } interface TaroStatic { diff --git a/packages/taro/types/api/open-api/device-voip.d.ts b/packages/taro/types/api/open-api/device-voip.d.ts index 316bd09edacf..9585abdd1552 100644 --- a/packages/taro/types/api/open-api/device-voip.d.ts +++ b/packages/taro/types/api/open-api/device-voip.d.ts @@ -50,12 +50,52 @@ declare module '../../index' { interface TaroStatic { /** 请求用户授权与设备(组)间进行音视频通话 + * @example + * ```tsx + * // 授权单台设备 + * Taro.requestDeviceVoIP({ + * sn: 'xxxx', + * snTicket: 'xxxxx', + * modelId: 'xxx', + * deviceName: 'xxx', + * success(res) { + * console.log(res) + * }, + * fail(res) { + * console.log(res) + * } + * }) + * + * // 批量授权(授权设备组) + * Taro.requestDeviceVoIP({ + * isGroup: true, + * groupId: '设备组 ID', + * success(res) { + * console.log(res) + * }, + * fail(res) { + * console.log(res) + * } + * }) + * ``` + * * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/device-voip/wx.requestDeviceVoIP.html */ requestDeviceVoIP(option: requestDeviceVoIP.Option): Promise /** 查询当前用户授权的音视频通话设备(组)信息 * @supported weapp + * @example + * ```tsx + * Taro.getDeviceVoIPList({ + * success(res) { + * console.log(res) + * }, + * fail(res) { + * console.log(res) + * } + * }) + * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/device-voip/wx.getDeviceVoIPList.html */ getDeviceVoIPList(option: getDeviceVoIPList.Option): Promise diff --git a/packages/taro/types/api/open-api/invoice.d.ts b/packages/taro/types/api/open-api/invoice.d.ts index 407ce67ccafd..8f8fe47a003b 100644 --- a/packages/taro/types/api/open-api/invoice.d.ts +++ b/packages/taro/types/api/open-api/invoice.d.ts @@ -75,7 +75,7 @@ declare module '../../index' { * 其中 `access_token` 的获取请参考[auth.getAccessToken](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/access-token/auth.getAccessToken.html)文档 * @supported weapp * @example - ```tsx + * ```tsx * Taro.chooseInvoice({ * success: function (res) {} * }) diff --git a/packages/taro/types/api/open-api/login.d.ts b/packages/taro/types/api/open-api/login.d.ts index bf788834ff44..ef9eca8030ff 100644 --- a/packages/taro/types/api/open-api/login.d.ts +++ b/packages/taro/types/api/open-api/login.d.ts @@ -26,12 +26,25 @@ declare module '../../index' { success?: (result: SuccessCallbackResult) => void /** 超时时间,单位ms */ timeout?: number + /** 未登录时, 是否强制调起登录框 + * @supported tt + * @default true + */ + force?: boolean } interface SuccessCallbackResult extends TaroGeneral.CallbackResult { /** 用户登录凭证(有效期五分钟)。开发者需要在开发者服务器后台调用 [auth.code2Session](https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/login/auth.code2Session.html),使用 code 换取 openid 和 session_key 等信息 */ code: string /** 调用结果 */ errMsg: string + /** 用于标识当前设备, 无论登录与否都会返回, 有效期 5 分钟。 + * @supported tt + */ + anonymousCode?: string + /** 判断在当前 APP(头条、抖音等)是否处于登录状态。 + * @supported tt + */ + isLogin?: boolean } } @@ -54,7 +67,7 @@ declare module '../../index' { pluginLogin(option?: pluginLogin.Option): Promise /** 调用接口获取登录凭证(code)。通过凭证进而换取用户登录态信息,包括用户的唯一标识(openid)及本次登录的会话密钥(session_key)等。用户数据的加解密通讯需要依赖会话密钥完成。更多使用方法详见 [小程序登录](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html)。 - * @supported weapp + * @supported weapp, jd, qq, tt, harmony_hybrid * @example * ```tsx * Taro.login({ @@ -81,8 +94,8 @@ declare module '../../index' { * * 通过 Taro.login 接口获得的用户登录态拥有一定的时效性。用户越久未使用小程序,用户登录态越有可能失效。反之如果用户一直在使用小程序,则用户登录态一直保持有效。具体时效逻辑由微信维护,对开发者透明。开发者只需要调用 Taro.checkSession 接口检测当前用户登录态是否有效。 * - * 登录态过期后开发者可以再调用 Taro.login 获取新的用户登录态。调用成功说明当前 session_key 未过期,调用失败说明 session_key 已过期。更多使用方法详见 [小程序登录](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html)。 - * @supported weapp + * 登录态过期后开发者可以再调用 Taro.login 获取新的用户登录态。调用 Taro.checkSession 成功说明当前 session_key 未过期,调用失败说明 session_key 已过期。更多使用方法详见 [小程序登录](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/login.html)。 + * @supported weapp, swan, qq, tt * @example * ```tsx * Taro.checkSession({ diff --git a/packages/taro/types/api/open-api/privacy.d.ts b/packages/taro/types/api/open-api/privacy.d.ts index ee0883dc6d14..34442922ed58 100644 --- a/packages/taro/types/api/open-api/privacy.d.ts +++ b/packages/taro/types/api/open-api/privacy.d.ts @@ -80,6 +80,14 @@ declare module '../../index' { /** * 跳转至隐私协议页面。隐私合规开发指南详情可见《小程序隐私协议开发指南》 * @supported weapp + * @example + * ```tsx + * Taro.openPrivacyContract({ + * success: () => {}, // 打开成功 + * fail: () => {}, // 打开失败 + * complete: () => {} + * }) + * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/privacy/wx.openPrivacyContract.html */ openPrivacyContract(option?: openPrivacyContract.Option): void diff --git a/packages/taro/types/api/open-api/settings.d.ts b/packages/taro/types/api/open-api/settings.d.ts index f4f2bad441c5..83672d1e9531 100644 --- a/packages/taro/types/api/open-api/settings.d.ts +++ b/packages/taro/types/api/open-api/settings.d.ts @@ -5,6 +5,7 @@ declare module '../../index' { interface Option { /** * 是否同时获取用户订阅消息的订阅状态,默认不获取。注意:withSubscriptions 只返回用户勾选过订阅面板中的“总是保持以上选择,不再询问”的订阅消息。 + * @default false */ withSubscriptions?: boolean /** 接口调用结束的回调函数(调用成功、失败都会执行) */ @@ -135,7 +136,7 @@ declare module '../../index' { /** 调起客户端小程序设置界面,返回用户设置的操作结果。**设置界面只会出现小程序已经向用户请求过的[权限](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html)**。 * * 注意:[2.3.0](https://developers.weixin.qq.com/miniprogram/dev/framework/compatibility.html) 版本开始,用户发生点击行为后,才可以跳转打开设置页,管理授权信息。[详情](https://developers.weixin.qq.com/community/develop/doc/000cea2305cc5047af5733de751008) - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, rn, harmony_hybrid * @example * ```tsx * Taro.openSetting({ @@ -153,7 +154,7 @@ declare module '../../index' { openSetting(option?: openSetting.Option): Promise /** 获取用户的当前设置。**返回值中只会出现小程序已经向用户请求过的[权限](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html)**。 - * @supported weapp, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, rn, harmony_hybrid * @example * ```tsx * Taro.getSetting({ diff --git a/packages/taro/types/api/open-api/sticker.d.ts b/packages/taro/types/api/open-api/sticker.d.ts new file mode 100644 index 000000000000..904448bffec1 --- /dev/null +++ b/packages/taro/types/api/open-api/sticker.d.ts @@ -0,0 +1,83 @@ +import Taro from '../../index' + +declare module '../../index' { + namespace openStickerSetView { + interface Option { + /** 表情专辑链接,可前往[表情开放平台](https://sticker.weixin.qq.com/cgi-bin/mmemoticonwebnode-bin/pages/home),在详情页中的「小程序跳转链接」入口复制 */ + url: Object + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + + namespace openStickerIPView { + interface Option { + /** 表情IP合辑链接,可前往[表情开放平台](https://sticker.weixin.qq.com/cgi-bin/mmemoticonwebnode-bin/pages/home),在详情页中的「小程序跳转链接」入口复制 */ + url: Object + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + + namespace openSingleStickerView { + interface Option { + /** 表情链接,可前往(表情开放平台)[https://sticker.weixin.qq.com/cgi-bin/mmemoticonwebnode-bin/pages/home],在详情页中的「小程序跳转链接」入口复制 */ + url: Object + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + + interface TaroStatic { + /** 打开表情专辑 + * @supported weapp + * @example + * ```tsx + * Taro.openStickerSetView({ + * url: '', + * success(res) {} + * }) + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sticker/wx.openStickerSetView.html + */ + openStickerSetView(option: openStickerSetView.Option): void + + /** 打开表情IP合辑 + * @supported weapp + * @example + * ```tsx + * Taro.openStickerIPView({ + * url: '', + * success(res) {} + * }) + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sticker/wx.openStickerIPView.html + */ + openStickerIPView(option: openStickerIPView.Option): void + + /** 打开单个表情 + * @supported weapp + * @example + * ```tsx + * Taro.openSingleStickerView({ + * url: '', + * success(res) {} + * }) + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/open-api/sticker/wx.openSingleStickerView.html + */ + openSingleStickerView(option: openSingleStickerView.Option): void + } +} \ No newline at end of file diff --git a/packages/taro/types/api/open-api/subscribe-message.d.ts b/packages/taro/types/api/open-api/subscribe-message.d.ts index a0db045e480a..a168306a7f76 100644 --- a/packages/taro/types/api/open-api/subscribe-message.d.ts +++ b/packages/taro/types/api/open-api/subscribe-message.d.ts @@ -3,8 +3,19 @@ import Taro from '../../index' declare module '../../index' { namespace requestSubscribeMessage { interface Option { - /** 需要订阅的消息模板的id的集合(注意:iOS客户端7.0.6版本、Android客户端7.0.7版本之后的一次性订阅/长期订阅才支持多个模板消息,iOS客户端7.0.5版本、Android客户端7.0.6版本之前的一次订阅只支持一个模板消息)消息模板id在[微信公众平台(mp.weixin.qq.com)-功能-订阅消息]中配置 */ + /** + * 需要订阅的消息模板的id的集合(注意:iOS客户端7.0.6版本、Android客户端7.0.7版本之后的一次性订阅/长期订阅才支持多个模板消息,iOS客户端7.0.5版本、Android客户端7.0.6版本之前的一次订阅只支持一个模板消息)消息模板id在[微信公众平台(mp.weixin.qq.com)-功能-订阅消息]中配置 + * @supported weapp, tt + */ tmplIds: string[] + /** 需要订阅的消息模板 id 集合(注意:1、一次性模板 id 和长期性模板 id 不可同时使用,2、一次最多传入三个模板 id + * @supported alipay + */ + entityIds: string[] + /** 模板小程序 appId,仅在服务商代调用场景下需要传入 + * @supported alipay + */ + thirdTypeAppId?: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ @@ -37,20 +48,90 @@ declare module '../../index' { * @type "accept" | "reject" | "ban" */ [TEMPLATE_ID: string]: keyof TemplateReflex | string + /** 用户订阅操作结果。 + * + * | 枚举值 | 描述 | + * | --- | ---- | + * | subscribe | 订阅成功 | + * + * @supported alipay + */ + behavior?: string + /** 一次性订阅,是否勾选 总是保持以上选择,不再询问。 + * + * | 枚举值 | 描述 | + * | --- | ---- | + * | true | 勾选 | + * | false | 未勾选 | + * + * @supported alipay + */ + keep?: boolean + /** 长期性订阅,是否点击 拒绝,不再询问。 + * + * | 枚举值 | 描述 | + * | --- | ---- | + * | true | 点击 | + * | false | 未点击 | + * + * @supported alipay + */ + refuse?: boolean + /** 订阅数据 + * @supported alipay + */ + result?: ISubscribeResult + /** 本次订阅过程是否弹出了订阅面板。 + * + * | 枚举值 | 描述 | + * | --- | ---- | + * | true | 弹出 | + * | false | 未弹出 | + * + * @supported alipay + */ + show?: boolean /** 接口调用成功时errMsg值为'requestSubscribeMessage:ok' */ errMsg: string } + interface ISubscribeResult { + /** 订阅成功的模板列表 */ + subscribeEntityIds: string[] + /** 最终订阅成功的模板列表 */ + subscribedEntityIds: string[] + /** 未订阅的模板列表 */ + unsubscribedEntityIds: string[] + /** 本次新增订阅成功的模板列表 */ + currentSubscribedEntityIds: string[] + } + /** 模版消息订阅类型 */ interface TemplateReflex { - /** 表示用户同意订阅该条id对应的模板消息 */ + /** + * 表示用户同意订阅该条id对应的模板消息 + * @supported weapp, alipay, tt + */ accept - /** 表示用户拒绝订阅该条id对应的模板消息 */ + /** + * 表示用户拒绝订阅该条id对应的模板消息 + * @supported weapp, alipay, tt + */ reject - /** 表示已被后台封禁 */ + /** + * 表示已被后台封禁 + * @supported weapp, tt + */ ban - /** 表示该模板因为模板标题同名被后台过滤 */ + /** + * 表示该模板因为模板标题同名被后台过滤 + * @supported weapp + */ filter + /** 表示该条 id 对应的模版消息授权失败 + * @supported tt + */ + fail } } @@ -114,6 +195,19 @@ declare module '../../index' { } } + namespace unsubscribeMessage { + interface Option { + /** 需要取消订阅的消息模板 id 集合(注意:1、一次性模板 id 和长期性模板 id 不可同时使用,2、一次最多传入三个模板 id)。 */ + entityIds: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + interface TaroStatic { /** 请求订阅消息 * @@ -133,7 +227,7 @@ declare module '../../index' { ): Promise /** 订阅设备消息接口,调用后弹出授权框,用户同意后会允许开发者给用户发送订阅模版消息。当用户点击“允许”按钮时,模板消息会被添加到用户的小程序设置页,通过 wx.getSetting 接口可获取用户对相关模板消息的订阅状态。 - * @supported weapp, tt + * @supported weapp * @example * ```tsx * Taro.requestSubscribeDeviceMessage({ @@ -154,5 +248,53 @@ declare module '../../index' { requestSubscribeDeviceMessage( option: requestSubscribeDeviceMessage.Option ): Promise + + /** 取消当前用户已订阅的消息 + * @supported alipay + * @example + * ```tsx + * Taro.unsubscribeMessage({ + * entityIds: [ + * 'ac768fca1ce245ccae9404bb5243c49b', + * '9aa357acb7c6434aba294aded1cdfb7c', + * ], + * success(res) { + * console.log(res); + * }, + * fail(err) { + * console.log(err); + * } + * }) + * ``` + * @see https://opendocs.alipay.com/mini/07vg26?pathHash=8c9630ac + */ + unsubscribeMessage(option: unsubscribeMessage.Option): void + + /** 小程序消息订阅服务,包括取消订阅和查询订阅;订阅操作详见 [form 表单](https://smartprogram.baidu.com/docs/develop/component/formlist_form/)。 + * @supported swan + * @example + * ```tsx + * Taro.subscribeService({ + * templateId: 'BD0003', + * subscribeId: '8026', + * type: 'query', + * success(res) { + * Taro.showModal({ + * title: 'success', + * content: JSON.stringify(res) + * }) + * }, + * fail(err) { + * Taro.showModal({ + * title: 'fail', + * content: JSON.stringify(err) + * }) + * } + * }) + * ``` + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-subscribeService/ + */ + subscribeService(option: subscribeService.Option): void + } } diff --git a/packages/taro/types/api/open-api/user-info.d.ts b/packages/taro/types/api/open-api/user-info.d.ts index e1d50a10f239..ad47f3bd0c09 100644 --- a/packages/taro/types/api/open-api/user-info.d.ts +++ b/packages/taro/types/api/open-api/user-info.d.ts @@ -39,6 +39,11 @@ declare module '../../index' { lang?: keyof UserInfo.Language /** 声明获取用户个人信息后的用途,不超过30个字符 */ desc: string + /** 当宿主未登录时,是否强制拉起登录框 + * @supported tt + * @default false + */ + force?: boolean /** 接口调用成功的回调函数 */ success?: (result: SuccessCallbackResult) => void /** 接口调用失败的回调函数 */ @@ -102,7 +107,7 @@ declare module '../../index' { * * **接口调整说明** * 在用户未授权过的情况下调用此接口,将不再出现授权弹窗,会直接进入 fail 回调(详见[《公告》](https://developers.weixin.qq.com/community/develop/doc/0000a26e1aca6012e896a517556c01))。在用户已授权的情况下调用此接口,可成功获取用户信息。 - * @supported weapp, tt + * @supported weapp, jd, qq, tt, harmony_hybrid * @example * ```tsx * // 必须是在用户已经授权的情况下调用 diff --git a/packages/taro/types/api/qq/index.d.ts b/packages/taro/types/api/qq/index.d.ts index 361c8b350cbe..05cfec3ee635 100644 --- a/packages/taro/types/api/qq/index.d.ts +++ b/packages/taro/types/api/qq/index.d.ts @@ -21,9 +21,148 @@ declare module '../../index' { type MediaType = 'photo' | 'video' } + namespace getQQRunData { + interface Option { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (result: SuccessCallbackResult) => void + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** + * 包括敏感数据在内的完整用户信息的加密数据,详细见加密数据解密算法。 + */ + encryptedData: string + /** + * 加密算法的初始向量,详细见加密数据解密算法 + */ + iv: string + } + } + + namespace setOfficialDress { + interface Option { + /** 方法名,设置头像填"setAvatar",其他方法后续开放 */ + action: string + /** openid,给自己设置头像填"self" */ + uin: string + /** 物品id */ + item_id?: string + /** 设置头像"setAvatar"此处不用填 */ + busi_info?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + + namespace setCustomDress { + interface Option { + /** 方法名,设置头像填"uploadAvatar",其他方法后续开放 */ + action: string + /** 素材路径,必须为本地文件,路径为 wxfile:// 的形式 */ + path: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + + namespace updateQQApp { + interface Option { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + + namespace addRecentColorSign { + interface Option { + /** + * 做为点击最近彩签打开的小程序页面的启动参数,如 a=1&b=2 + * 默认值:当前页面的查询参数 + */ + query?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + + namespace getGuildInfo { + interface Option { + /** 频道id */ + open_guild_id: string + /** 子频道Id */ + channel_id?: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 加密之后的数据,需要解密 */ + encryptedData: string + /** 对称解密算法初始向量(base64) */ + iv: string + /** 签名(base64) */ + signature: string + } + } + + namespace applyAddToMyApps { + interface Option { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + } + interface SuccessCallbackResult { + /** true 代表用户选择了同意 */ + confirm: boolean + /** true 代表用户选择了不同意 */ + cancel: boolean + } + } + + namespace isAddedToMyApps { + interface Option { + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** true 代表用户已经添加,false 则还没添加 */ + isAdded: boolean + } + } + interface TaroStatic { /** * 此接口可打开手Q说说发表界面,并将文字内容和图片/视频内容传递到手Q说说发表界面。 + * @supported qq + * @example * ```tsx * Taro.openQzonePublish({ * footnote: '使用同款滤镜', @@ -41,9 +180,175 @@ declare module '../../index' { * ] * }) * ``` - * @supported qq * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_openQzonePublish.html */ openQzonePublish(option: openQzonePublish.Option): void + /** + * 获取用户过去三十天QQ运动步数。需要先调用 qq.login 接口。步数信息会在用户主动进入小程序时更新。 + * @supported qq + * @example + * ```tsx + * Taro.getQQRunData({ + * success(res) { + * // 拿 encryptedData 到开发者后台解密开放数据 + * const encryptedData = res.encryptedData + * } + * }) + * ``` + * + * **开放数据 JSON 结构** + * 敏感数据有两种获取方式,一是使用 加密数据解密算法 。 获取得到的开放数据为以下 json 结构: + * + * ```json + * { + * "stepInfoList": [ + * { + * "timestamp": 1445866601, + * "step": 100 + * }, + * { + * "timestamp": 1445876601, + * "step": 120 + * } + * ] + * } + * ``` + * * stepInfoList 中,每一项结构如下: + * + * | 属性 | 类型 | 说明 | + * | --- | ---- | --- | + * | timestamp | number | 时间戳,表示数据对应的时间 | + * | step | number | QQ运动步数 | + * + * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_sport.html + */ + getQQRunData(option: getQQRunData.Option): void + /** + * QQ美化平台内测阶段,仅被邀请的商户可使用此接口。 + * @supported qq + * @example + * ```tsx + * Taro.setOfficialDress({ + * action: "setAvatar", + * uin: "self", + * item_id: "2740", + * success(res) { + * console.log("success"+res); + * }, + * fail(res) { + * console.log("fail"+res); + * } + * }) + * ``` + * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/personalize.html#qq-setofficialdress + */ + setOfficialDress(option: setOfficialDress.Option): void + /** + * QQ美化平台内测阶段,仅被邀请的商户可使用此接口。 + * @supported qq + * @example + * ```tsx + * Taro.setCustomDress({ + * action: "uploadAvatar", + * path:"wxfile://images/1.png" + * success(res) { + * console.log("success"+res); + * }, + * fail(res) { + * console.log("fail"+res); + * } + * }) + * ``` + * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/personalize.html#qq-setcustomdress + */ + setCustomDress(option: setCustomDress.Option): void + /** + * 更新 QQ 版本 + * @supported qq + * @example + * ```tsx + * Taro.updateQQApp({ + * success: function(res) { + * console.log('updateQQApp success',res) + * }, + * fail: function(err) { + * console.log('updateQQApp fail',err) + * }, + * complete: function(res) { + * console.log('updateQQApp info',res) + * } + * }) + * ``` + * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_updateQQ.html#qq-updateqqapp + */ + updateQQApp(option: updateQQApp.Option): void + /** + * 添加当前小程序页面到最近浏览彩签,需要授权基础库 1.20.0 开始支持。 + * 提示:在手 Q 8.9.0 前的版本,当系统未授予手 Q 悬浮穿权限时,每次调用该接口都会弹出系统授权窗口。自手 Q 8.9.0 起交互调整如下: + * 1. 系统没有授予手 Q 悬浮窗权限时,接口执行 fail 回调函数并附带 ”No floating window permission“的错误信息,开发者可针对此信息在业务代码里弹窗提示用户手动授予手 Q 悬浮窗权限。 + * 2. 安卓系统部分机型存在获取悬浮窗权限不准确情况。 + * @supported qq + * @example + * ```tsx + * Taro.addRecentColorSign({ + * query: 'a=1&b=2', + * success(res) { + * console.log('addRecentColorSign success: ', res) + * }, + * fail(err) { + * console.log('addRecentColorSign fail: ', err) + * }, + * complete(res) { + * console.log('addRecentColorSign complete: ', res) + * } + * }) + * ``` + * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addColorSign.html#qq-addrecentcolorsign + */ + addRecentColorSign(option: addRecentColorSign.Option): void + /** + * 获取频道信息与当前人身份(FOR 机器人服务入口) + * @supported qq + * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_guild.html + */ + getGuildInfo(option: getGuildInfo.Option): void + /** + * 申请用户将本小程序添加到下拉页面中“我的小程序”当中,手Q8.9.13及以上版本支持 + * @supported qq + * @example + * ```tsx + * Taro.applyAddToMyApps({ + * success(res) { + * if (res.confirm) { + * // 用户同意添加 + * } + * if (res.cancel) { + * // 用户不同意添加 + * } + * // 原则上,confirm和cancel是互斥的 + * } + * }) + * ``` + * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addToMyApps.html#qq-applyaddtomyapps + */ + applyAddToMyApps(option: applyAddToMyApps.Option): void + /** + * 查询用户是否已经将本小程序添加到下拉页面中“我的小程序”当中,手Q8.9.13及以上版本支持,建议使用qq.applyAddToMyApps之前先调用qq.isAddedToMyApps来作前置判断 + * @supported qq + * @example + * ```tsx + * Taro.isAddedToMyApps({ + * success(res) { + * if (res.isAdded) { + * // 用户已经添加 + * } else { + * // 用户还未添加 + * } + * } + * }) + * ``` + * @see https://q.qq.com/wiki/develop/miniprogram/API/open_port/port_addToMyApps.html#qq-isaddedtomyapps + */ + isAddedToMyApps(option: isAddedToMyApps.Option): void } } diff --git a/packages/taro/types/api/route/index.d.ts b/packages/taro/types/api/route/index.d.ts index 1c783a1cd46b..5d908282c434 100644 --- a/packages/taro/types/api/route/index.d.ts +++ b/packages/taro/types/api/route/index.d.ts @@ -117,7 +117,7 @@ declare module '../../index' { interface TaroStatic { /** 跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```json * { @@ -143,7 +143,7 @@ declare module '../../index' { switchTab(option: switchTab.Option): Promise /** 关闭所有页面,打开到应用内的某个页面 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.reLaunch({ @@ -155,7 +155,7 @@ declare module '../../index' { reLaunch(option: reLaunch.Option): Promise /** 关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @h5 未针对 tabbar 页面做限制处理 * @example * ```tsx @@ -168,7 +168,7 @@ declare module '../../index' { redirectTo(option: redirectTo.Option): Promise /** 保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 Taro.navigateBack 可以返回到原页面。小程序中页面栈最多十层。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @h5 未针对 tabbar 页面做限制处理 * @example * ```tsx @@ -195,7 +195,7 @@ declare module '../../index' { navigateTo(option: navigateTo.Option): Promise /** 关闭当前页面,返回上一页面或多级页面。可通过 getCurrentPages 获取当前的页面栈,决定需要返回几层。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @h5 若入参 delta 大于现有页面数时,返回应用打开的第一个页面(如果想要返回首页请使用 reLaunch 方法)。 * @example * ```tsx diff --git a/packages/taro/types/api/skyline/index.d.ts b/packages/taro/types/api/skyline/index.d.ts new file mode 100644 index 000000000000..d6a5700e6d76 --- /dev/null +++ b/packages/taro/types/api/skyline/index.d.ts @@ -0,0 +1,59 @@ +import Taro from '../../index' + +declare module '../../index' { + /** + * Snapshot 实例,可通过 SelectorQuery 获取。 + * + * Snapshot 通过 id 跟一个 snapshot 组件绑定,操作对应的 snapshot 组件。 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/skyline/Snapshot.html + */ + interface Snapshot { + /** + * 画布宽度 + */ + width: number + /** + * 画布高度 + */ + height: number + /** + * 对 snapshot 组件子树进行截图 + * @param option + * @see https://developers.weixin.qq.com/miniprogram/dev/api/skyline/Snapshot.takeSnapshot.html + */ + takeSnapshot(option: Snapshot.TakeSnapshot.Option): Promise + } + + namespace Snapshot { + namespace TakeSnapshot { + interface Option { + /** + * 截图导出类型,'file' 保存到临时文件目录或 'arraybuffer' 返回图片二进制数据,默认值为 'file' + */ + type: string + /** + * 截图文件格式,'rgba' 或 'png',默认值为 'png' + */ + format: string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + } + + interface SuccessCallbackResult { + /** + * 截图保存的临时文件路径,当 type 为 file 该字段生效 + */ + tempFilePath: string + /** + * 截图对应的二进制数据,当 type 为 arraybuffer 该字段生效 + */ + data: string + } + } + } +} diff --git a/packages/taro/types/api/storage/background-fetch.d.ts b/packages/taro/types/api/storage/background-fetch.d.ts index 0dcacf4208ed..0b01f871e775 100644 --- a/packages/taro/types/api/storage/background-fetch.d.ts +++ b/packages/taro/types/api/storage/background-fetch.d.ts @@ -25,6 +25,25 @@ declare module '../../index' { /** 接口调用成功的回调函数 */ success?: (res: TaroGeneral.CallbackResult) => void } + + type Callback = ( + result: CallbackResult, + ) => void + + interface CallbackResult { + /** 缓存数据类别,取值为 periodic 或 pre */ + fetchType: string + /** 缓存数据 */ + fetchedData: string + /** 客户端拿到缓存数据的时间戳 */ + timeStamp: number + /** 小程序页面路径 */ + path: string + /** 传给页面的 query 参数 */ + query: string + /** 进入小程序的场景值 */ + scene: number + } } namespace getBackgroundFetchToken { @@ -34,46 +53,79 @@ declare module '../../index' { /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void /** 接口调用成功的回调函数 */ - success?: (res: TaroGeneral.CallbackResult) => void + success?: (res: SuccessCallbackResult) => void + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 自定义的登录态 */ + token: string + /** 接口调用结果 */ + errMsg: string } } namespace getBackgroundFetchData { interface Option { - /** 取值为 periodic */ + /** 缓存数据类别 + * @weapp 取值为 periodic + * @qq 取值为 periodic + * @alipay 取值为 pre: 数据预拉取; jsapiPre: API 预调用(目前仅支持地理位置预拉取) + */ fetchType: string /** 接口调用结束的回调函数(调用成功、失败都会执行) */ complete?: (res: TaroGeneral.CallbackResult) => void /** 接口调用失败的回调函数 */ fail?: (res: TaroGeneral.CallbackResult) => void /** 接口调用成功的回调函数 */ - success?: (res: TaroGeneral.CallbackResult) => void + success?: (res: SuccessCallbackResult) => void + } + + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 缓存数据 + * @alipay Object + */ + fetchedData: string | Object + /** 客户端拿到缓存数据的时间戳 ms。(iOS 时间戳存在异常,8.0.27 修复) */ + timeStamp: number + /** 小程序页面路径 */ + path: string + /** 传给页面的 query 参数 */ + query: string + /** 进入小程序的场景值 */ + scene: number + /** 缓存数据类型,与入参 fetchType 一致 + * @supported alipay + */ + fetchType?: string + /** 缓存数据的时间戳。单位:ms。 + * @supported alipay + */ + timestamp?: number } } interface TaroStatic { /** 设置自定义登录态,在周期性拉取数据时带上,便于第三方服务器验证请求合法性 - * @supported weapp + * @supported weapp, qq * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.setBackgroundFetchToken.html */ - setBackgroundFetchToken(option: setBackgroundFetchToken.Option): void + setBackgroundFetchToken(option: setBackgroundFetchToken.Option): Promise /** 收到 backgroundFetch 数据时的回调 - * @supported weapp + * @supported weapp, qq * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.onBackgroundFetchData.html */ - onBackgroundFetchData(option?: onBackgroundFetchData.Option): void + onBackgroundFetchData(option?: onBackgroundFetchData.Option | onBackgroundFetchData.Callback): void /** 获取设置过的自定义登录态。若无,则返回 fail。 - * @supported weapp + * @supported weapp, qq * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchToken.html */ - getBackgroundFetchToken(option?: getBackgroundFetchToken.Option): void + getBackgroundFetchToken(option?: getBackgroundFetchToken.Option): Promise /** 拉取 backgroundFetch 客户端缓存数据 - * @supported weapp + * @supported weapp, alipay, qq * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/background-fetch/wx.getBackgroundFetchData.html */ - getBackgroundFetchData(option: getBackgroundFetchData.Option): void + getBackgroundFetchData(option: getBackgroundFetchData.Option): Promise } } diff --git a/packages/taro/types/api/storage/cache-manager.d.ts b/packages/taro/types/api/storage/cache-manager.d.ts index e2366fb31d14..cb2a4212fffd 100644 --- a/packages/taro/types/api/storage/cache-manager.d.ts +++ b/packages/taro/types/api/storage/cache-manager.d.ts @@ -2,8 +2,42 @@ import Taro from '../../index' declare module '../../index' { interface CacheManager { + /** 当前缓存模式 */ + mode: keyof CacheManager.Mode + /** 全局 origin */ + origin: string + /** 全局缓存有效时间 */ + maxAge: number + /** 当前缓存管理器状态 */ + state: keyof CacheManager.State /** 添加规则 * @supported weapp + * @example + * ```tsx + * const ruleId = cacheManager.addRule({ + * id: 'haha-rule', + * method: 'GET', + * url: '/haha', + * maxAge: 123455, + * dataSchema: [ + * // data 字段的匹配,默认为空,表示不匹配 + * // 类型可以是:string、number、boolean、null、object、any(表示任意类型均可),以及这些类型的数组表示方式 + * {name: 'aaa', schema: {type: 'string'}}, // 类型为 string + * {name: 'bbb', schema: [{type: 'number'}, {type: 'string'}]}, // 类型为 number, string + * {name: 'ccc', schema: {type: 'string', value: 'abc'}}, // 值为 abc + * {name: 'ddd', schema: {type: 'string', value: /(abc|cba)/ig}}, // 值符合该正则匹配,如果该值不是字符串类型,则会被尝试转成字符串后再进行比较 + * {name: 'ddd', schema: {type: 'string', value: val => val === '123'}}, // 传入函数来校验值 + * {name: 'eee', schema: {type: 'object', value: [{ // 类型为对象,则通过嵌套的方式来逐层校验 + * name: 'aaa', schema: {type: 'string'}, + * // ... + * // 嵌套 dataSchema,同上面的方式一样来匹配嵌套的对象 + * }]}}, + * {name: 'fff', schema: {type: 'string[]'}}, // 类型为 string 数组 + * {name: 'ggg', schema: {type: 'any'}}, // 类型为任意类型 + * {name: 'hhh', schema: {type: 'any[]'}}, // 类型为任意类型的数组 + * ] + * }) + * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.addRule.html */ addRule(option: CacheManager.AddRuleOption): string @@ -26,7 +60,7 @@ declare module '../../index' { * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteCache.html */ - deleteCache( + deleteCache( /** 缓存 id */ id: string ): void @@ -40,7 +74,7 @@ declare module '../../index' { ): void /** 删除规则,同时会删除对应规则下所有缓存 * @supported weapp - * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteRule.html + * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.deleteRule.html */ deleteRule( /** 规则 id */ @@ -67,17 +101,17 @@ declare module '../../index' { /** 事件名称 */ eventName: string, /** 事件监听函数 */ - handler: Function + handler: TaroGeneral.EventCallback ): void /** 监听事件 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/CacheManager.on.html */ - on( + on( /** 事件名称 */ eventName: keyof CacheManager.OnEventName, /** 事件监听函数 */ - handler: Function + handler: TaroGeneral.EventCallback ): void /** 开启缓存,仅在 mode 为 none 时生效,调用后缓存管理器的 state 会置为 1 * @supported weapp @@ -92,6 +126,22 @@ declare module '../../index' { } namespace CacheManager { + interface Mode { + /** 默认值,弱网/离线使用缓存返回 */ + weakNetwork + /** 总是使用缓存返回 */ + always + /** 不开启,后续可手动开启/停止使用缓存返回 */ + none + } + interface State { + /** 不使用缓存返回 */ + 0 + /** 使用缓存返回 */ + 1 + /** 未知 */ + 2 + } interface DataSchema { /** 需要匹配的 data 对象的参数类型 * string、number、boolean、null、object、any(表示任意类型), @@ -117,7 +167,7 @@ declare module '../../index' { method: string /** uri 匹配规则,可参考规则字符串写法和正则写法 */ url: any - /** + /** * 缓存有效时间,单位为 ms,不填则默认取缓存管理器全局的缓存有效时间 * @default 7 * 24 * 60 * 60 * 1000 */ @@ -135,6 +185,7 @@ declare module '../../index' { rule: Rule } interface AddRulesOption { + /** 规则列表 */ rules: Rule[] } interface MatchOption { @@ -189,10 +240,10 @@ declare module '../../index' { } interface TaroStatic { - /** 拉起手机发送短信界面 - * @supported weap - * @see declare module '../../index' + /** 创建缓存管理器 + * @supported weapp + * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/cachemanager/wx.createCacheManager.html */ createCacheManager(option: createCacheManager.Option): CacheManager } -} \ No newline at end of file +} diff --git a/packages/taro/types/api/storage/index.d.ts b/packages/taro/types/api/storage/index.d.ts index ff54a9d47c8b..7d7389b46fa6 100644 --- a/packages/taro/types/api/storage/index.d.ts +++ b/packages/taro/types/api/storage/index.d.ts @@ -49,6 +49,10 @@ declare module '../../index' { keys: string[] /** 限制的空间大小,单位 KB */ limitSize: number + /** 是否执行成功 + * @supported alipay + */ + success?: boolean } } @@ -102,9 +106,54 @@ declare module '../../index' { } } + namespace batchSetStorageSync { + interface Option { + /** [{ key, value }] */ + kvList: kv[] + } + interface kv { + /** key 本地缓存中指定的 key */ + key: string + /** data 需要存储的内容。只支持原生类型、Date、及能够通过JSON.stringify序列化的对象。*/ + value: any + } + } + + namespace batchSetStorage { + interface Option { + /** [{ key, value }] */ + kvList: kv[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + interface kv { + /** key 本地缓存中指定的 key */ + key: string + /** data 需要存储的内容。只支持原生类型、Date、及能够通过JSON.stringify序列化的对象。*/ + value: any + } + } + + namespace batchGetStorage { + interface Option { + /** 本地缓存中指定的 keyList */ + keyList: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + } + interface TaroStatic { /** Taro.setStorage 的同步版本 - * @supported weapp, h5, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * Taro.setStorage({ @@ -128,7 +177,7 @@ declare module '../../index' { ): void /** 将数据存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.setStorage({ @@ -155,7 +204,7 @@ declare module '../../index' { ): void /** Taro.removeStorage 的同步版本 - * @supported weapp, h5, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * try { @@ -172,7 +221,7 @@ declare module '../../index' { ): void /** 从本地缓存中移除指定 key - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.removeStorage({ @@ -187,7 +236,7 @@ declare module '../../index' { removeStorage(option: removeStorage.Option): Promise /** Taro.getStorage 的同步版本 - * @supported weapp, h5, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * try { @@ -207,7 +256,7 @@ declare module '../../index' { ): T /** Taro.getStorageInfo 的同步版本 - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * try { @@ -224,7 +273,7 @@ declare module '../../index' { getStorageInfoSync(): getStorageInfoSync.Option /** 异步获取当前storage的相关信息 - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.getStorageInfo({ @@ -240,7 +289,7 @@ declare module '../../index' { getStorageInfo(option?: getStorageInfo.Option): Promise /** 从本地缓存中异步获取指定 key 的内容 - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.getStorage({ @@ -264,7 +313,7 @@ declare module '../../index' { ): void /** Taro.clearStorage 的同步版本 - * @supported weapp, h5, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, harmony_hybrid * @example * ```tsx * try { @@ -278,7 +327,7 @@ declare module '../../index' { clearStorageSync(): void /** 清理本地数据缓存 - * @supported weapp, h5, rn, tt + * @supported weapp, alipay, swan, jd, qq, tt, h5, rn, harmony_hybrid * @example * ```tsx * Taro.clearStorage() @@ -286,5 +335,71 @@ declare module '../../index' { * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.clearStorage.html */ clearStorage(option?: clearStorage.Option): Promise + + /** 将数据批量存储在本地缓存中指定的 key 中。 + * 会覆盖掉原来该 key 对应的内容。除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。 + * 单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 + * @supported weapp + * @example + * ```tsx + * try { + * Taro.batchSetStorageSync([{key: 'key', value: 'value'}]) + * } catch (e) { } + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorageSync.html + */ + batchSetStorageSync(option: batchSetStorageSync.Option): void + + /** 将数据批量存储在本地缓存中指定的 key 中。会覆盖掉原来该 key 对应的内容。 + * 除非用户主动删除或因存储空间原因被系统清理,否则数据都一直可用。 + * 单个 key 允许存储的最大数据长度为 1MB,所有数据存储上限为 10MB。 + * @supported weapp + * @example + * ```tsx + * Taro.batchGetStorage({ + * keyList: ['key'] + * success(res) { + * console.log(res) + * } + * }) + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorage.html + */ + batchSetStorage(option: batchSetStorage.Option): Promise + + /** 从本地缓存中同步批量获取指定 key 的内容。 + * @supported weapp + * @example + * ```tsx + * try { + * var valueList = Taro.batchGetStorageSync(['key']) + * if (valueList) { + * // Do something with return value + * } + * } catch (e) { + * // Do something when catch error + * } + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorageSync.html + */ + batchGetStorageSync( + /** 本地缓存中指定的 key 数组 */ + keyList: string[] + ): T[] + + /** 从本地缓存中异步批量获取指定 key 的内容。 + * @supported weapp + * @example + * ```tsx + * Taro.batchGetStorage({ + * keyList: ['key'], + * success(res) { + * console.log(res) + * } + * }) + * ``` + * @see https://developers.weixin.qq.com/miniprogram/dev/api/storage/wx.batchGetStorage.html + */ + batchGetStorage(option: batchGetStorage.Option): Promise } } diff --git a/packages/taro/types/api/swan/bookshelf.d.ts b/packages/taro/types/api/swan/bookshelf.d.ts new file mode 100644 index 000000000000..ae3e6343f5f4 --- /dev/null +++ b/packages/taro/types/api/swan/bookshelf.d.ts @@ -0,0 +1,307 @@ +import Taro from '../../index' + +declare module '../../index' { + namespace insertBookshelf { + interface Option { + /** 添加的内容分类 */ + category: keyof Category | string + /** 要添加到书架内容的 id,支持传多个,最多 100 条;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符) */ + contentIds: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + } + interface Category { + /** 专栏模板 */ + article + /** 文档模板 */ + doc + /** 动漫模板 */ + cartoon + /** 影音模板 */ + av + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 添加到书架的结果列表 */ + list: IListItem[] + } + interface IListItem { + /** 内容的唯一标识 */ + contentId: string + /** 添加状态:值为 0 时是失败,为 1 时是成功 */ + status: keyof Status + /** 添加信息 */ + msg: string + } + interface Status { + /** 失败 */ + 0 + /** 成功 */ + 1 + } + } + + namespace deleteBookshelf { + interface Option { + /** 要删除的内容分类 */ + category: keyof Category | string + /** 要删除书架内容的 id,支持传多个,最多 100 条;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符)。支持批量删除的同一个 category 下的多个 id,不同 category 下的 id 请分别调用该接口删除 */ + contentIds: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + } + interface Category { + /** 专栏模板 */ + article + /** 文档模板 */ + doc + /** 动漫模板 */ + cartoon + /** 影音模板 */ + av + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 添加到书架的结果列表 */ + list: IListItem[] + } + interface IListItem { + /** 内容的唯一标识 */ + contentId: string + /** 删除状态:值为 0 时是失败,为 1 时是成功 */ + status: keyof Status + /** 删除信息 */ + msg: string + } + interface Status { + /** 失败 */ + 0 + /** 成功 */ + 1 + } + } + + namespace queryBookshelf { + interface Option { + /** 要查询内容的 id,支持传多个,最多 100 条;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符) */ + contentIds: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 查询的内容结果列表 */ + list: IListItem[] + } + interface IListItem { + /** 内容的唯一标识 */ + contentId: string + /** 状态 */ + status: keyof Status + } + interface Status { + /** 不存在 */ + 0 + /** 存在 */ + 1 + } + } + + namespace updateBookshelfReadTime { + interface Option { + /** 添加的内容分类 */ + category: keyof Category | string + /** 要更新内容的 id;注释:contentId 为内容 id,内容的唯一标识,自定义,最长 22 字符(不能含有空格、中文字符) */ + contentIds: string[] + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => void + } + interface Category { + /** 专栏模板 */ + article + /** 文档模板 */ + doc + /** 动漫模板 */ + cartoon + /** 影音模板 */ + av + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 更新状态 */ + status: keyof Status + /** 更新的结果信息 */ + msg: string + } + interface Status { + /** 失败 */ + 0 + /** 成功 */ + 1 + } + } + + namespace navigateToBookshelf { + interface Option { + /** 跳转到指定的内容分类 + * @supported swan + */ + category: keyof Category | string + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用失败的回调函数 */ + fail?: (res: TaroGeneral.CallbackResult) => void + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => void + } + interface Category { + /** 专栏模板 */ + article + /** 文档模板 */ + doc + /** 动漫模板 */ + cartoon + /** 影音模板 */ + av + } + } + + interface TaroStatic { + /** 添加内容到宿主书架 + * @supported swan, qq + * @swan (需宿主支持书架入口) + * @example + * ```tsx + * Taro.insertBookshelf({ + * category: 'doc', + * contentIds: ['test1', 'test2'], + * success(res) { + * Taro.showModal({ + * title: 'success', + * content: JSON.stringify(res) + * }) + * }, + * fail(err) { + * Taro.showModal({ + * title: 'fail', + * content: JSON.stringify(err) + * }) + * } + * }) + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-insertBookshelf/ + */ + insertBookshelf(option: insertBookshelf.Option): void + + /** 删除书架中的内容(需宿主支持书架入口) + * @supported swan + * @example + * ```tsx + * Taro.deleteBookshelf({ + * category: 'doc', + * contentIds: ['test1', 'test2'], + * success(res) { + * Taro.showModal({ + * title: 'success', + * content: JSON.stringify(res) + * }) + * }, + * fail(err) { + * Taro.showModal({ + * title: 'fail', + * content: JSON.stringify(err) + * }) + * } + * }) + * ``` + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-deleteBookshelf/ + */ + deleteBookshelf(option: deleteBookshelf.Option): void + + /** 查询宿主书架的相关内容 + * @supported swan, qq + * @swan (需宿主支持书架入口) + * @example + * ```tsx + * Taro.queryBookshelf({ + * contentIds: ['test1', 'test2'], + * success(res) { + * Taro.showModal({ + * title: 'success', + * content: JSON.stringify(res) + * }) + * }, + * fail(err) { + * Taro.showModal({ + * title: 'fail', + * content: JSON.stringify(err) + * }) + * } + * }) + * ``` + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-queryBookshelf/ + */ + queryBookshelf(option: queryBookshelf.Option): void + + /** 更新已加入宿主书架的内容的阅读时间 + * @supported swan, qq + * @swan (需宿主支持书架入口) + * @example + * ```tsx + * Taro.updateBookshelfReadTime({ + * category: 'doc', + * contentIds: 'test1', + * success(res) { + * Taro.showModal({ + * title: 'success', + * content: JSON.stringify(res) + * }) + * }, + * fail(err) { + * Taro.showModal({ + * title: 'fail', + * content: JSON.stringify(err) + * }) + * } + * }) + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-queryBookshelf/ + */ + updateBookshelfReadTime(option: updateBookshelfReadTime.Option): void + + /** 跳转到宿主书架 + * @supported swan + * @swan (需宿主支持书架入口) + * @example + * ```tsx + * Taro.navigateToBookshelf({ + * category: 'article', + * contentIds: 'test1', + * success(res) { + * Taro.showModal({ + * title: 'navigateToBookshelf', + * content: 'success' + * }) + * }, + * fail(err) { + * Taro.showModal({ + * title: 'fail', + * content: JSON.stringify(err) + * }) + * } + * }) + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-navigateToBookshelf/ + */ + navigateToBookshelf(option: navigateToBookshelf.Option): void + } +} diff --git a/packages/taro/types/api/swan/download-package.d.ts b/packages/taro/types/api/swan/download-package.d.ts new file mode 100644 index 000000000000..3e3163515e48 --- /dev/null +++ b/packages/taro/types/api/swan/download-package.d.ts @@ -0,0 +1,80 @@ +import Taro from '../../index' + +declare module '../../index' { + namespace downloadPackage { + interface Option { + /** 预下载的小程序的 appKey */ + appKey: string + /** 预下载的小程序的 pageUrl ,默认值为小程序的首页页面 */ + pageUrl?: string + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => any + /** 接口调用失败的回调函数 */ + fail?: (err: TaroGeneral.CallbackResult) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => any + } + } + + namespace downloadPackages { + interface Option { + /** 预下载的小程序的列表。 */ + pageList: IPageItem[] + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => any + /** 接口调用失败的回调函数 */ + fail?: (err: TaroGeneral.CallbackResult) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => any + } + interface IPageItem { + /** 预下载的小程序的 appKey */ + appKey: string + /** 页面路径 */ + pages: string[] + } + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 小程序包预下载结果回调 */ + [key: string]: IAppKeyResult[] + } + interface IAppKeyResult { + /** 页面路径 */ + pageUrl: string + /** 预下载能力调用结果。值为 "0" 时是成功,非 "0" 时是失败 */ + status: string + /** 预下载结果信息 */ + message: string + } + } + + namespace loadSubPackage { + interface Option { + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => any + /** 接口调用失败的回调函数 */ + fail?: (err: TaroGeneral.CallbackResult) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => any + } + } + + interface TaroStatic { + /** 针对在小程序中调用其他小程序的场景,预下载其他小程序的包内容。 + * Web 态说明:Web 态不支持预下载的能力。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-downloadPackage/ + */ + downloadPackage(option: downloadPackage.Option): void + /** 针对在小程序中调用其他小程序的场景,预下载其他小程序的包内容。 + * Web 态说明:Web 态不支持预下载的能力。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-downloadPackages/ + */ + downloadPackages(option: downloadPackages.Option): void + /** 提前下载好子包的资源,目录结构配置参考[分包加载](https://smartprogram.baidu.com/docs/develop/framework/subpackages/)。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-loadSubPackage/ + */ + loadSubPackage(option: loadSubPackage.Option): void + } +} \ No newline at end of file diff --git a/packages/taro/types/api/swan/index.d.ts b/packages/taro/types/api/swan/index.d.ts index 41125a5c864b..8b38bc4dba43 100644 --- a/packages/taro/types/api/swan/index.d.ts +++ b/packages/taro/types/api/swan/index.d.ts @@ -54,6 +54,116 @@ declare module '../../index' { } } + namespace setMetaDescription { + interface Option { + /** 需要设置的 description 内容 */ + content: string + /** 接口调用成功的回调函数 */ + success?: (res: any) => any + /** 接口调用失败的回调函数 */ + fail?: (err: any) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: any) => any + } + } + + namespace setMetaKeywords { + interface Option { + /** 需要设置的 keywords 内容 */ + content: string + /** 接口调用成功的回调函数 */ + success?: (res: any) => any + /** 接口调用失败的回调函数 */ + fail?: (err: any) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: any) => any + } + } + + namespace setDocumentTitle { + interface Option { + /** 页面中 title 标签中的内容 */ + title: string + /** 接口调用成功的回调函数 */ + success?: (res: any) => any + /** 接口调用失败的回调函数 */ + fail?: (err: any) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: any) => any + } + } + + namespace getSystemRiskInfo { + interface Option { + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => any + /** 接口调用失败的回调函数 */ + fail?: (err: any) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: any) => any + } + interface SuccessCallbackResult { + /** 用于获取风控信息的加密信息对象。 + * 要获取风控信息,需要和[风控检测](https://smartprogram.baidu.com/docs/develop/serverapi/open_risk_power/#detectrisk/)接口联合使用,并作为风控检测接口的 xtoken 参数传入。 + */ + content: Object + } + interface IContent { + key: string + value: string + } + } + + namespace getFavorStatus { + interface Option { + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => any + /** 接口调用失败的回调函数 */ + fail?: (err: any) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: any) => any + } + interface SuccessCallbackResult { + /** 用户关注关注状态,1表示已关注,0表示未关注 */ + isFavor: string + } + } + + namespace getTopStatus { + interface Option { + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => any + /** 接口调用失败的回调函数 */ + fail?: (err: any) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: any) => any + } + interface SuccessCallbackResult { + /** 置顶状态 */ + isTop: boolean + } + } + + namespace openBdboxWebview { + interface Option { + /** 跳转百度 App 特定页面的 scheme 的 module */ + module?: string + /** 跳转百度 App 特定页面的 scheme 的 action */ + action?: string + /** 跳转百度 App 特定页面的 scheme 的 path */ + path?: string + /** 跳转百度 App 特定页面的 scheme 的 authority */ + authority?: string + /** 跳转百度 App 特定页面的 scheme 的参数 */ + parameters?: Object + /** 接口调用成功的回调函数 */ + success?: (res: any) => any + /** 接口调用失败的回调函数 */ + fail?: (err: any) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: any) => any + } + } interface TaroStatic { /** * 百度智能小程序可接入百度搜索和百度 App,setPageInfo 负责为小程序设置各类页面基础信息,包括标题、关键字、页面描述以及图片信息、视频信息等。开发者为智能小程序设置完备的页面基础信息,有助于智能小程序在搜索引擎和信息流中得到更加有效的展示和分发。 @@ -96,5 +206,46 @@ declare module '../../index' { * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-setPageInfo/ */ setPageInfo(option: setPageInfo.Option): void + /** 设置 web 版小程序 description meta 信息。此方法为 web 版小程序专用方法,使用前需判断方法是否存在。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-setMetaDescription/ + */ + setMetaDescription(option: setMetaDescription.Option): void + /** 设置 web 版小程序 keywords meta 信息。此方法为 web 版小程序专用方法,使用前需判断方法是否存在。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-setMetaKeywords/ + */ + setMetaKeywords(option: setMetaKeywords.Option): void + /** 动态设置当前页面的标题。此方法为 web 版小程序专用方法,使用前需判断方法是否存在。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-setDocumentTitle/ + */ + setDocumentTitle(option: setDocumentTitle.Option): void + /** 获取用于得到风控信息的加密信息对象。更多小程序风控能力参见[风控服务](https://smartprogram.baidu.com/docs/develop/serverapi/open_risk_power/)。 + * Web 态说明:Web 态小程序暂不支持获取用于得到风控信息的加密信息对象。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-getSystemRiskInfo/ + */ + getSystemRiskInfo(option: getSystemRiskInfo.Option): void + /** 获取小程序用户关注状态。 + * Web 态说明:Web 态小程序暂不支持关注小程序。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-getFavorStatus/ + */ + getFavorStatus(option: getFavorStatus.Option): void + /** 获取小程序用户置顶状态。 + * Web 态说明:Web 态小程序暂不支持获取置顶状态,降级调起百度 App。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-getTopStatus/ + */ + getTopStatus(option: getTopStatus.Option): void + /** 小程序跳转百度 App 内特定页面。接入本 API 的开发者,需要了解跳转页面的 scheme,并根据文档调用 API 完成跳转。可在百度 App 中,通过将跳转页面 scheme 生成对应二维码,并使用百度 APP 相机扫描二维码调起的方式,来确保 scheme 是否正确。 + * Web 态说明: + * 1.由于浏览器的限制,Web 态暂时无法准确获取跳转百度 App 成功 / 失败状态,会执行失败回调; + * 2.在用户未安装手百、部分第三方浏览器封禁百度 App 的情况下,Web 态会尝试降级调起应用商店。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/swan-openBdboxWebview/ + */ + openBdboxWebview(option: openBdboxWebview.Option): void } } diff --git a/packages/taro/types/api/swan/pay.d.ts b/packages/taro/types/api/swan/pay.d.ts new file mode 100644 index 000000000000..1ebbc2f25164 --- /dev/null +++ b/packages/taro/types/api/swan/pay.d.ts @@ -0,0 +1,139 @@ +import { Interface } from 'readline' +import Taro from '../../index' + +declare module '../../index' { + + namespace requestPolymerPayment { + interface Option { + /** 订单信息 */ + orderInfo: OrderInfo + /** 接口调用成功的回调函数 */ + success?: (res: TaroGeneral.CallbackResult) => any + /** 接口调用失败的回调函数 */ + fail?: (err: FailCallbackResult) => any + /** 接口调用结束的回调函数(调用成功、失败都会执行) */ + complete?: (res: TaroGeneral.CallbackResult) => any + } + interface OrderInfo { + /** 跳转百度收银台支付必带参数之一,是百度收银台的财务结算凭证,与账号绑定的结算协议一一对应,每笔交易将结算到 dealId 对应的协议主体。 + * 详见[核心参数获取与组装](https://smartprogram.baidu.com/docs/develop/function/parameter/)。 + */ + dealId: string + /** 支付能力开通后分配的支付 appKey,用以表示应用身份的唯一 ID ,在应用审核通过后进行分配,一经分配后不会发生更改,来唯一确定一个应用。 + * 详见[核心参数获取与组装](https://smartprogram.baidu.com/docs/develop/function/parameter/)。 + */ + appKey: string + /** 订单金额(单位:人民币分)。注:小程序测试包测试金额不可超过 1000 分 */ + totalAmount: string + /** 小程序开发者系统创建的唯一订单 ID ,当支付状态发生变化时,会通过此订单 ID 通知开发者。 */ + tpOrderId: string + /** 通知开发者支付状态的回调地址,必须是合法的 URL ,与开发者平台填写的支付回调地址作用一致,未填写的以平台回调地址为准 */ + notifyUrl?: string + /** 订单的名称。 */ + dealTitle: string + /** 用于区分验签字段范围,signFieldsRange 的值:0:原验签字段 appKey+dealId+tpOrderId;1:包含 totalAmount 的验签,验签字段包括appKey+dealId+tpOrderId+totalAmount。固定值为 1 。 */ + signFieldsRange: string + /** 对appKey+dealId+totalAmount+tpOrderId进行 RSA 加密后的签名,防止订单被伪造。 + * 签名过程见[签名与验签](https://smartprogram.baidu.com/docs/develop/function/sign_v2/)。 + */ + rsaSign: string + /** 订单详细信息,需要是一个可解析为 JSON Object 的字符串。 + * 字段内容见: [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)。 + */ + bizInfo?: string + /** 当前页面 path。Web 态小程序支付成功后跳回的页面路径,例如:'/pages/payResult/payResult' */ + payResultUrl?: string + /** + * 内嵌支付组件返回的支付信息加密 key,与[内嵌支付组件](https://smartprogram.baidu.com/docs/develop/component/inline_payment_panel)配套使用,此值不传或者传空时默认调起支付面板。 + */ + inlinePaySign?: string + /** 平台营销信息,此处传可使用平台券的 spuid,支持通过英文逗号分割传入多个 spuid 值,仅与百度合作平台类目券的开发者需要填写 */ + promotionTag?: string + } + + interface FailCallbackResult extends TaroGeneral.CallbackResult { + /** 错误码 */ + errCode: number + /** 详细错误信息。 + * 注: 目前仅在内嵌支付组件调起 swan.requestPolymerPayment 时,选择数字人民币 APP 渠道支付且用户未下载数字人民币 APP 时,返回具体错误信息 data。 + */ + data: DetailFailData + } + interface DetailFailData { + /** 详细错误码。20014 表示【未下载数字人民币 APP】 */ + subErrCode: number + /** 详细错误信息 */ + subErrMsg: string + } + } + + namespace getOptimalPriceInfo { + interface Option { + /** 商品信息 */ + productsInfo: ProductInfo[] + /** 接口调用成功的回调函数 */ + success?: (res: SuccessCallbackResult) => any + /** 接口调用失败的回调函数 */ + fail?: (err: TaroGeneral.CallbackResult) => any + } + + interface ProductInfo { + /** 支付的 appKey */ + appKey: string + /** 商品信息 */ + products: Product[] + } + interface Product { + /** 商品单价(原价) */ + amount: number + /** 商品标识 */ + promotionTag?: string + /** 开发者自定义商品 ID,在success回调中,会与减免信息一起返回。*/ + productId: string + } + + interface SuccessCallbackResult extends TaroGeneral.CallbackResult { + /** 商品信息 */ + productsInfo: ProductInfoSuccess[] + } + interface ProductInfoSuccess { + /** 支付的 appKey */ + appKey: string + /** 减免后的商品信息 */ + products: ProductSuccess[] + } + interface ProductSuccess { + /** 商品单价(原价) */ + amount: number + /** 开发者自定义商品 ID */ + productId: string + /** 商品标识 */ + promotionTag: string + /** 百度平台券减免金额 */ + reduceAmount: number + /** 百度平台券减免后金额 */ + afterPayAmount: number + } + } + + interface TaroStatic { + /** + * 1)百度收银台,聚合了主流的百度钱包、微信、支付宝、网银等多种支付渠道,方便开发者一站式快速接入多种支付渠道,让百度用户能在智能小程序场景下,直接完成支付、交易闭环,提升用户支付体验的同时,提高智能小程序的订单转化率。 + * 2)上述支付渠道在 C 端收银台有两种展示方式,开发者可以选择其中一种实现。 + * 方式一:将支付渠道内嵌在小程序提单页面中,实现方式参考文档[inline-payment-panel内嵌支付组件](https://smartprogram.baidu.com/docs/develop/component/inline_payment_panel/)。 + * 方式二:在用户确认订单后,调起收银台半屏面板承载支付渠道,实现方式参考文档调起[百度收银台](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)。 + * + * Web 态说明:为了保证用户交易行为全流程闭环体验,在 Web 态下调用该方法会做打开百度 App 对应小程序页面的降级处理。 + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/payment_swan-requestPolymerPayment/ + */ + requestPolymerPayment(option: requestPolymerPayment.Option): void + /** 获取商品使用百度平台券后的价格 + * 通过百度收银台支付的商品,用户在支付时可以享受百度平台券提供的优惠。 + * 使用 API swan.getOptimalPriceInfo 可以提前获知用户在支付时享受的优惠价格。(当用户有多张平台券时,按照平台最优优惠价格计算,与支付时默认选中的优惠券对应的优惠一致) + * @supported swan + * @see https://smartprogram.baidu.com/docs/develop/api/open/payment_swan-getOptimalPriceInfo/ + */ + getOptimalPriceInfo(option: getOptimalPriceInfo.Option): void + } +} \ No newline at end of file diff --git a/packages/taro/types/api/taro.extend.d.ts b/packages/taro/types/api/taro.extend.d.ts index eaf99c83f57c..9a948e318d7a 100644 --- a/packages/taro/types/api/taro.extend.d.ts +++ b/packages/taro/types/api/taro.extend.d.ts @@ -45,6 +45,7 @@ declare module '../index' { [TaroGeneral.ENV_TYPE.TT]: TaroGeneral.ENV_TYPE.TT [TaroGeneral.ENV_TYPE.QQ]: TaroGeneral.ENV_TYPE.QQ [TaroGeneral.ENV_TYPE.JD]: TaroGeneral.ENV_TYPE.JD + [TaroGeneral.ENV_TYPE.HARMONYHYBRID]: TaroGeneral.ENV_TYPE.HARMONYHYBRID } namespace interceptorify { @@ -97,7 +98,7 @@ declare module '../index' { }): void /** 小程序获取和 Taro 相关的 App 信息 - * @supported weapp, alipay, jd, qq, swan, tt, h5 + * @supported weapp, alipay, jd, qq, swan, tt, h5, harmony_hybrid */ getAppInfo(): getAppInfo.AppInfo @@ -127,7 +128,13 @@ declare module '../index' { /** 小程序引用插件 JS 接口 * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp */ - requirePlugin(pluginName: string): any + requirePlugin: { + (pluginName: string): any + /** @supported weapp */ + (pluginName: string, success?: (mod: any) => any, error?: (e: { mod: any; errMsg: string }) => any): any; + /** @supported weapp */ + async?: (pluginName: string) => Promise + } /** 获取当前页面实例 * @supported global @@ -138,7 +145,7 @@ declare module '../index' { Current: getCurrentInstance.Current /** Vue3 插件,用于设置 `getApp()` 中的全局变量 - * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp + * @supported weapp, alipay, h5, rn, jd, qq, swan, tt, quickapp, harmony_hybrid * @example * ```js * // 使用插件 diff --git a/packages/taro/types/api/taro.hooks.d.ts b/packages/taro/types/api/taro.hooks.d.ts index 91f98745dc5e..6b07e06c7978 100644 --- a/packages/taro/types/api/taro.hooks.d.ts +++ b/packages/taro/types/api/taro.hooks.d.ts @@ -46,7 +46,7 @@ declare module '../index' { /** * 当前是 tab 页时,tab 被点击时的回调。 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid */ useTabItemTap(callback: (payload: TabItemTapObject) => void): void @@ -73,45 +73,45 @@ declare module '../index' { /** * 小程序初始化完成时的回调。 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid */ useLaunch(callback: (options: getLaunchOptionsSync.LaunchOptions) => void): void /** * 小程序发生脚本错误或 API 调用报错时触发的回调。 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid */ useError(callback: (error: string) => void): void /** * 小程序有未处理的 Promise reject 时触发。也可以使用 Taro.onUnhandledRejection 绑定监听。 - * @supported weapp, alipay, h5 + * @supported weapp, alipay, h5, harmony_hybrid */ useUnhandledRejection(callback: (error: { reason: Error, promise: Promise }) => void): void /** * 小程序要打开的页面不存在时触发的回调。 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @h5 多页面模式不支持该方法 */ usePageNotFound(callback: (res: { path: string, query: Record, isEntryPage: boolean, [key: string]: any }) => void): void /** * 页面加载完成时的回调。 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid */ useLoad>(callback: (param: T) => void): void /** * 页面卸载时的回调。 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid */ useUnload(callback: () => void): void /** * 页面初次渲染完成的回调。 * 此时页面已经准备妥当,可以和视图层进行交互。 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid */ useReady(callback: () => void): void @@ -135,7 +135,7 @@ declare module '../index' { /** * 下拉中断时的回调。 - * @supported alipay, h5 + * @supported alipay, h5, harmony_hybrid */ usePullIntercept(callback: () => void): void } diff --git a/packages/taro/types/api/ui/animation.d.ts b/packages/taro/types/api/ui/animation.d.ts index af77e1d1e135..d527889114b6 100644 --- a/packages/taro/types/api/ui/animation.d.ts +++ b/packages/taro/types/api/ui/animation.d.ts @@ -38,34 +38,34 @@ declare module '../../index' { } /** 动画对象 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.html */ interface Animation { /** 导出动画队列。**export 方法每次调用后会清掉之前的动画操作**。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.export.html */ export(): { actions: TaroGeneral.IAnyObject[] } /** 表示一组动画完成。可以在一组动画中调用任意多个动画方法,一组动画中的所有动画会同时开始,一组动画完成后才会进行下一组动画。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.step.html */ step(option?: Animation.StepOption): Animation /** 同 [transform-function matrix](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix) - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.matrix.html */ matrix(a: number, b: number, c: number, d: number, tx: number, ty: number): Animation /** 同 [transform-function matrix3d](https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/matrix3d) - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.matrix3d.html */ matrix3d(a1: number, b1: number, c1: number, d1: number, a2: number, b2: number, c2: number, d2: number, a3: number, b3: number, c3: number, d3: number, a4: number, b4: number, c4: number, d4: number): Animation /** 从原点顺时针旋转一个角度 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotate.html */ rotate( @@ -73,7 +73,7 @@ declare module '../../index' { angle: number, ): Animation /** 从 固定 轴顺时针旋转一个角度 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotate3d.html */ rotate3d( @@ -87,7 +87,7 @@ declare module '../../index' { angle?: number, ): Animation /** 从 X 轴顺时针旋转一个角度 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateX.html */ rotateX( @@ -95,7 +95,7 @@ declare module '../../index' { angle: number, ): Animation /** 从 Y 轴顺时针旋转一个角度 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateY.html */ rotateY( @@ -103,7 +103,7 @@ declare module '../../index' { angle: number, ): Animation /** 从 Z 轴顺时针旋转一个角度 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.rotateZ.html */ rotateZ( @@ -111,7 +111,7 @@ declare module '../../index' { angle: number, ): Animation /** 缩放 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scale.html */ scale( @@ -121,7 +121,7 @@ declare module '../../index' { sy?: number, ): Animation /** 缩放 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scale3d.html */ scale3d( @@ -133,7 +133,7 @@ declare module '../../index' { sz: number, ): Animation /** 缩放 X 轴 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleX.html */ scaleX( @@ -141,7 +141,7 @@ declare module '../../index' { scale: number, ): Animation /** 缩放 Y 轴 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleY.html */ scaleY( @@ -149,7 +149,7 @@ declare module '../../index' { scale: number, ): Animation /** 缩放 Z 轴 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.scaleZ.html */ scaleZ( @@ -157,7 +157,7 @@ declare module '../../index' { scale: number, ): Animation /** 对 X、Y 轴坐标进行倾斜 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.skew.html */ skew( @@ -167,7 +167,7 @@ declare module '../../index' { ay: number, ): Animation /** 对 X 轴坐标进行倾斜 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.skewX.html */ skewX( @@ -175,7 +175,7 @@ declare module '../../index' { angle: number, ): Animation /** 对 Y 轴坐标进行倾斜 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.skewY.html */ skewY( @@ -183,7 +183,7 @@ declare module '../../index' { angle: number, ): Animation /** 平移变换 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translate.html */ translate( @@ -193,7 +193,7 @@ declare module '../../index' { ty?: number, ): Animation /** 对 xyz 坐标进行平移变换 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translate3d.html */ translate3d( @@ -205,7 +205,7 @@ declare module '../../index' { tz?: number, ): Animation /** 对 X 轴平移 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateX.html */ translateX( @@ -213,7 +213,7 @@ declare module '../../index' { translation: number, ): Animation /** 对 Y 轴平移 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateY.html */ translateY( @@ -221,7 +221,7 @@ declare module '../../index' { translation: number, ): Animation /** 对 Z 轴平移 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.translateZ.html */ translateZ( @@ -229,7 +229,7 @@ declare module '../../index' { translation: number, ): Animation /** 设置透明度 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.opacity.html */ opacity( @@ -237,7 +237,7 @@ declare module '../../index' { value: number, ): Animation /** 设置背景色 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.backgroundColor.html */ backgroundColor( @@ -245,7 +245,7 @@ declare module '../../index' { value: string, ): Animation /** 设置宽度 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.width.html */ width( @@ -253,7 +253,7 @@ declare module '../../index' { value: number | string, ): Animation /** 设置高度 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.height.html */ height( @@ -261,7 +261,7 @@ declare module '../../index' { value: number | string, ): Animation /** 设置 left 值 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.left.html */ left( @@ -269,7 +269,7 @@ declare module '../../index' { value: number | string, ): Animation /** 设置 right 值 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.right.html */ right( @@ -277,7 +277,7 @@ declare module '../../index' { value: number | string, ): Animation /** 设置 top 值 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.top.html */ top( @@ -285,7 +285,7 @@ declare module '../../index' { value: number | string, ): Animation /** 设置 bottom 值 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/animation/Animation.bottom.html */ bottom( @@ -410,7 +410,7 @@ declare module '../../index' { interface TaroStatic { /** 创建一个动画实例 [animation](../Animation)。调用实例的方法来描述动画。最后通过动画实例的 export 方法导出动画数据传递给组件的 animation 属性。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * var animation = Taro.createAnimation({ diff --git a/packages/taro/types/api/ui/custom-component.d.ts b/packages/taro/types/api/ui/custom-component.d.ts index 9cd98c98f002..f7afc78e0672 100644 --- a/packages/taro/types/api/ui/custom-component.d.ts +++ b/packages/taro/types/api/ui/custom-component.d.ts @@ -7,7 +7,7 @@ declare module '../../index' { * **说明** * 因为自定义组件中的 setData 和 triggerEvent 等接口本身是同步的操作,当这几个接口被连续调用时,都是在一个同步流程中执行完的,因此若逻辑不当可能会导致出错。 * 一个极端的案例:当父组件的 setData 引发了子组件的 triggerEvent,进而使得父组件又进行了一次 setData,期间有通过 wx:if 语句对子组件进行卸载,就有可能引发奇怪的错误,所以对于不需要在一个同步流程内完成的逻辑,可以使用此接口延迟到下一个时间片再执行。 - * @supported weapp, h5 + * @supported weapp, h5, harmony_hybrid * @example * ```tsx * this.setData({ number: 1 }) // 直接在当前同步流程中执行 diff --git a/packages/taro/types/api/ui/fonts.d.ts b/packages/taro/types/api/ui/fonts.d.ts index 11826e47157c..c1eb5671d8c1 100644 --- a/packages/taro/types/api/ui/fonts.d.ts +++ b/packages/taro/types/api/ui/fonts.d.ts @@ -54,13 +54,14 @@ declare module '../../index' { /** 动态加载网络字体。文件地址需为下载类型。iOS 仅支持 https 格式文件地址。 * * 注意: - * 1. 字体文件返回的 contet-type 参考 [font](https://www.iana.org/assignments/media-types/media-types.xhtml#font),格式不正确时会解析失败。 + * 1. 字体文件返回的 context-type 参考 [font](https://www.iana.org/assignments/media-types/media-types.xhtml#font),格式不正确时会解析失败。 * 2. 字体链接必须是https(ios不支持http) * 3. 字体链接必须是同源下的,或开启了cors支持,小程序的域名是`servicewechat.com` * 4. canvas等原生组件不支持使用接口添加的字体 - * 5. 工具里提示 Faild to load font可以忽略 - * @supported weapp, h5 + * 5. 工具里提示 Failed to load font 可以忽略 + * @supported weapp, alipay, h5, harmony_hybrid * @h5 不支持 global (默认全局加载) + * @alipay source 地址格式为 `url('https://...')`,而不是单纯 URL 地址 * @example * ```tsx * Taro.loadFontFace({ diff --git a/packages/taro/types/api/ui/interaction.d.ts b/packages/taro/types/api/ui/interaction.d.ts index 2db00a625304..e14e9b19b9db 100644 --- a/packages/taro/types/api/ui/interaction.d.ts +++ b/packages/taro/types/api/ui/interaction.d.ts @@ -160,7 +160,7 @@ declare module '../../index' { * **注意** * - Taro.showLoading 和 Taro.showToast 同时只能显示一个 * - Taro.showToast 应与 Taro.hideToast 配对使用 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.showToast({ @@ -177,7 +177,7 @@ declare module '../../index' { * **注意** * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel"; * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑 - * @supported weapp, h5, rn, tt + * @supported weapp, swan, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.showModal({ @@ -201,7 +201,7 @@ declare module '../../index' { * **注意** * - Taro.showLoading 和 Taro.showToast 同时只能显示一个 * - Taro.showLoading 应与 Taro.hideLoading 配对使用 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.showLoading({ @@ -220,7 +220,7 @@ declare module '../../index' { * **注意** * - Android 6.7.2 以下版本,点击取消或蒙层时,回调 fail, errMsg 为 "fail cancel"; * - Android 6.7.2 及以上版本 和 iOS 点击蒙层不会关闭模态弹窗,所以尽量避免使用「取消」分支中实现业务逻辑 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.showActionSheet({ @@ -238,13 +238,13 @@ declare module '../../index' { showActionSheet(option: showActionSheet.Option): Promise /** 隐藏消息提示框 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/interaction/wx.hideToast.html */ hideToast(option?: hideToast.Option): void /** 隐藏 loading 提示框 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.showLoading({ diff --git a/packages/taro/types/api/ui/menu.d.ts b/packages/taro/types/api/ui/menu.d.ts index 0b133d75bce8..f20dd1a397e4 100644 --- a/packages/taro/types/api/ui/menu.d.ts +++ b/packages/taro/types/api/ui/menu.d.ts @@ -21,7 +21,7 @@ declare module '../../index' { interface TaroStatic { /** 获取菜单按钮(右上角胶囊按钮)的布局位置信息。坐标信息以屏幕左上角为原点。 - * @supported weapp, tt + * @supported weapp, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/menu/wx.getMenuButtonBoundingClientRect.html */ getMenuButtonBoundingClientRect(): getMenuButtonBoundingClientRect.Rect diff --git a/packages/taro/types/api/ui/navigation-bar.d.ts b/packages/taro/types/api/ui/navigation-bar.d.ts index 953fba4322e7..8da578bc504d 100644 --- a/packages/taro/types/api/ui/navigation-bar.d.ts +++ b/packages/taro/types/api/ui/navigation-bar.d.ts @@ -85,7 +85,7 @@ declare module '../../index' { showNavigationBarLoading(option?: showNavigationBarLoading.Option): void /** 动态设置当前页面的标题 - * @supported weapp, alipay, h5, rn, tt + * @supported weapp, alipay, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.setNavigationBarTitle({ @@ -97,7 +97,7 @@ declare module '../../index' { setNavigationBarTitle(option: setNavigationBarTitle.Option): Promise /** 设置页面导航条颜色 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @h5 不支持 animation 参数 * @rn 不支持 animation 参数 * @example diff --git a/packages/taro/types/api/ui/pull-down-refresh.d.ts b/packages/taro/types/api/ui/pull-down-refresh.d.ts index 768730d107da..129b9985faf5 100644 --- a/packages/taro/types/api/ui/pull-down-refresh.d.ts +++ b/packages/taro/types/api/ui/pull-down-refresh.d.ts @@ -25,7 +25,7 @@ declare module '../../index' { interface TaroStatic { /** 停止当前页面下拉刷新。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * onPullDownRefresh: function (){ @@ -37,7 +37,7 @@ declare module '../../index' { stopPullDownRefresh(option?: stopPullDownRefresh.Option): void /** 开始下拉刷新。调用后触发下拉刷新动画,效果与用户手动下拉刷新一致。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @rn 无动画效果 * @example * ```tsx diff --git a/packages/taro/types/api/ui/scroll.d.ts b/packages/taro/types/api/ui/scroll.d.ts index cb684b35ce03..3153696825cb 100644 --- a/packages/taro/types/api/ui/scroll.d.ts +++ b/packages/taro/types/api/ui/scroll.d.ts @@ -99,7 +99,7 @@ declare module '../../index' { * - 后代选择器:.the-ancestor .the-descendant * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant * - 多选择器的并集:#a-node, .some-other-nodes - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.pageScrollTo({ diff --git a/packages/taro/types/api/ui/tab-bar.d.ts b/packages/taro/types/api/ui/tab-bar.d.ts index 77c4e15ca147..afca2e227aa8 100644 --- a/packages/taro/types/api/ui/tab-bar.d.ts +++ b/packages/taro/types/api/ui/tab-bar.d.ts @@ -121,19 +121,19 @@ declare module '../../index' { interface TaroStatic { /** 显示 tabBar 某一项的右上角的红点 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.showTabBarRedDot.html */ showTabBarRedDot(option: showTabBarRedDot.Option): Promise /** 显示 tabBar - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.showTabBar.html */ showTabBar(option?: showTabBar.Option): Promise /** 动态设置 tabBar 的整体样式 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.setTabBarStyle({ @@ -148,7 +148,7 @@ declare module '../../index' { setTabBarStyle(option?: setTabBarStyle.Option): Promise /** 动态设置 tabBar 某一项的内容,`2.7.0` 起图片支持临时文件和网络文件。 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.setTabBarItem({ @@ -163,7 +163,7 @@ declare module '../../index' { setTabBarItem(option: setTabBarItem.Option): Promise /** 为 tabBar 某一项的右上角添加文本 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @example * ```tsx * Taro.setTabBarBadge({ @@ -176,19 +176,19 @@ declare module '../../index' { setTabBarBadge(option: setTabBarBadge.Option): Promise /** 移除 tabBar 某一项右上角的文本 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.removeTabBarBadge.html */ removeTabBarBadge(option: removeTabBarBadge.Option): Promise /** 隐藏 tabBar 某一项的右上角的红点 - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.hideTabBarRedDot.html */ hideTabBarRedDot(option: hideTabBarRedDot.Option): Promise /** 隐藏 tabBar - * @supported weapp, h5, rn, tt + * @supported weapp, h5, rn, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/tab-bar/wx.hideTabBar.html */ hideTabBar(option?: hideTabBar.Option): Promise diff --git a/packages/taro/types/api/ui/window.d.ts b/packages/taro/types/api/ui/window.d.ts index 24c7b880cbd2..34acb754eafb 100644 --- a/packages/taro/types/api/ui/window.d.ts +++ b/packages/taro/types/api/ui/window.d.ts @@ -44,7 +44,7 @@ declare module '../../index' { setWindowSize(option: setWindowSize.Option): Promise /** 监听窗口尺寸变化事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.onWindowResize.html */ onWindowResize( @@ -53,7 +53,7 @@ declare module '../../index' { ): void /** 取消监听窗口尺寸变化事件 - * @supported weapp, h5, rn + * @supported weapp, h5, rn, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/ui/window/wx.offWindowResize.html */ offWindowResize( diff --git a/packages/taro/types/api/wxml/index.d.ts b/packages/taro/types/api/wxml/index.d.ts index 4a7585aea229..dc033bf72154 100644 --- a/packages/taro/types/api/wxml/index.d.ts +++ b/packages/taro/types/api/wxml/index.d.ts @@ -18,12 +18,12 @@ declare module '../../index' { */ interface IntersectionObserver { /** 停止监听。回调函数将不再触发 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.disconnect.html */ disconnect(): void /** 指定目标节点并开始监听相交状态变化情况 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.observe.html */ observe( @@ -33,7 +33,7 @@ declare module '../../index' { callback: IntersectionObserver.ObserveCallback, ): void /** 使用选择器指定一个节点,作为参照区域之一。 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/IntersectionObserver.relativeTo.html */ relativeTo( @@ -43,7 +43,7 @@ declare module '../../index' { margins?: IntersectionObserver.RelativeToMargins, ): IntersectionObserver /** 指定页面显示区域作为参照区域之一 - * @supported weapp, tt, h5 + * @supported weapp, tt, h5, harmony_hybrid * @example * 下面的示例代码中,如果目标节点(用选择器 .target-class 指定)进入显示区域以下 100px 时,就会触发回调函数。 * @@ -184,7 +184,7 @@ declare module '../../index' { */ interface NodesRef { /** 添加节点的布局位置的查询请求。相对于显示区域,以像素为单位。其功能类似于 DOM 的 `getBoundingClientRect`。返回 `NodesRef` 对应的 `SelectorQuery`。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * Taro.createSelectorQuery().select('#the-id').boundingClientRect(function(rect){ @@ -220,7 +220,7 @@ declare module '../../index' { callback?: NodesRef.BoundingClientRectCallback, ): SelectorQuery /** 添加节点的 Context 对象查询请求。目前支持 [VideoContext](/docs/apis/media/video/VideoContext)、[CanvasContext](/docs/apis/canvas/CanvasContext)、[LivePlayerContext](/docs/apis/media/live/LivePlayerContext)、[EditorContext](/docs/apis/media/editor/EditorContext)和 [MapContext](/docs/apis/media/map/MapContext) 的获取。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * Taro.createSelectorQuery().select('.the-video-class').context(function (res) { @@ -237,7 +237,7 @@ declare module '../../index' { * * **注意** * computedStyle 的优先级高于 size,当同时在 computedStyle 里指定了 width/height 和传入了 size: true,则优先返回 computedStyle 获取到的 width/height。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * Taro.createSelectorQuery().select('#the-id').fields({ @@ -269,7 +269,7 @@ declare module '../../index' { callback?: NodesRef.FieldsCallback, ): SelectorQuery /** 获取 Node 节点实例。目前支持 [Canvas](/docs/components/canvas) 的获取。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * Taro.createSelectorQuery().select('.canvas').node(function(res){ @@ -283,7 +283,7 @@ declare module '../../index' { callback?: NodesRef.NodeCallback, ): SelectorQuery /** 添加节点的滚动位置查询请求。以像素为单位。节点必须是 `scroll-view` 或者 `viewport`,返回 `NodesRef` 对应的 `SelectorQuery`。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * Taro.createSelectorQuery().selectViewport().scrollOffset(function(res){ @@ -384,7 +384,7 @@ declare module '../../index' { */ interface SelectorQuery { /** 执行所有的请求。请求结果按请求次序构成数组,在callback的第一个参数中返回。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.exec.html */ exec( @@ -392,7 +392,7 @@ declare module '../../index' { callback?: (...args: any[]) => any, ): NodesRef /** 将选择器的选取范围更改为自定义组件 `component` 内。(初始时,选择器仅选取页面范围的节点,不会选取任何自定义组件中的节点)。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * Component({ @@ -423,7 +423,7 @@ declare module '../../index' { * - 后代选择器:.the-ancestor .the-descendant * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant * - 多选择器的并集:#a-node, .some-other-nodes - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * Taro.createSelectorQuery().select('#the-id').fields({ @@ -459,7 +459,7 @@ declare module '../../index' { * - 后代选择器:.the-ancestor .the-descendant * - 跨自定义组件的后代选择器:.the-ancestor >>> .the-descendant * - 多选择器的并集:#a-node, .some-other-nodes - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/SelectorQuery.selectAll.html */ selectAll( @@ -467,7 +467,7 @@ declare module '../../index' { selector: string, ): NodesRef /** 选择显示区域。可用于获取显示区域的尺寸、滚动位置等信息。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * Taro.createSelectorQuery().selectViewport().scrollOffset(function (res) { @@ -484,7 +484,7 @@ declare module '../../index' { interface TaroStatic { /** 返回一个 SelectorQuery 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createSelectorQuery()` 来代替。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx * const query = Taro.createSelectorQuery() @@ -500,10 +500,10 @@ declare module '../../index' { createSelectorQuery(): SelectorQuery /** 创建并返回一个 IntersectionObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createIntersectionObserver([options])` 来代替。 - * @supported weapp, h5, tt + * @supported weapp, h5, tt, harmony_hybrid * @example * ```tsx - * const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true }) + * const observer = Taro.createIntersectionObserver(this, { thresholds: [0], observeAll: true }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/wxml/wx.createIntersectionObserver.html */ @@ -515,7 +515,7 @@ declare module '../../index' { ): IntersectionObserver /** 创建并返回一个 MediaQueryObserver 对象实例。在自定义组件或包含自定义组件的页面中,应使用 `this.createMediaQueryObserver()` 来代替。 - * @supported h5 + * @supported h5, harmony_hybrid * @example * ```tsx * let createMediaQueryObserver @@ -525,7 +525,7 @@ declare module '../../index' { * } else if (process.env.TARO_ENV === 'h5') { * createMediaQueryObserver= Taro.createMediaQueryObserver * } - * const mediaQueryObserver = createMediaQueryObserver() + * const mediaQueryObserver = createMediaQueryObserver() * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/framework/view/resizable.html#Media%20Query */ diff --git a/packages/taro/types/compile/compiler.d.ts b/packages/taro/types/compile/compiler.d.ts index 76edd1f70869..148fdc9000fe 100644 --- a/packages/taro/types/compile/compiler.d.ts +++ b/packages/taro/types/compile/compiler.d.ts @@ -20,6 +20,8 @@ interface IPrebundle { interface ICompiler { type: CompilerTypes prebundle?: IPrebundle + /** 错误处理级别。可选值:0、1 */ + errorLevel?: number } export type Compiler = CompilerTypes | ICompiler diff --git a/packages/taro/types/compile/config/h5.d.ts b/packages/taro/types/compile/config/h5.d.ts index 8a7d22ad2a01..5aeaec609640 100644 --- a/packages/taro/types/compile/config/h5.d.ts +++ b/packages/taro/types/compile/config/h5.d.ts @@ -44,6 +44,9 @@ export interface IH5Config { /** 预览服务的配置,可以更改端口等参数。具体配置参考 [webpack-dev-server](https://webpack.js.org/configuration/dev-server) */ devServer?: webpackDevServer.Configuration + /** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */ + enableSourceMap?: boolean + /** 具体配置请参考 [Webpack devtool](https://webpack.js.org/configuration/devtool/#devtool) 配置 (默认值:'cheap-module-eval-source-map')*/ sourceMapType?: | 'none' @@ -93,7 +96,7 @@ export interface IH5Config { /** 配置需要额外的经由 Taro 预设的 postcss 编译的模块 */ esnextModules?: string[] - /** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/next/h5#react-兼容性组件库)。(默认值:false) */ + /** 用于控制在 H5 端是否使用兼容性组件库,详情请看 [React 兼容性组件库](https://taro-docs.jd.com/docs/h5#react-兼容性组件库)。(默认值:false) */ useHtmlComponents?: boolean /** 用于控制在 H5 端是否使用旧版本适配器,旧版本采用全局注册组件,懒加载组件相关依赖;新版本适配器会自动注册相关组件,不再需要引入 @tarojs/components/loader 中的全局 defineCustomElements 方法。(默认值:false) */ diff --git a/packages/taro/types/compile/config/mini.d.ts b/packages/taro/types/compile/config/mini.d.ts index bb2aff4b828f..04c1ff3f8312 100644 --- a/packages/taro/types/compile/config/mini.d.ts +++ b/packages/taro/types/compile/config/mini.d.ts @@ -3,16 +3,19 @@ import type Chain from 'webpack-chain' import type { IOption, IPostcssOption } from './util' interface Runtime { - enableInnerHTML: boolean - enableSizeAPIs: boolean - enableAdjacentHTML: boolean - enableTemplateContent: boolean - enableCloneNode: boolean - enableContains: boolean - enableMutationObserver: boolean + enableInnerHTML?: boolean + enableSizeAPIs?: boolean + enableAdjacentHTML?: boolean + enableTemplateContent?: boolean + enableCloneNode?: boolean + enableContains?: boolean + enableMutationObserver?: boolean } export interface IMiniAppConfig { + /** 用于控制是否生成 js、css 对应的 sourceMap (默认值:watch 模式下为 true,否则为 false) */ + enableSourceMap?: boolean + /** 默认值:'cheap-module-source-map', 具体参考[Webpack devtool 配置](https://webpack.js.org/configuration/devtool/#devtool) */ sourceMapType?: string @@ -42,7 +45,7 @@ export interface IMiniAppConfig { /** * 编译前清空输出目录 * @since Taro v3.6.9 - * @description + * @description * - 默认清空输出目录,可设置 clean: false 不清空 * - 可设置 clean: { keep: ['project.config.json'] } 保留指定文件 * - 注意 clean.keep 不支持函数 @@ -100,4 +103,10 @@ export interface IMiniAppConfig { /** 插件内部使用 */ runtime?: Runtime + + /** 体验式功能 */ + experimental?: { + /** 是否开启编译模式 */ + compileMode?: boolean + } } diff --git a/packages/taro/types/compile/config/rn.d.ts b/packages/taro/types/compile/config/rn.d.ts index 221a8660976c..a7a481e261fd 100644 --- a/packages/taro/types/compile/config/rn.d.ts +++ b/packages/taro/types/compile/config/rn.d.ts @@ -20,7 +20,7 @@ export interface IRNConfig { /** [less](https://lesscss.org/usage/#less-options) 相关配置 */ less?: IOption - /** [stylus](https://github.com/NervJS/taro/blob/next/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */ + /** [stylus](https://github.com/NervJS/taro/blob/main/packages/taro-rn-style-transformer/README.md#rnstylus) 相关配置 */ stylus?: IOption /** 配置 postcss 相关插件 */ diff --git a/packages/taro/types/compile/config/util.d.ts b/packages/taro/types/compile/config/util.d.ts index ff56534f3476..7729464a10a6 100644 --- a/packages/taro/types/compile/config/util.d.ts +++ b/packages/taro/types/compile/config/util.d.ts @@ -89,7 +89,7 @@ export interface ICopyOptions { from: string to: string ignore?: string[] - transform?: Function + transform?: Func watch?: boolean }[] options: { diff --git a/packages/taro/types/global.d.ts b/packages/taro/types/global.d.ts index 5081d72c8466..85410b1fb434 100644 --- a/packages/taro/types/global.d.ts +++ b/packages/taro/types/global.d.ts @@ -2,6 +2,7 @@ declare namespace TaroGeneral { type IAnyObject = Record type Optional = F extends (arg: infer P) => infer R ? (arg?: P) => R : F type OptionalInterface = { [K in keyof T]: Optional } + type TFunc = (...args: any[]) => any /** 事件监听函数 */ type EventCallback = ( /** 触发事件参数 */ @@ -418,7 +419,8 @@ declare namespace TaroGeneral { WEB = 'WEB', RN = 'RN', HARMONY = 'HARMONY', - QUICKAPP = 'QUICKAPP' + QUICKAPP = 'QUICKAPP', + HARMONYHYBRID = 'HARMONYHYBRID' } type TDeviceRatio = Record diff --git a/packages/taro/types/index.d.ts b/packages/taro/types/index.d.ts index 624acd3e2de4..5623c3254ae0 100644 --- a/packages/taro/types/index.d.ts +++ b/packages/taro/types/index.d.ts @@ -3,51 +3,64 @@ * * 目录结构 * ├── api 小程序端能力 API - * │ ├── ad + * │   ├── ad * │ │ └── index.d.ts 广告 API - * │ ├── alipay + * │   ├── ai + * │   │   ├── face.d.ts 人脸检测 API + * │   │   ├── inference.d.ts AI 推理 API + * │   │   └── visionkit.d.ts 视觉算法 API + * │   ├── alipay * │ │ └── index.d.ts 支付宝小程序 API - * │ ├── base + * │   ├── base * │ │ ├── index.d.ts 基础 API + * │   │   ├── crypto.d.ts 基础 -> 加密 API * │ │ ├── debug.d.ts 基础 -> 调试 API + * │   │   ├── env.d.ts 基础 -> ENV + * │   │   ├── performance.d.ts * │ │ ├── system.d.ts 基础 -> 系统 API - * │ │ ├── update.d.ts 基础 -> 更新 API - * │ │ ├── weapp 基础 -> 小程序 API - * │ │ │ ├── life-cycle.d.ts 基础 -> 小程序 API -> 生命周期 - * │ │ │ └── app-event.d.ts 基础 -> 小程序 API -> 应用级事件 - * │ │ └── env.d.ts 基础 -> ENV - * │ ├── canvas + * │   │   ├── update.d.ts 基础 -> 更新 API + * │   │   └── weapp 基础 -> 小程序 API + * │   │   ├── app-event.d.ts 基础 -> 小程序 API -> 应用级事件 + * │   │   └── life-cycle.d.ts 基础 -> 小程序 API -> 生命周期 + * │   ├── canvas * │ │ └── index.d.ts 画布 API - * │ ├── cloud + * │   ├── cloud * │ │ └── index.d.ts 微信小程序云开发 API - * │ ├── device + * │   ├── data-analysis + * │ │ └── index.d.ts 数据分析 API + * │   ├── device * │ │ ├── accelerometer.d.ts 设备 -> 加速计 API + * │   │   ├── accessibility.d.ts 设备 -> 无障碍 API * │ │ ├── battery.d.ts 设备 -> 电量 API - * │ │ ├── ble.d.ts 设备 -> 低功耗蓝牙 API - * │ │ ├── bluetooth.d. 设备 -> 蓝牙 API + * │   │   ├── bluetooth-ble.d.ts 设备 -> 蓝牙-低功耗中心设备 API + * │   │   ├── bluetooth-peripheral.d.ts 设备 -> 蓝牙-低功耗外围设备 API + * │   │   ├── bluetooth.d.ts 设备 -> 蓝牙-通用 API + * │   │   ├── calendar.d.ts 设备 -> 日历 API * │ │ ├── clipboard.d.ts 设备 -> 剪贴板 API * │ │ ├── compass.d.ts 设备 -> 罗盘 API * │ │ ├── contact.d.ts 设备 -> 联系人 API - * │ │ ├── motion.d.ts 设备 -> 设备方向 API * │ │ ├── gyroscope.d.ts 设备 -> 陀螺仪 API * │ │ ├── iBeacon.d.ts 设备 -> iBeacon API - * │ │ ├── network.d.ts 设备 -> 网络 API - * │ │ ├── nfc.d.ts 设备 -> NFC API - * │ │ ├── performance.d.ts 设备 -> 性能 API + * │   │   ├── keyboard.d.ts 设备 -> 键盘 API + * │   │   ├── memory.d.ts 设备 -> 内存 API + * │ │ ├── motion.d.ts 设备 -> 设备方向 API + * │   │   ├── network.d.ts 设备 -> 网络 API + * │   │   ├── nfc.d.ts 设备 -> NFC 读写 API * │ │ ├── phone.d.ts 设备 -> 电话 API * │ │ ├── scan.d.ts 设备 -> 扫码 API * │ │ ├── screen.d.ts 设备 -> 屏幕 API + * │   │   ├── sms.d.ts 设备 -> 短信 API * │ │ ├── vibrate.d.ts 设备 -> 振动 API * │ │ └── wifi.d.ts 设备 -> Wi-Fi API - * │ ├── ext + * │   ├── ext * │ │ └── index.d.ts 第三方平台 API - * │ ├── files + * │   ├── files * │ │ └── index.d.ts 文件 API - * │ ├── framework + * │   ├── framework * │ │ └── index.d.ts 小程序框架 API - * │ ├── location + * │   ├── location * │ │ └── index.d.ts 位置 API - * │ ├── media + * │   ├── media * │ │ ├── audio.d.ts 媒体 -> 音频 API * │ │ ├── background-audio.d.ts 媒体 -> 背景音频 API * │ │ ├── camera.d.ts 媒体 -> 相机 API @@ -55,49 +68,72 @@ * │ │ ├── image.d.ts 媒体 -> 图片 API * │ │ ├── live.d.ts 媒体 -> 实时音视频 API * │ │ ├── map.d.ts 媒体 -> 地图 API + * │   │   ├── media-recorder.d.ts 媒体 -> 画面录制器 API * │ │ ├── recorder.d.ts 媒体 -> 录音 API - * │ │ ├── video.d.ts 媒体 -> 视频 API + * │   │   ├── video-decoder.d.ts 媒体 -> 视频解码器 API * │ │ └── video-processing.d.ts 媒体 -> 音视频合成 API - * │ ├── network + * │ │ ├── video.d.ts 媒体 -> 视频 API + * │   │   └── voip.d.ts 媒体 -> 实时语音 API + * │   ├── navigate + * │   │   └── index.d.ts 跳转 API + * │   ├── network * │ │ ├── download.d.ts 网络 -> 下载 API * │ │ ├── mdns.d.ts 网络 -> mDNS API * │ │ ├── request.d.ts 网络 -> 发起请求 API + * │   │   ├── tcp.d.ts 网络 -> TCP 通信 API * │ │ ├── udp.d.ts 网络 -> UDP 通信 API * │ │ ├── upload.d.ts 网络 -> 上传 API * │ │ └── websocket.d.ts 网络 -> WebSocket API - * │ ├── open-api + * │   ├── open-api * │ │ ├── account.d.ts 开放接口 -> 账号信息 API * │ │ ├── address.d.ts 开放接口 -> 收货地址 API * │ │ ├── authorize.d.ts 开放接口 -> 授权 API * │ │ ├── card.d.ts 开放接口 -> 卡券 API - * │ │ ├── data-analysis.d.ts 开放接口 -> 数据分析 API + * | | ├── channels.d.ts 开放接口 -> 视频号 API + * | | ├── customer-service.d.ts 开放接口 -> 微信客服 API + * | | ├── device-voip.d.ts 开放接口 -> 音视频通话 API * │ │ ├── facial.d.ts 开放接口 -> 人脸识别 API // 在微信小程序文档已找不到 + * │ │ ├── favorites.d.ts 开放接口 -> 收藏 API + * │ │ ├── group.d.ts 开放接口 -> 微信群 API * │ │ ├── invoice.d.ts 开放接口 -> 发票 API + * │   │   ├── license-plate.d.ts 开放接口 -> 车牌 API * │ │ ├── login.d.ts 开放接口 -> 登录 API - * │ │ ├── navigate.d.ts 开放接口 -> 小程序跳转 API - * │ │ ├── payment.d.ts 开放接口 -> 支付 API - * │ │ ├── report.d.ts 开放接口 -> 数据上报 API + * │ │ ├── my-miniprogram.d.ts 开放接口 -> 我的小程序 API + * │ │ ├── privacy.d.ts 开放接口 -> 隐私信息授权 API + * │ │ ├── redpackage.d.ts 开放接口 -> 微信红包 API * │ │ ├── settings.d.ts 开放接口 -> 设置 API * │ │ ├── soter.d.ts 开放接口 -> 生物认证 API + * │ │ ├── sticker.d.ts 开放接口 -> 微信表情 API * | | ├── subscribe-message.d.ts 开放接口 -> 订阅消息 API * │ │ ├── user-info.d.ts 开放接口 -> 用户信息 API - * │ │ ├── customer-service.d.ts 开放接口 -> 微信客服 API * │ │ └── werun.d.ts 开放接口 -> 微信运动 API - * │ ├── route + * │   ├── payment + * │   │   └── index.d.ts 支付 API + * │   ├── qq + * │   │   └── index.d.ts QQ 小程序 API + * │   ├── route * │ │ └── index.d.ts 路由 API - * │ ├── share + * │   ├── share * │ │ └── index.d.ts 转发 API - * │ ├── storage + * │   ├── skyline + * │ │ └── index.d.ts 微信 Skyline API + * │   ├── storage * │ │ ├── background-fetch.d.ts 数据缓存 -> 后台获取 API - * │ │ └── index.d.ts 数据缓存 API - * │ ├── swan + * │   │   ├── cache-manager.d.ts 数据缓存 -> 缓存管理 API + * │   │   └── index.d.ts 数据缓存 API + * │   ├── swan + * │   │   ├── bookshelf.d.ts 百度小程序 -> 书架 API + * │   │   ├── download-package.d.ts 百度小程序 -> 下载包 API * │ │ └── index.d.ts 百度小程序 API - * │ ├── ui + * │   │   └── pay.d.ts 百度小程序 -> 支付 API + * │   ├── taro.extend.d.ts Taro 扩展 API 类型定义 + * │   ├── taro.hooks.d.ts Taro Hooks 类型定义 + * │   ├── ui * │ │ ├── animation.d.ts 界面 -> 动画 API * │ │ ├── background.d.ts 界面 -> 背景 API * │ │ ├── custom-component.d.ts 界面 -> 自定义组件 API * │ │ ├── fonts.d.ts 界面 -> 字体 API - * │ │ ├── keyboard.d.ts 界面 -> 键盘 API + * │   │   ├── interaction.d.ts 界面 -> 交互 API * │ │ ├── menu.d.ts 界面 -> 菜单 API * │ │ ├── navigation-bar.d.ts 界面 -> 导航栏 API * │ │ ├── pull-down-refresh.d.ts 界面 -> 下拉刷新 API @@ -105,14 +141,25 @@ * │ │ ├── sticky.d.ts 界面 -> 置顶 API * │ │ ├── tab-bar.d.ts 界面 -> TabBar API * │ │ ├── window.d.ts 界面 -> 窗口 API - * │ │ └── interaction.d.ts 界面 -> 交互 API - * │ ├── worker + * │   ├── worker * │ │ └── index.d.ts Worker API - * │ ├── wxml + * │   └── wxml * │ │ └── index.d.ts WXML API - * │ ├── taro.extend.d.ts Taro 扩展 API 类型定义 - * │ └── taro.hooks.d.ts Taro Hooks 类型定义 + * ├── compile + * │   ├── compiler.d.ts + * │   ├── config + * │   │   ├── h5.d.ts + * │   │   ├── index.d.ts + * │   │   ├── manifest.d.ts + * │   │   ├── mini.d.ts + * │   │   ├── project.d.ts + * │   │   ├── rn.d.ts + * │   │   └── util.d.ts + * │   ├── hooks.d.ts Taro Hooks 类型定义 + * │   └── index.d.ts + * ├── global.d.ts * ├── index.d.ts 此文件 + * ├── taro.api.d.ts * ├── taro.component.d.ts Taro Component 类型定义 * ├── taro.config.d.ts Taro 小程序 App 与 Window 设置类型定义 * └── taro.lifecycle.d.ts Taro 生命周期类型定义 @@ -124,6 +171,7 @@ /// /// /// +/// /// /// @@ -143,6 +191,6 @@ declare namespace Taro { interface TaroStatic {} } declare global { - const defineAppConfig: (config: Taro.Config) => Taro.Config - const definePageConfig: (config: Taro.Config) => Taro.Config + const defineAppConfig: (config: Taro.AppConfig) => Taro.AppConfig + const definePageConfig: (config: Taro.PageConfig) => Taro.Config } diff --git a/packages/taro/types/taro.api.d.ts b/packages/taro/types/taro.api.d.ts index f15d6a841122..9b086e379779 100644 --- a/packages/taro/types/taro.api.d.ts +++ b/packages/taro/types/taro.api.d.ts @@ -59,26 +59,30 @@ /// /// /// -/// + /// -/// -/// -/// /// +/// /// -/// -/// -/// -/// -/// -/// -/// -/// /// +/// /// +/// +/// /// +/// +/// +/// +/// /// -/// +/// +/// +/// +/// +/// +/// +/// + /// /// /// @@ -109,13 +113,18 @@ /// /// /// +/// /// -/// /// /// + +/// +/// /// +/// + /// /// diff --git a/packages/taro/types/taro.component.d.ts b/packages/taro/types/taro.component.d.ts index 2fd78272dff6..0d0a4c502728 100644 --- a/packages/taro/types/taro.component.d.ts +++ b/packages/taro/types/taro.component.d.ts @@ -51,6 +51,7 @@ declare module './index' { onReachBottom?(): void onResize?(opt: PageResizeObject): void onShareAppMessage?(opt: ShareAppMessageObject): ShareAppMessageReturn + onShareTimeline?(): ShareTimelineReturnObject onTabItemTap?(opt: TabItemTapObject): void onTitleClick?(): void onUnload(): void @@ -138,5 +139,7 @@ declare module './index' { path?: string /** 页面的组件选项 */ options?: Record + /** 获得一个 EventChannel 对象,用于页面间通讯 */ + getOpenerEventChannel?(): Record } } diff --git a/packages/taro/types/taro.config.d.ts b/packages/taro/types/taro.config.d.ts index faf7ad5b0ece..b9f3821ce16d 100644 --- a/packages/taro/types/taro.config.d.ts +++ b/packages/taro/types/taro.config.d.ts @@ -10,9 +10,11 @@ declare module './index' { */ navigationBarBackgroundColor?: string /** 导航栏标题颜色,仅支持 black/white + * 当 app.json 中配置 darkmode 为 true 时可通过变量的形式配置 + * @see: https://developers.weixin.qq.com/miniprogram/dev/framework/ability/darkmode.html * @default: "white" */ - navigationBarTextStyle?: 'white' | 'black' + navigationBarTextStyle?: 'white' | 'black' | string /** 导航栏标题文字内容 */ navigationBarTitleText?: string /** 导航栏样式,仅支持以下值: @@ -31,9 +33,11 @@ declare module './index' { */ backgroundColor?: string /** 下拉背景字体、loading 图的样式,仅支持 dark/light + * 当 app.json 中配置 darkmode 为 true 时可通过变量的形式配置 + * @see: https://developers.weixin.qq.com/miniprogram/dev/framework/ability/darkmode.html * @default: "dark" */ - backgroundTextStyle?: 'dark' | 'light' + backgroundTextStyle?: 'dark' | 'light' | string /** 顶部窗口的背景色,仅 iOS 支持 * @default: "#ffffff" */ @@ -175,6 +179,12 @@ declare module './index' { * @default false */ enableShareTimeline?: boolean + /** + * 页面是否需要使用 \ 和 \ 组件 + * @default false + * @support weapp, alipay + */ + enablePageMeta?: boolean /** 页面自定义组件配置 * @see https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/ */ @@ -363,16 +373,41 @@ declare module './index' { interface RenderOptions { skyline: { - /** - * 开启默认Block布局 + /** 开启默认Block布局 * @see https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/wxss.html#%E5%BC%80%E5%90%AF%E9%BB%98%E8%AE%A4Block%E5%B8%83%E5%B1%80 + * @supported weapp */ defaultDisplayBlock?: boolean - /** - * 关闭 Skyline AB 实验 + /** 关闭 Skyline AB 实验 * @see https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/migration/release.html#%E5%8F%91%E5%B8%83%E4%B8%8A%E7%BA%BF + * @supported weapp */ disableABTest?: boolean + /** 基础库最低版本 + * @supported weapp + */ + sdkVersionBegin?: string + /** 基础库最高版本 + * @supported weapp + */ + sdkVersionEnd?: string + /** iOS 微信最低版本 + * @supported weapp + */ + iosVersionBegin?: string + /** iOS 微信最高版本 + * @supported weapp + */ + iosVersionEnd?: string + /** 安卓微信最低版本 + * @supported weapp + */ + androidVersionBegin?: string + /** 安卓微信最高版本 + * @supported weapp + */ + androidVersionEnd?: string + [key: string]: unknown } } diff --git a/packages/taro/types/taro.lifecycle.d.ts b/packages/taro/types/taro.lifecycle.d.ts index b5bd97f3ee14..6d9f94eea0cd 100644 --- a/packages/taro/types/taro.lifecycle.d.ts +++ b/packages/taro/types/taro.lifecycle.d.ts @@ -56,9 +56,12 @@ declare module './index' { } interface PageResizeObject { + deviceOrientation?: 'portrait' | 'landscape' size: { windowWidth: number windowHeight: number + screenWidth?: number + screenHeight?: number } } diff --git a/packages/taro/types/taro.runtime.d.ts b/packages/taro/types/taro.runtime.d.ts new file mode 100644 index 000000000000..b083b300b977 --- /dev/null +++ b/packages/taro/types/taro.runtime.d.ts @@ -0,0 +1,9 @@ +import type { options } from '@tarojs/runtime' + +import Taro from './index' + +declare module './index' { + interface TaroStatic { + options: typeof options + } +}