Skip to content

Commit 5d2b716

Browse files
committed
docs(Chat): update api docs
1 parent e46324e commit 5d2b716

File tree

39 files changed

+946
-1187
lines changed

39 files changed

+946
-1187
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: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
overflow | String | wrap | options: wrap/scrollX/scrollY | N
15+
removable | Boolean | true | \- | N
16+
17+
### Attachments Events
18+
19+
name | params | description
20+
-- | -- | --
21+
add | \- | \-
22+
file-click | `(item: FileItem)` | \-
23+
remove | `(item: FileItem, index: number)` | \-

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

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -49,35 +49,18 @@ isComponent: true
4949

5050
名称 | 类型 | 默认值 | 描述 | 必传
5151
-- | -- | -- | -- | --
52-
items | Array | [] | 附件列表。TS类型:FileItem[] | Y
53-
removable | Boolean | true | 是否显示删除按钮 | N
54-
imageViewer | Boolean | true | 是否启用图片预览功能 | N
52+
style | Object | - | 样式 | N
53+
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
5554
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-
}
55+
image-viewer | Boolean | true | 是否启用图片预览功能 | N
56+
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
57+
overflow | String | wrap | 文件列表超出时样式。可选项:wrap/scrollX/scrollY | N
58+
removable | Boolean | true | 是否显示删除按钮 | N
7559

7660
### Attachments Events
7761

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

packages/pro-components/chat/attachments/attachments.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { SuperComponent, wxComponent, ComponentsOptionsType } from '../../../components/common/src/index';
22
import config from '../../../components/common/config';
3+
import { TdAttachmentsProps } from './type';
34

45
const { prefix } = config;
56
const name = `${prefix}-attachments`;
67

8+
export interface AttachmentsProps extends TdAttachmentsProps {}
9+
710
@wxComponent()
811
export default class Attachments extends SuperComponent {
912
options: ComponentsOptionsType = {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './props';
2+
export * from './type';
3+
export * from './attachments';

packages/pro-components/chat/attachments/props.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,10 @@
44
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
55
* */
66

7-
import { TdChatAttachmentsProps } from './type';
8-
const props: TdChatAttachmentsProps = {
9-
/** 文件列表数据,每个元素需包含fileType/name/url/size等属性 */
10-
items: {
11-
type: Array,
12-
value: [],
13-
},
14-
/** 是否显示删除按钮 */
15-
removable: {
7+
import { TdAttachmentsProps } from './type';
8+
const props: TdAttachmentsProps = {
9+
/** 是否显示添加按钮 */
10+
addable: {
1611
type: Boolean,
1712
value: true,
1813
},
@@ -21,11 +16,21 @@ const props: TdChatAttachmentsProps = {
2116
type: Boolean,
2217
value: true,
2318
},
24-
/** 是否显示添加按钮 */
25-
addable: {
19+
/** 【实验】附件列表 */
20+
items: {
21+
type: Array,
22+
value: [],
23+
},
24+
/** 文件列表超出时样式 */
25+
overflow: {
26+
type: String,
27+
value: 'wrap',
28+
},
29+
/** 是否显示删除按钮 */
30+
removable: {
2631
type: Boolean,
2732
value: true,
28-
}
33+
},
2934
};
3035

3136
export default props;

packages/pro-components/chat/attachments/type.ts

Lines changed: 35 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,12 @@
44
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
55
* */
66

7-
export interface FileItem {
8-
/**
9-
* 文件类型
10-
*/
11-
fileType: 'image' | 'pdf' | 'doc' | 'ppt' | 'txt';
12-
/**
13-
* 文件名
14-
*/
15-
name: string;
16-
/**
17-
* 文件URL
18-
*/
19-
url: string;
20-
/**
21-
* 文件大小(KB)
22-
*/
23-
size: number;
24-
/**
25-
* 上传状态
26-
*/
27-
status?: 'success' | 'fail' | 'pending' | 'error';
28-
/**
29-
* 上传进度(0-100)
30-
*/
31-
progress?: number;
32-
/**
33-
* 错误信息
34-
*/
35-
errorMessage?: string;
36-
/**
37-
* 自定义文件图标URL
38-
*/
39-
fileIcon?: string;
40-
/**
41-
* 图片宽度
42-
*/
43-
width?: number;
44-
/**
45-
* 图片高度
46-
*/
47-
height?: number;
48-
/**
49-
* 图片缩放模式
50-
*/
51-
mode?: 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'scaleToFill';
52-
}
53-
export interface TdChatAttachmentsProps {
54-
/**
55-
* 文件列表数据,每个元素需包含fileType/name/url/size等属性
56-
* @default []
57-
*/
58-
items?: {
59-
type: ArrayConstructor;
60-
value?: FileItem[];
61-
};
7+
export interface TdAttachmentsProps {
628
/**
63-
* 是否显示删除按钮
9+
* 是否显示添加按钮
6410
* @default true
6511
*/
66-
removable?: {
12+
addable?: {
6713
type: BooleanConstructor;
6814
value?: boolean;
6915
};
@@ -76,11 +22,41 @@ export interface TdChatAttachmentsProps {
7622
value?: boolean;
7723
};
7824
/**
79-
* 是否显示添加按钮
25+
* 【实验】附件列表
26+
* @default []
27+
*/
28+
items?: {
29+
type: ArrayConstructor;
30+
value?: FileItem[];
31+
};
32+
/**
33+
* 文件列表超出时样式
34+
* @default wrap
35+
*/
36+
overflow?: {
37+
type: StringConstructor;
38+
value?: 'wrap' | 'scrollX' | 'scrollY';
39+
};
40+
/**
41+
* 是否显示删除按钮
8042
* @default true
8143
*/
82-
addable?: {
44+
removable?: {
8345
type: BooleanConstructor;
8446
value?: boolean;
8547
};
8648
}
49+
50+
export interface FileItem {
51+
fileType: 'image' | 'video' | 'audio' | 'pdf' | 'doc' | 'ppt' | 'txt';
52+
name: string;
53+
url: string;
54+
size: number;
55+
status?: 'success' | 'fail' | 'pending' | 'error';
56+
progress?: number;
57+
errorMessage?: string;
58+
fileIcon?: string;
59+
width?: number;
60+
height?: number;
61+
mode?: 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'scaleToFill';
62+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
:: BASE_DOC ::
2+
3+
## API
4+
5+
### ChatActionbar 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+
action-bar | Array | ['refresh', 'copy', 'good', 'bad', 'share'] | Typescript: `Array<string>` | N
12+
chat-id | String | - | \- | N
13+
comment | String | - | \- | N
14+
content | String | - | \- | N
15+
copy-mode | String | markdown | options: markdown/text | N
16+
disabled | Boolean | false | \- | N
17+
placement | String | start | options: start/end/space-around/space-between | N
18+
19+
### ChatActionbar Events
20+
21+
name | params | description
22+
-- | -- | --
23+
actions | `(name: ChatActionsName, active: boolean)` | \-

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,19 +37,23 @@ isComponent: true
3737

3838

3939
## API
40-
### ChatAction Props
40+
41+
### ChatActionbar Props
4142

4243
名称 | 类型 | 默认值 | 描述 | 必传
4344
-- | -- | -- | -- | --
44-
chatId | String | '' | 聊天消息的唯一标识,一般用于分享一段问答 | N
45-
content | String | - | 被复制的内容 | N
46-
copyMode | String | markdown | 复制内容的模式,可选 'markdown'(复制markdown原文)或 'text'(复制纯文本) | N
47-
comment | String | - | 评价类型, 可选值: `'good(点赞)'/'bad(点踩)`, 默认为空| N
48-
actionBar | Array | ["refresh", "copy", "good", "bad", "share"] | 操作按钮配置项,可配置操作按钮选项和顺序。TS 类型:`Array<'refresh'\|'copy'\|'good'\|'bad'\|'share'>` | N
49-
placement | String | start | 操作栏位置。可选项:start/end/space-around/space-between | N
50-
51-
### ChatAction Events
45+
style | Object | - | 样式 | N
46+
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
47+
action-bar | Array | ['refresh', 'copy', 'good', 'bad', 'share'] | 操作栏配置。TS 类型:`Array<string>` | N
48+
chat-id | String | - | 【实验】聊天消息的唯一标识 | N
49+
comment | String | - | 评价内容 | N
50+
content | String | - | 复制内容文本 | N
51+
copy-mode | String | markdown | 【实验】复制内容的模式,可选 'markdown'(复制markdown原文)或 'text'(复制纯文本)。可选项:markdown/text | N
52+
disabled | Boolean | false | 【讨论中】操作按钮是否可点击 | N
53+
placement | String | start | 【实验】操作栏位置。可选项:start/end/space-around/space-between | N
54+
55+
### ChatActionbar Events
5256

5357
名称 | 参数 | 描述
5458
-- | -- | --
55-
actions | `(name: ChatActionsName, context: { e: MouseEvent, active: boolean })` 点击点赞,点踩,复制,分享,重新生成按钮时触发发
59+
actions | `(name: ChatActionsName, active: boolean)` | 点击点赞,点踩,复制,分享,重新生成按钮时触发发
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/* eslint-disable */
2+
3+
/**
4+
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
5+
* */
6+
7+
import { TdChatActionbarProps } from './type';
8+
const props: TdChatActionbarProps = {
9+
/** 操作栏配置 */
10+
actionBar: {
11+
type: Array,
12+
value: ['refresh', 'copy', 'good', 'bad', 'share'],
13+
},
14+
/** 【实验】聊天消息的唯一标识 */
15+
chatId: {
16+
type: String,
17+
value: '',
18+
},
19+
/** 评价内容 */
20+
comment: {
21+
type: String,
22+
value: '',
23+
},
24+
/** 复制内容文本 */
25+
content: {
26+
type: String,
27+
value: '',
28+
},
29+
/** 【实验】复制内容的模式,可选 'markdown'(复制markdown原文)或 'text'(复制纯文本) */
30+
copyMode: {
31+
type: String,
32+
value: 'markdown',
33+
},
34+
/** 【讨论中】操作按钮是否可点击 */
35+
disabled: {
36+
type: Boolean,
37+
value: false,
38+
},
39+
/** 【实验】操作栏位置 */
40+
placement: {
41+
type: String,
42+
value: 'start',
43+
},
44+
};
45+
46+
export default props;

0 commit comments

Comments
 (0)