Skip to content

Commit 51ba96e

Browse files
authored
docs(Chat): update api docs (#4038)
* docs(Chat): update api docs * docs: update * chore: using props.ts file * fix(Demo): fix multiple example bugs * chore: remove irrelevant content
1 parent 2befe4d commit 51ba96e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1145
-1756
lines changed

packages/components/common/common.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ export interface Styles {
66

77
export type ImageEvent = any;
88

9-
/**
10-
* 通用全局类型
11-
* */
129
export type PlainObject = { [key: string]: any };
1310

1411
export type OptionData = {
@@ -28,6 +25,9 @@ export type TreeOptionData<T = string | number> = {
2825
content?: string;
2926
} & PlainObject;
3027

28+
/**
29+
* 通用全局类型
30+
* */
3131
export type SizeEnum = 'small' | 'medium' | 'large';
3232

3333
export type ShapeEnum = 'circle' | 'round';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
:: BASE_DOC ::
2+
3+
## API
4+
5+
### Attachments Props
6+
7+
name | type | default | description | required
8+
-- | -- | -- | -- | --
9+
style | Object | - | CSS(Cascading Style Sheets) | N
10+
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
11+
addable | Boolean | true | \- | N
12+
image-viewer | Boolean | true | \- | N
13+
items | Array | [] | Typescript: `FileItem[]` `interface FileItem { fileType: 'image'\|'video'\|'audio'\|'pdf'\|'doc'\|'ppt'\|'txt'; name: string; url: string; size: number; status?: 'success'\|'fail'\|'pending'\|'error'; progress?: number; errorMessage?: string; fileIcon?: string; width?: number; height?: number; mode?: 'aspectFit' \| 'aspectFill' \| 'widthFix' \| 'heightFix' \| 'scaleToFill'}`[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/attachments/type.ts) | N
14+
removable | Boolean | true | \- | N
15+
16+
### Attachments Events
17+
18+
name | params | description
19+
-- | -- | --
20+
add | \- | \-
21+
file-click | `(item: FileItem)` | \-
22+
remove | `(item: FileItem, index: number)` | \-

packages/pro-components/chat/attachments/README.md

Lines changed: 15 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ spline: base
55
isComponent: true
66
---
77

8-
<span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20lines-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20functions-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20statements-100%25-blue" /></span><span class="coverages-badge" style="margin-right: 10px"><img src="https://img.shields.io/badge/coverages%3A%20branches-100%25-blue" /></span>
98

109
## 引入
1110

@@ -17,67 +16,43 @@ isComponent: true
1716
}
1817
```
1918

20-
## 代码演示
21-
22-
<a href="https://developers.weixin.qq.com/s/F1cSo7mm75SS" title="在开发者工具中预览效果" target="_blank" rel="noopener noreferrer"> 在开发者工具中预览效果 </a>
23-
24-
<blockquote style="background-color: #d9e1ff; font-size: 15px; line-height: 26px;margin: 16px 0 0;padding: 16px; border-radius: 6px; color: #0052d9" >
25-
<p>Tips: 请确保开发者工具为打开状态。导入开发者工具后,依次执行:npm i > 构建npm包 > 勾选 "将JS编译成ES5"</p>
26-
</blockquote>
27-
2819
### 01 组件类型
2920

30-
图片类型
21+
#### 图片类型
3122

3223
{{ base }}
3324

34-
文件类型
25+
#### 文件类型
3526

3627
{{ file }}
3728

3829
### 02 组件状态
39-
图片类型加载状态
4030

41-
{{ imageLoading }}
31+
#### 图片类型加载状态
32+
33+
{{ image-loading }}
4234

43-
文件类型加载状态
44-
{{ fileLoading }}
35+
#### 文件类型加载状态
36+
37+
{{ file-loading }}
4538

4639
## API
4740

4841
### Attachments Props
4942

5043
名称 | 类型 | 默认值 | 描述 | 必传
5144
-- | -- | -- | -- | --
52-
items | Array | [] | 附件列表。TS类型:FileItem[] | Y
45+
style | Object | - | 样式 | N
46+
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
47+
addable | Boolean | true | 【讨论中】是否显示添加按钮 | N
48+
image-viewer | Boolean | true | 是否启用图片预览功能 | N
49+
items | Array | [] | 【实验】附件列表。TS 类型:`FileItem[]` `interface FileItem { fileType: 'image'\|'video'\|'audio'\|'pdf'\|'doc'\|'ppt'\|'txt'; name: string; url: string; size: number; status?: 'success'\|'fail'\|'pending'\|'error'; progress?: number; errorMessage?: string; fileIcon?: string; width?: number; height?: number; mode?: 'aspectFit' \| 'aspectFill' \| 'widthFix' \| 'heightFix' \| 'scaleToFill'}`[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/attachments/type.ts) | N
5350
removable | Boolean | true | 是否显示删除按钮 | N
54-
imageViewer | Boolean | true | 是否启用图片预览功能 | N
55-
addable | Boolean | true | 是否显示添加按钮 | N
56-
57-
58-
59-
60-
### FileItem 类型定义
61-
```typescript
62-
interface FileItem {
63-
fileType: 'image'|'video'|'audio'|'pdf'|'doc'|'ppt'|'txt' // 文件类型
64-
name: string // 文件名
65-
url: string // 文件URL
66-
size: number // 文件大小(KB)
67-
status?: 'success'|'fail'|'pending'|'error' // 上传状态
68-
progress?: number // 上传进度(0-100)
69-
errorMessage?: string // 错误信息
70-
fileIcon?: string // 自定义文件图标URL
71-
width?: number // 图片宽度(px)
72-
height?: number // 图片高度(px)
73-
mode?: 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'scaleToFill' // 图片模式
74-
}
7551

7652
### Attachments Events
7753

7854
名称 | 参数 | 描述
7955
-- | -- | --
80-
fileClick | `(item: FileItem)` | 点击文件时触发
56+
add | \- | 点击添加按钮时触发
57+
file-click | `(item: FileItem)` | 点击文件时触发
8158
remove | `(item: FileItem, index: number)` | 点击删除按钮时触发
82-
add | - | 点击添加按钮时触发
83-

packages/pro-components/chat/attachments/_example/attachments.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"navigationBarTitleText": "Attachments 聊天附件",
33
"usingComponents": {
44
"base": "./base",
5-
"fileLoading": "./fileLoading",
6-
"imageLoading": "./imageLoading",
5+
"fileLoading": "./file-loading",
6+
"imageLoading": "./image-loading",
77
"file": "./file"
88
}
99
}

0 commit comments

Comments
 (0)