Skip to content

Commit

Permalink
docs: 更新 label 与 3.x 文档
Browse files Browse the repository at this point in the history
  • Loading branch information
ZakaryCode committed Jul 27, 2023
1 parent d79a086 commit df6b001
Show file tree
Hide file tree
Showing 54 changed files with 200 additions and 481 deletions.
4 changes: 3 additions & 1 deletion docs/use-h5.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ config = {
postcss: {
htmltransform: {
enable: true,
removeCursorStyle: false,
config: {
removeCursorStyle: false,
},
},
},
},
Expand Down
3 changes: 2 additions & 1 deletion sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,8 @@ module.exports = {
'apis/cloud/DB'
],
'Alipay': [
'apis/alipay/getOpenUserInfo'
'apis/alipay/getOpenUserInfo',
'apis/alipay/tradePay',
],
'QQ': [
'apis/qq/openQzonePublish'
Expand Down
46 changes: 46 additions & 0 deletions versioned_docs/version-3.x/apis/alipay/tradePay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Taro.tradePay(Option)
sidebar_label: tradePay
---

此接口是用于发起支付的 API,此 API 暂仅支持企业支付宝小程序使用

支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="支付宝小程序" src={require('@site/static/img/platform/alipay.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>

> [参考文档](https://opendocs.alipay.com/mini/api/openapi-pay)
## 类型

```tsx
(Option: Option) => Promise<SuccessCallbackResult>
```

## 参数

### Option

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | :---: | --- |
| tradeNO | `string` || 接入小程序支付时传入此参数。此参数为支付宝交易号,注意参数有大小写区分(调用 小程序支付 时必填) |
| orderStr | `string` || 完整的支付参数拼接成的字符串,从服务端获取(调用 支付宝预授权 时必填) |
| success | `(res: SuccessCallbackResult) => void` || 接口调用成功的回调函数 |
| fail | `(res: TaroGeneral.CallbackResult) => void` || 接口调用失败的回调函数 |
| complete | `(res: TaroGeneral.CallbackResult) => void` || 接口调用结束的回调函数(调用成功、失败都会执行) |

### ResultCode

| 参数 | 说明 |
| --- | --- |
| 4 | 无权限调用(N22104) |
| 9000 | 订单处理成功 |
| 8000 | 正在处理中。支付结果未知(有可能已经支付成功) |
| 4000 | 订单处理失败 |
| 6001 | 用户中途取消 |
| 6002 | 网络连接出错 |
| 6004 | 处理结果未知(有可能已经成功) |

### SuccessCallbackResult

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| response | `{ resultCode: ResultCode; }` | success 回调函数会携带一个 Object 类型的对象,其属性如下: |
2 changes: 1 addition & 1 deletion versioned_docs/version-3.x/apis/base/canIUse.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_label: canIUse

判断小程序的 API,回调,参数,组件等是否在当前版本可用。

支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="字节跳动小程序" src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="抖音小程序" src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>

> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/base/wx.canIUse.html)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Taro.getUserCryptoManager().getRandomValues({

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | :---: | --- |
| success | `(res: TaroGeneral.CallbackResult) => void` || 接口调用成功的回调函数 |
| success | `(res: SuccessCallbackResult) => void` || 接口调用成功的回调函数 |
| fail | `(res: TaroGeneral.CallbackResult) => void` || 接口调用失败的回调函数 |
| complete | `(res: SuccessCallbackResult) => void` || 接口调用结束的回调函数(调用成功、失败都会执行) |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_label: addPhoneCalendar

向系统日历添加事件

支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="字节跳动小程序" src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="抖音小程序" src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>

> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/calendar/wx.addPhoneCalendar.html)
Expand Down
8 changes: 5 additions & 3 deletions versioned_docs/version-3.x/apis/media/image/previewImage.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ sidebar_label: previewImage
| 参数 | 类型 | 必填 | 说明 |
| --- | --- | :---: | --- |
| urls | `string[]` || 需要预览的图片链接列表。 |
| current | `string` || 当前显示图片的链接 |
| showmenu | `boolean` || <br />support: weapp 最低版本:2.13.0。是否显示长按菜单,默认值:true |
| referrerPolicy | `string` || <br />support: weapp 最低版本:2.13.0。origin: 发送完整的referrer; no-referrer: 不发送。格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本;默认值:no-referrer |
| current | string or number || 微信端为当前显示图片的链接,支付宝端为当前显示图片的索引值 |
| enablesavephoto | `boolean` || 是否支持长按下载图片<br />API 支持度: alipay 基础库: 1.13.0 |
| enableShowPhotoDownload | `boolean` || 是否在右下角显示下载入口<br />API 支持度: alipay 基础库: 1.13.0 |
| showmenu | `boolean` || <br />API 支持度: weapp 最低版本:2.13.0。是否显示长按菜单,默认值:true |
| referrerPolicy | `string` || <br />API 支持度: weapp 最低版本:2.13.0。origin: 发送完整的referrer; no-referrer: 不发送。格式固定为 https://servicewechat.com/{appid}/{version}/page-frame.html,其中 {appid} 为小程序的 appid,{version} 为小程序的版本号,版本号为 0 表示为开发版、体验版以及审核版本,版本号为 devtools 表示为开发者工具,其余为正式版本;默认值:no-referrer |
| complete | `(res: TaroGeneral.CallbackResult) => void` || 接口调用结束的回调函数(调用成功、失败都会执行) |
| fail | `(res: TaroGeneral.CallbackResult) => void` || 接口调用失败的回调函数 |
| success | `(res: TaroGeneral.CallbackResult) => void` || 接口调用成功的回调函数 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_label: saveImageToPhotosAlbum

保存图片到系统相册。需要[用户授权](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html) scope.writePhotosAlbum

支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="百度小程序" src={require('@site/static/img/platform/swan.png').default} className="icon_platform" width="25px"/> <img title="支付宝小程序" src={require('@site/static/img/platform/alipay.png').default} className="icon_platform" width="25px"/> <img title="字节跳动小程序" src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="百度小程序" src={require('@site/static/img/platform/swan.png').default} className="icon_platform" width="25px"/> <img title="支付宝小程序" src={require('@site/static/img/platform/alipay.png').default} className="icon_platform" width="25px"/> <img title="抖音小程序" src={require('@site/static/img/platform/tt.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>

> [参考文档](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.saveImageToPhotosAlbum.html)
Expand Down
20 changes: 18 additions & 2 deletions versioned_docs/version-3.x/apis/network/request/request.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ sidebar_label: request
| url | `string` | | 是 | 开发者服务器接口地址 |
| data | `U` | | 否 | 请求的参数 |
| header | `TaroGeneral.IAnyObject` | | 否 | 设置请求的 header,header 中不能设置 Referer。<br /><br />`content-type` 默认为 `application/json` |
| timeout | `number` | `2000` | 否 | 超时时间,单位为毫秒<br />API 支持度: weapp, h5, tt |
| method | `keyof Method` | `GET` | 否 | HTTP 请求方法 |
| timeout | `number` | `2000` | 否 | 超时时间,单位为毫秒<br />API 支持度: weapp, h5, tt, alipay |
| method | `keyof Method` | `"GET"` | 否 | HTTP 请求方法 |
| dataType | `string` | | 否 | 返回的数据格式 |
| responseType | `keyof ResponseType` | | 否 | 响应的数据类型 |
| enableHttp2 | `boolean` | `false` | 否 | 开启 http2<br />API 支持度: weapp |
Expand All @@ -44,6 +44,9 @@ sidebar_label: request
| enableHttpDNS | `boolean` | `false` | 否 | 是否开启 HttpDNS 服务。如开启,需要同时填入 httpDNSServiceId 。 HttpDNS 用法详见 移动解析HttpDNS<br />API 支持度: weapp |
| httpDNSServiceId | `string` | | 否 | HttpDNS 服务商 Id。 HttpDNS 用法详见 移动解析HttpDNS<br />API 支持度: weapp |
| enableChunked | `boolean` | `false` | 否 | 开启 transfer-encoding chunked。<br />API 支持度: weapp |
| forceCellularNetwork | `boolean` | `false` | 否 | wifi下使用移动网络发送请求<br />API 支持度: weapp |
| enableCookie | `boolean` | `false` | 否 | headers 中设置 cookie 字段是否生效。如果为 false,则 headers 中的 cookie 字段将被忽略,请求头中将包含服务端上一次返回的 cookie(如果有)。<br />API 支持度: alipay 支付宝: 10.2.33+ |
| referrerStrategy | `keyof ReferrerStrategy` | `"querystring"` | 否 | referer 策略,用于控制当前请求 header 对象中 referer 字段格式。该参数默认值可通过 app.json 中的配置进行修改。<br />API 支持度: alipay 支付宝: 10.3.50+ APPX: 2.8.7 开发者工具: 3.5.1<br />[参考地址](https://opendocs.alipay.com/mini/api/owycmh#referrerStrategy%20%E5%8F%82%E6%95%B0%E8%AF%B4%E6%98%8E) |
| success | `(result: SuccessCallbackResult<T>) => void` | | 否 | 接口调用成功的回调函数 |
| fail | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用失败的回调函数 |
| complete | `(res: TaroGeneral.CallbackResult) => void` | | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
Expand Down Expand Up @@ -78,6 +81,9 @@ sidebar_label: request
| 参数 | 说明 |
| --- | --- |
| json | 返回的数据为 JSON,返回后会对返回的数据进行一次 JSON.parse<br />其他: 不对返回的内容进行 JSON.parse |
| text | 返回的数据为文本字符串<br />API 支持度: alipay |
| base64 | 返回的数据将转换为 base64 格式字符串<br />API 支持度: alipay |
| arraybuffer | 返回的数据将保持 ArrayBuffer 数据<br />API 支持度: alipay 支付宝: 10.1.70+ |

### Method

Expand Down Expand Up @@ -136,6 +142,16 @@ HTTP 请求方法
| force-cache | 浏览器在其HTTP缓存中寻找匹配的请求 |
| only-if-cached | 浏览器在其HTTP缓存中寻找匹配的请求 |

### ReferrerStrategy

referer 策略

| 参数 | 说明 |
| --- | --- |
| index | referer 值为 https://{appid}.hybrid.alipay-eco.com/{appid}/{version}/index.html |
| page | 保留 page(pages/xxx/yyy),referer 值为 https://{appid}.hybrid.alipay-eco.com/{appid}/{version}/index.html#{page} |
| querystring | 默认值。会将发起请求时所在页面的 URL 作为 referer 值,会保留 page(pages/xxx/yyy)和 querystring(x=1&y=2)并可能有框架添加的其他参数,referer 值为 https://{appid}.hybrid.alipay-eco.com/{appid}/{version}/index.html#{page}?{querysrtring}{框架其他参数} |

## 示例代码

### 示例 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@ sidebar_label: chooseAddress

| 参数 | 类型 | 必填 | 说明 |
| --- | --- | :---: | --- |
| complete | `(res: TaroGeneral.CallbackResult) => void` || 接口调用结束的回调函数(调用成功、失败都会执行) |
| complete | `(res: SuccessCallbackResult) => void` || 接口调用结束的回调函数(调用成功、失败都会执行) |
| fail | `(res: TaroGeneral.CallbackResult) => void` || 接口调用失败的回调函数 |
| success | `(result: SuccessCallbackResult) => void` || 接口调用成功的回调函数 |

### SuccessCallbackResult

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| userName | `string` | 收货人姓名 |
| postalCode | `string` | 邮编 |
| provinceName | `string` | 国标收货地址第一级地址 |
| cityName | `string` | 国标收货地址第二级地址 |
| countyName | `string` | 国标收货地址第三级地址 |
| streetName | `string` | 国标收货地址第四级地址 |
| detailInfo | `string` | 详细收货地址信息 |
| errMsg | `string` | 错误信息 |
| detailInfoNew | `string` | 新选择器详细收货地址信息 |
| nationalCode | `string` | 收货地址国家码 |
| postalCode | `string` | 邮编 |
| provinceName | `string` | 国标收货地址第一级地址 |
| telNumber | `string` | 收货人手机号码 |
| userName | `string` | 收货人姓名 |

## 示例代码

Expand Down
10 changes: 10 additions & 0 deletions versioned_docs/version-3.x/apis/taro.extend/getEnvInfoSync.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Taro.getEnvInfoSync()
sidebar_label: getEnvInfoSync
---

## 类型

```tsx
() => { microapp: { mpVersion: string; envType: string; appId: string; }; plugin: Record<string, unknown>; common: { USER_DATA_PATH: string; location: string; launchFrom: string; schema: string; }; }
```
2 changes: 1 addition & 1 deletion versioned_docs/version-3.x/apis/taro.extend/getTabBar.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ sidebar_label: getTabBar

获取自定义 TabBar 对应的 React 或 Vue 组件实例

支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>
支持情况:<img title="微信小程序" src={require('@site/static/img/platform/weapp.png').default} className="icon_platform" width="25px"/> <img title="京东小程序" src={require('@site/static/img/platform/jd.png').default} className="icon_platform" width="25px"/> <img title="H5" src={require('@site/static/img/platform/h5.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="React Native" src={require('@site/static/img/platform/rn.png').default} className="icon_platform icon_platform--not-support" width="25px"/> <img title="Harmony" src={require('@site/static/img/platform/harmony.png').default} className="icon_platform icon_platform--not-support" width="25px"/>

## 类型

Expand Down
12 changes: 2 additions & 10 deletions versioned_docs/version-3.x/components/base/icon.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@ ComponentType<IconProps>

## 示例代码

import { ReactIcon, VueIcon } from '@site/static/icons'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'

<Tabs
defaultValue="React"
values={[
{
"label": "React",
"value": "React"
},
{
"label": "Vue",
"value": "Vue"
}
]}>
values={[{ label: <ReactIcon />, value: "React" }, { label: <VueIcon />, value: "Vue" }]}>
<TabItem value="React">

```tsx
Expand Down
12 changes: 2 additions & 10 deletions versioned_docs/version-3.x/components/base/progress.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@ ComponentType<ProgressProps>

## 示例代码

import { ReactIcon, VueIcon } from '@site/static/icons'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'

<Tabs
defaultValue="React"
values={[
{
"label": "React",
"value": "React"
},
{
"label": "Vue",
"value": "Vue"
}
]}>
values={[{ label: <ReactIcon />, value: "React" }, { label: <VueIcon />, value: "Vue" }]}>
<TabItem value="React">

```tsx
Expand Down
14 changes: 3 additions & 11 deletions versioned_docs/version-3.x/components/base/rich-text.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,13 @@ ComponentType<RichTextProps>

## 示例代码

import { ReactIcon, VueIcon } from '@site/static/icons'
import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'

<Tabs
defaultValue="React"
values={[
{
"label": "React",
"value": "React"
},
{
"label": "Vue",
"value": "Vue"
}
]}>
values={[{ label: <ReactIcon />, value: "React" }, { label: <VueIcon />, value: "Vue" }]}>
<TabItem value="React">

```tsx
Expand Down Expand Up @@ -112,7 +104,7 @@ export default {

### API 支持度

| API | 微信小程序 | 百度小程序 | 支付宝小程序 | 字节跳动小程序 | QQ 小程序 | H5 | React Native | Harmony |
| API | 微信小程序 | 百度小程序 | 支付宝小程序 | 抖音小程序 | QQ 小程序 | H5 | React Native | Harmony |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| RichTextProps.userSelect | ✔️ | | | | | ✔️ | | |
| RichTextProps.nodes | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Expand Down
Loading

0 comments on commit df6b001

Please sign in to comment.