Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 54 additions & 31 deletions packages/tdesign-miniprogram/site/docs/getting-started.en-US.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
---
title: Wechat MiniProgram
description: TDesign MiniProgram is a UI component library for Wechat MiniProgram.
title: WeChat MiniProgram
description: TDesign is a UI component library for WeChat Mini Programs.
spline: explain
---

## Preview

Please use WeChat to scan the QR code to preview the TDesign MiniProgram example. ↓
Scan the QR code with WeChat to preview the Mini Program component demo. ↓
<br/>

<img width="260" src="https://tdesign.gtimg.com/site/qrcode.jpeg" />

## Before you start

## Before use

Before using it, please make sure you have studied WeChat’s official [Simple Tutorial on Mini Programs](https://developers.weixin.qq.com/miniprogram/dev/framework/) and [Introduction to Custom Components](https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/).
Before using the library, make sure you have read WeChat’s official [Simple Tutorial on Mini Programs](https://developers.weixin.qq.com/miniprogram/dev/framework/) and [Introduction to Custom Components](https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/).

## Installation

### npm
### Install with NPM

TDesign MiniProgram already supports using NPM to install third-party packages. For details, see [NPM Support](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html?search-key=npm)
Mini Programs support installing third-party packages with NPM. For details, see [NPM Support](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html?search-key=npm)

```bash
npm i tdesign-miniprogram -S --production
```

> After installation, npm needs to be built in WeChat developer tools: `tool - build npm`.(If `NPM packages not found` appears during the build, please go to the `project.config.json` file to add the `packNpmManually` and `packNpmRelationList` configuration items. For details, see [NPM Support](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html?search-key=npm))
> After installation, build npm packages in WeChat DevTools: `Tools - Build npm`. (If `NPM packages not found` appears during the build, add `packNpmManually` and `packNpmRelationList` to `project.config.json`. For details, see [NPM Support](https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html?search-key=npm).)

> After the build is successful, check the box `Compile JS to ES5`
> After a successful build, check `Compile JS to ES5`.
> <br/>
><img width="200" src="https://tdesign.gtimg.com/miniprogram/docs/getting-started.png" />
> <img width="200" src="https://tdesign.gtimg.com/miniprogram/docs/getting-started.png" />

## Modify app.json
## Update `app.json`

Remove `"style": "v2"` in `app.json`.
Remove `"style": "v2"` from `app.json`.

> Because [v2 configuration](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#style) means enabling a new version of component styles, it will cause TDesign component styles to be disordered.
> This [configuration](https://developers.weixin.qq.com/miniprogram/dev/reference/configuration/app.html#style) enables the new component style mode, which can break TDesign component styles.

## Modify tsconfig.json
## Update `tsconfig.json`

If you use `typescript` to develop, you need to modify `tsconfig.json` to specify `paths`
If you use `TypeScript`, update `tsconfig.json` and specify `paths`:

```json
{
Expand All @@ -52,7 +51,7 @@ If you use `typescript` to develop, you need to modify `tsconfig.json` to specif

## Use components

Taking the button component as an example, you only need to introduce the custom component corresponding to the button in the `JSON` file.
Take the button component as an example: you only need to register the corresponding custom component in the `JSON` file.

```json
{
Expand All @@ -62,34 +61,58 @@ Taking the button component as an example, you only need to introduce the custom
}
```

Then you can use the component directly in wxml.
Then you can use the component directly in `wxml`.

```html
<t-button theme="primary">按钮</t-button>
<t-button theme="primary">Button</t-button>
```

## Preview in developer tools
## Preview in WeChat DevTools

```bash
# Install project dependencies
npm install

# compile
# Build components
npm run dev
```

Open [WeChat Developer Tools](https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html) and add the `_example` directory to preview the example.
Open [WeChat DevTools](https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html), then add the `_example` directory to preview the demo.

## About base library version

The minimum base library version is `^2.12.0`.

### Recommended base library version strategy

- **Development and debugging**: use the "latest stable" version in WeChat DevTools to reduce console warnings caused by version differences. When reporting issues, please include the actual base library version.
- **Minimum production version**: set a reasonable minimum base library version in the WeChat Mini Program admin console. It is recommended to cover more than 95% of users (for example, 3.x) to avoid issues caused by versions that are too low.
- **Compatibility testing**: switch to the target minimum version in local settings to verify fallback and compatibility behavior for users on lower versions.

> You can refer to the official [Base Library Version Distribution](https://developers.weixin.qq.com/miniprogram/dev/framework/client-lib/version.html) to determine the minimum version you need to support.

### Component-to-base-library mapping

| Component | API | Minimum base library | Description |
| --------- | ------ | -------------------- | ----------- |
| Upload | [wx.previewMedia](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewMedia.html) | 2.12.0 | Preview images and videos. |
| Upload | [wx.chooseMedia](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html) | 2.10.0 | Capture photos/videos or choose images/videos from the phone album. |
| Upload | [wx.chooseMessageFile](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html) | 2.5.0 | Select files from a chat session. |
| Navbar | [wx.getMenuButtonBoundingClientRect](https://developers.weixin.qq.com/miniprogram/dev/api/ui/menu/wx.getMenuButtonBoundingClientRect.html) | 2.1.0 | Get layout information for the menu button (the capsule button in the top-right corner). Coordinates use the top-left corner of the screen as the origin. |

## About user privacy protection guidelines

Some TDesign components use WeChat APIs, and some of these APIs involve users’ personal information. For example, `Upload` uses `wx.chooseMedia` / `wx.chooseImage` (photos or videos).

## Base library version
When your Mini Program uses TDesign via the `tdesign-miniprogram` npm package and is published, according to WeChat’s [Instructions for Filling in the User Privacy Protection Guidelines](https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/), if APIs involving personal information are detected in code, you must complete the user privacy protection guideline declaration and pass review (Mini Program admin console: `Settings - Service Content Declaration - User Privacy Protection Guidelines`). Undeclared APIs will be disabled directly; APIs already declared do not need to be declared again.

Minimum base library version `^2.12.0`
### Components involving users’ personal information

### Correspondence between component and basic library versions
| Component | API/Capability | Information processed |
| --------- | -------------- | --------------------- |
| Upload | `wx.chooseImage` / `wx.chooseMedia` | Collects the photo or video information you select. |
| Upload | `wx.chooseMessageFile` | Collects the files you select. |
| Typography | `wx.setClipboardData` | Reads your clipboard. |

| 组件 | API | 最低基础库 | 描述 |
| ----- | ------ | ---------- | ---- |
| Upload | [wx.previewMedia](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewMedia.html) | 2.12.0 | - |
| Upload | [wx.chooseMedia](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html) | 2.10.0 | - |
| Upload | [wx.chooseMessageFile](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html) | 2.5.0 | - |
| Navbar | [wx.getMenuButtonBoundingClientRect](https://developers.weixin.qq.com/miniprogram/dev/api/ui/menu/wx.getMenuButtonBoundingClientRect.html) | 2.1.0 | - |
> For the mapping between APIs and processed information, see [Introduction to Mini Program User Privacy Protection Guidelines](https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/miniprogram-intro.html).

38 changes: 31 additions & 7 deletions packages/tdesign-miniprogram/site/docs/getting-started.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Wechat MiniProgram
title: WeChat MiniProgram
description: TDesign 微信小程序组件库。
spline: explain
---
Expand Down Expand Up @@ -79,16 +79,40 @@ npm run dev

打开[微信开发者工具](https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html),把`_example`目录添加进去就可以预览示例了。

## 基础库版本
## 关于基础库版本

最低基础库版本`^2.12.0`
最低基础库版本 `^2.12.0`。

### 基础库版本选择建议

- **开发调试**:使用微信开发者工具的「最新稳定版」,减少版本差异带来的控制台警告;反馈问题时请注明实际基础库版本。
- **线上最低版本**:在微信公众平台设置合理的最低基础库版本,建议覆盖 95% 以上用户(如 3.x),避免版本过低导致功能异常。
- **兼容测试**:在本地设置中切换到目标最低版本,验证低版本用户的降级与兼容逻辑。

> 可参考官方 [基础库版本分布](https://developers.weixin.qq.com/miniprogram/dev/framework/client-lib/version.html) 确定需要兼容的最低版本。

### 组件与基础库版本对应关系

| 组件 | API | 最低基础库 | 描述 |
| ----- | ------ | ---------- | ---- |
| Upload | [wx.previewMedia](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewMedia.html) | 2.12.0 | - |
| Upload | [wx.chooseMedia](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html) | 2.10.0 | - |
| Upload | [wx.chooseMessageFile](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html) | 2.5.0 | - |
| Navbar | [wx.getMenuButtonBoundingClientRect](https://developers.weixin.qq.com/miniprogram/dev/api/ui/menu/wx.getMenuButtonBoundingClientRect.html) | 2.1.0 | - |
| Upload | [wx.previewMedia](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewMedia.html) | 2.12.0 | 预览图片和视频 |
| Upload | [wx.chooseMedia](https://developers.weixin.qq.com/miniprogram/dev/api/media/video/wx.chooseMedia.html) | 2.10.0 | 拍摄或从手机相册中选择图片或视频。 |
| Upload | [wx.chooseMessageFile](https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.chooseMessageFile.html) | 2.5.0 | 从客户端会话选择文件。 |
| Navbar | [wx.getMenuButtonBoundingClientRect](https://developers.weixin.qq.com/miniprogram/dev/api/ui/menu/wx.getMenuButtonBoundingClientRect.html) | 2.1.0 | 获取菜单按钮(右上角胶囊按钮)的布局位置信息。坐标信息以屏幕左上角为原点。 |

## 关于用户隐私保护指引

TDesign 部分组件使用了微信提供的接口,其中部分接口涉及获取用户隐私信息。例如 `Upload` 使用了 `wx.chooseMedia` / `wx.chooseImage`(照片或视频)。

当小程序引入 tdesign-miniprogram 组件库并发布时,根据微信 [《用户隐私保护指引填写说明》](https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/),如检测到代码中存在涉及用户隐私信息接口,则需要填写用户隐私保护指引信息并通过审核(小程序管理后台 `设置 - 服务内容声明 - 用户隐私保护指引` )。未声明的接口将直接禁用,已声明的无需重复填写。

### 涉及用户隐私信息的组件

| 组件 | 接口/能力 | 处理的信息 |
| ---- | --------- | ---------- |
| Upload | `wx.chooseImage` / `wx.chooseMedia` | 收集你选中的照片或视频信息 |
| Upload | `wx.chooseMessageFile` | 收集你选中的文件 |
| Typography | `wx.setClipboardData` | 读取你的剪切板 |

> 接口与处理信息的对应关系见 [小程序用户隐私保护指引内容介绍](https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/miniprogram-intro.html)。

Loading