diff --git a/db/TDesign.db b/db/TDesign.db index ca0431067..ca10147c3 100644 Binary files a/db/TDesign.db and b/db/TDesign.db differ diff --git a/packages/products/tdesign-react/packages/components/chat/chat.en-US.md b/packages/products/tdesign-react/packages/components/chat/chat.en-US.md index 4523f93ce..141830f3d 100644 --- a/packages/products/tdesign-react/packages/components/chat/chat.en-US.md +++ b/packages/products/tdesign-react/packages/components/chat/chat.en-US.md @@ -134,8 +134,10 @@ name | type | default | description | required className | String | - | className of component | N style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N collapsePanelProps | Object | { destroyOnCollapse: false } | Typescript:`CollapsePanelProps`,[Collapse API Documents](./collapse?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/chat/type.ts) | N +expand | Boolean | - | \- | N +defaultExpand | Boolean | - | uncontrolled property | N expandIcon | TElement | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N expandIconPlacement | String | right | options: left/right | N header | TElement | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N headerRightContent | TElement | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N -onExpandChange | Function | | Typescript:`(value: CollapseValue) => void`
Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/chat/type.ts)。
`import { CollapseValue } from '@Collapse'`
| N +onExpandChange | Function | | Typescript:`(value: boolean) => void`
Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N diff --git a/packages/products/tdesign-react/packages/components/chat/chat.md b/packages/products/tdesign-react/packages/components/chat/chat.md index b2ccd7f75..319d0bd61 100644 --- a/packages/products/tdesign-react/packages/components/chat/chat.md +++ b/packages/products/tdesign-react/packages/components/chat/chat.md @@ -134,8 +134,10 @@ onStop | Function | | TS 类型:`(value:string, context: { e: MouseEvent }) = className | String | - | 类名 | N style | Object | - | 样式,TS 类型:`React.CSSProperties` | N collapsePanelProps | Object | { destroyOnCollapse: false } | 透传给 CollapsePanel 组件的全部属性。TS 类型:`CollapsePanelProps`,[Collapse API Documents](./collapse?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/chat/type.ts) | N +expand | Boolean | - | \- | N +defaultExpand | Boolean | - | 非受控属性 | N expandIcon | TElement | - | 当前折叠面板展开图标。优先级低于collapsePanelProps.expandIcon。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N expandIconPlacement | String | right | 展开图标位置,可选项:left/right。可选项:left/right | N header | TElement | - | 折叠面板头内容。优先级低于collapsePanelProps.header。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N headerRightContent | TElement | - | 折叠面板尾内容。优先级低于collapsePanelProps.headerRightContent。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N -onExpandChange | Function | | TS 类型:`(value: CollapseValue) => void`
展开图标点击事件。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/chat/type.ts)。
`import { CollapseValue } from '@Collapse'`
| N +onExpandChange | Function | | TS 类型:`(value: boolean) => void`
展开图标点击事件。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-react/blob/develop/packages/components/common.ts) | N diff --git a/packages/products/tdesign-react/packages/components/chat/type.ts b/packages/products/tdesign-react/packages/components/chat/type.ts index 5469185b2..16a0efb1c 100644 --- a/packages/products/tdesign-react/packages/components/chat/type.ts +++ b/packages/products/tdesign-react/packages/components/chat/type.ts @@ -7,7 +7,6 @@ import { AvatarProps } from '../avatar'; import { TextareaProps } from '../textarea'; import { CollapsePanelProps } from '../collapse'; -import { CollapseValue } from '../collapse'; import { TNode, TElement } from '../common'; import { MouseEvent, KeyboardEvent, FocusEvent, FormEvent } from 'react'; @@ -326,6 +325,14 @@ export interface TdChatReasoningProps { * @default { destroyOnCollapse: false } */ collapsePanelProps?: CollapsePanelProps; + /** + * null + */ + expand?: boolean; + /** + * null,非受控属性 + */ + defaultExpand?: boolean; /** * 当前折叠面板展开图标。优先级低于collapsePanelProps.expandIcon */ @@ -346,7 +353,7 @@ export interface TdChatReasoningProps { /** * 展开图标点击事件 */ - onExpandChange?: (value: CollapseValue) => void; + onExpandChange?: (value: boolean) => void; } export interface TdChatItemMeta { diff --git a/packages/products/tdesign-vue-next/packages/components/chat/chat-reasoning-props.ts b/packages/products/tdesign-vue-next/packages/components/chat/chat-reasoning-props.ts index b4951a86f..398dab1cd 100644 --- a/packages/products/tdesign-vue-next/packages/components/chat/chat-reasoning-props.ts +++ b/packages/products/tdesign-vue-next/packages/components/chat/chat-reasoning-props.ts @@ -13,6 +13,13 @@ export default { type: Object as PropType, default: { destroyOnCollapse: false }, }, + /** null */ + expand: { + type: Boolean, + default: undefined, + }, + /** null,非受控属性 */ + defaultExpand: Boolean, /** 当前折叠面板展开图标。优先级低于collapsePanelProps.expandIcon */ expandIcon: { type: Function as PropType, diff --git a/packages/products/tdesign-vue-next/packages/components/chat/chat.en-US.md b/packages/products/tdesign-vue-next/packages/components/chat/chat.en-US.md index de35baa0a..76dc45dc6 100644 --- a/packages/products/tdesign-vue-next/packages/components/chat/chat.en-US.md +++ b/packages/products/tdesign-vue-next/packages/components/chat/chat.en-US.md @@ -149,14 +149,16 @@ stop | `(value:string, context: { e: MouseEvent })` | \- name | type | default | description | required -- | -- | -- | -- | -- collapsePanelProps | Object | { destroyOnCollapse: false } | Typescript:`CollapsePanelProps`,[Collapse API Documents](./collapse?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/chat/type.ts) | N +expand | Boolean | - | `v-model:expand` is supported | N +defaultExpand | Boolean | - | uncontrolled property | N expandIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N expandIconPlacement | String | right | options: left/right | N header | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N headerRightContent | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N -onExpandChange | Function | | Typescript:`(value: CollapseValue) => void`
Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/chat/type.ts)。
`import { CollapseValue } from '@Collapse'`
| N +onExpandChange | Function | | Typescript:`(value: boolean) => void`
Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N ### ChatReasoning Events name | params | description -- | -- | -- -expand-change | `(value: CollapseValue)` | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/chat/type.ts)。
`import { CollapseValue } from '@Collapse'`
+expand-change | `(value: boolean)` | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) diff --git a/packages/products/tdesign-vue-next/packages/components/chat/chat.md b/packages/products/tdesign-vue-next/packages/components/chat/chat.md index 73e74adcd..8341233ef 100644 --- a/packages/products/tdesign-vue-next/packages/components/chat/chat.md +++ b/packages/products/tdesign-vue-next/packages/components/chat/chat.md @@ -149,14 +149,16 @@ stop | `(value:string, context: { e: MouseEvent })` | 点击消息终止的回 名称 | 类型 | 默认值 | 描述 | 必传 -- | -- | -- | -- | -- collapsePanelProps | Object | { destroyOnCollapse: false } | 透传给 CollapsePanel 组件的全部属性。TS 类型:`CollapsePanelProps`,[Collapse API Documents](./collapse?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/chat/type.ts) | N +expand | Boolean | - | 支持语法糖 `v-model:expand` | N +defaultExpand | Boolean | - | 非受控属性 | N expandIcon | Slot / Function | - | 当前折叠面板展开图标。优先级低于collapsePanelProps.expandIcon。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N expandIconPlacement | String | right | 展开图标位置,可选项:left/right。可选项:left/right | N header | Slot / Function | - | 折叠面板头内容。优先级低于collapsePanelProps.header。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N headerRightContent | Slot / Function | - | 折叠面板尾内容。优先级低于collapsePanelProps.headerRightContent。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N -onExpandChange | Function | | TS 类型:`(value: CollapseValue) => void`
展开图标点击事件。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/chat/type.ts)。
`import { CollapseValue } from '@Collapse'`
| N +onExpandChange | Function | | TS 类型:`(value: boolean) => void`
展开图标点击事件。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) | N ### ChatReasoning Events 名称 | 参数 | 描述 -- | -- | -- -expand-change | `(value: CollapseValue)` | 展开图标点击事件。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/chat/type.ts)。
`import { CollapseValue } from '@Collapse'`
+expand-change | `(value: boolean)` | 展开图标点击事件。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue-next/blob/develop/packages/components/common.ts) diff --git a/packages/products/tdesign-vue-next/packages/components/chat/type.ts b/packages/products/tdesign-vue-next/packages/components/chat/type.ts index 9b95775c3..58812b2d0 100644 --- a/packages/products/tdesign-vue-next/packages/components/chat/type.ts +++ b/packages/products/tdesign-vue-next/packages/components/chat/type.ts @@ -7,7 +7,6 @@ import { AvatarProps } from '../avatar'; import { TextareaProps } from '../textarea'; import { CollapsePanelProps } from '../collapse'; -import { CollapseValue } from '../collapse'; import { TNode } from '../common'; export interface TdChatProps { @@ -329,6 +328,14 @@ export interface TdChatReasoningProps { * @default { destroyOnCollapse: false } */ collapsePanelProps?: CollapsePanelProps; + /** + * null + */ + expand?: boolean; + /** + * null,非受控属性 + */ + defaultExpand?: boolean; /** * 当前折叠面板展开图标。优先级低于collapsePanelProps.expandIcon */ @@ -349,7 +356,7 @@ export interface TdChatReasoningProps { /** * 展开图标点击事件 */ - onExpandChange?: (value: CollapseValue) => void; + onExpandChange?: (value: boolean) => void; } export interface TdChatItemMeta { diff --git a/packages/products/tdesign-vue/src/chat/chat-action-props.ts b/packages/products/tdesign-vue/src/chat/chat-action-props.ts new file mode 100644 index 000000000..38f9f4ac7 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat-action-props.ts @@ -0,0 +1,29 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdChatActionProps } from '../chat/type'; +import { PropType } from 'vue'; + +export default { + /** 被复制的内容 */ + content: { + type: String, + default: '', + }, + /** 操作按钮是否可点击 */ + disabled: Boolean, + /** 是否点踩 */ + isBad: Boolean, + /** 是否点赞 */ + isGood: Boolean, + /** 操作按钮配置项,可配置操作按钮选项和顺序 */ + operationBtn: { + type: Array as PropType, + default: (): TdChatActionProps['operationBtn'] => ["replay", "copy", "good", "bad"], + }, + /** 点击点赞,点踩,复制,重新生成按钮时触发 */ + onOperation: Function as PropType, +}; diff --git a/packages/products/tdesign-vue/src/chat/chat-content-props.ts b/packages/products/tdesign-vue/src/chat/chat-content-props.ts new file mode 100644 index 000000000..53282e6b2 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat-content-props.ts @@ -0,0 +1,24 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdChatContentProps } from '../chat/type'; +import { PropType } from 'vue'; + +export default { + /** 聊天内容,支持 markdown 格式 */ + content: { + type: String, + default: '', + }, + /** 角色,不同选项配置不同的样式,支持类型包括用户、助手、错误、模型切换、系统消息 */ + role: { + type: String as PropType, + validator(val: TdChatContentProps['role']): boolean { + if (!val) return true; + return ['user', 'assistant', 'error', 'model-change', 'system'].includes(val); + }, + }, +}; diff --git a/packages/products/tdesign-vue/src/chat/chat-input-props.ts b/packages/products/tdesign-vue/src/chat/chat-input-props.ts new file mode 100644 index 000000000..6a15ddfa5 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat-input-props.ts @@ -0,0 +1,51 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdChatInputProps } from '../chat/type'; +import { PropType } from 'vue'; + +export default { + /** 输入框是否自动聚焦 */ + autofocus: Boolean, + /** 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度 */ + autosize: { + type: [Boolean, Object] as PropType, + default: { minRows: 1, maxRows: 5 }, + }, + /** 是否禁用输入框 */ + disabled: Boolean, + /** 输入框默认文案 */ + placeholder: { + type: String, + default: '', + }, + /** 中止按钮是否可点击。等流式数据全部返回结束置为false,注意跟textLoading的控制时机不是同一个 */ + stopDisabled: Boolean, + /** 发送按钮的自定义扩展 */ + suffixIcon: { + type: Function as PropType, + }, + /** 输入框的值 */ + value: { + type: String, + default: '', + }, + /** 输入框的值,非受控属性 */ + defaultValue: { + type: String, + default: '', + }, + /** 输入框聚焦时触发 */ + onBlur: Function as PropType, + /** 输入框值发生变化时触发 */ + onChange: Function as PropType, + /** 输入框聚焦时触发 */ + onFocus: Function as PropType, + /** 点击消息发送的回调方法 */ + onSend: Function as PropType, + /** 点击消息终止的回调方法 */ + onStop: Function as PropType, +}; diff --git a/packages/products/tdesign-vue/src/chat/chat-item-props.ts b/packages/products/tdesign-vue/src/chat/chat-item-props.ts new file mode 100644 index 000000000..911dd6619 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat-item-props.ts @@ -0,0 +1,64 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdChatItemProps } from '../chat/type'; +import { PropType } from 'vue'; + +export default { + /** 自定义的操作内容 */ + actions: { + type: [String, Function] as PropType, + }, + /** 动画效果,支持「渐变加载动画」,「闪烁加载动画」, 「骨架屏」三种 */ + animation: { + type: String as PropType, + default: 'skeleton' as TdChatItemProps['animation'], + validator(val: TdChatItemProps['animation']): boolean { + if (!val) return true; + return ['skeleton', 'moving', 'gradient'].includes(val); + }, + }, + /** 自定义的头像配置 */ + avatar: { + type: [String, Object, Function] as PropType, + }, + /** 对话单元的内容 */ + content: { + type: [String, Function] as PropType, + }, + /** 对话单元的时间配置 */ + datetime: { + type: [String, Function] as PropType, + }, + /** 自定义的昵称 */ + name: { + type: [String, Function] as PropType, + }, + /** 值为false不显示思维链,为string则显示内置推理内容交互,为对象则单独配置推理内容 */ + reasoning: { + type: [String, Boolean, Object] as PropType, + default: false, + }, + /** 角色,不同选项配置不同的样式,支持类型包括用户、助手、错误、模型切换、系统消息 */ + role: { + type: String as PropType, + validator(val: TdChatItemProps['role']): boolean { + if (!val) return true; + return ['user', 'assistant', 'error', 'model-change', 'system'].includes(val); + }, + }, + /** 新消息是否处于加载状态,加载状态默认显示骨架屏,接口请求返回数据时请将新消息加载状态置为false */ + textLoading: Boolean, + /** 气泡框样式,支持基础、线框、文字三种类型 */ + variant: { + type: String as PropType, + default: 'text' as TdChatItemProps['variant'], + validator(val: TdChatItemProps['variant']): boolean { + if (!val) return true; + return ['base', 'outline', 'text'].includes(val); + }, + }, +}; diff --git a/packages/products/tdesign-vue/src/chat/chat-loading-props.ts b/packages/products/tdesign-vue/src/chat/chat-loading-props.ts new file mode 100644 index 000000000..fee979daa --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat-loading-props.ts @@ -0,0 +1,25 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdChatLoadingProps } from '../chat/type'; +import { PropType } from 'vue'; + +export default { + /** 加载的状态形式 */ + animation: { + type: String as PropType, + default: 'gradient' as TdChatLoadingProps['animation'], + validator(val: TdChatLoadingProps['animation']): boolean { + if (!val) return true; + return ['moving', 'gradient'].includes(val); + }, + }, + /** 加载过程展示的文字内容 */ + text: { + type: String, + default: '', + }, +}; diff --git a/packages/products/tdesign-vue/src/chat/chat-reasoning-props.ts b/packages/products/tdesign-vue/src/chat/chat-reasoning-props.ts new file mode 100644 index 000000000..257ee00c0 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat-reasoning-props.ts @@ -0,0 +1,43 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdChatReasoningProps } from '../chat/type'; +import { PropType } from 'vue'; + +export default { + /** 透传给 CollapsePanel 组件的全部属性 */ + collapsePanelProps: { + type: Object as PropType, + default: { destroyOnCollapse: false }, + }, + /** null */ + expand: Boolean, + /** null,非受控属性 */ + defaultExpand: Boolean, + /** 当前折叠面板展开图标。优先级低于collapsePanelProps.expandIcon */ + expandIcon: { + type: Function as PropType, + }, + /** 展开图标位置,可选项:left/right */ + expandIconPlacement: { + type: String as PropType, + default: 'right' as TdChatReasoningProps['expandIconPlacement'], + validator(val: TdChatReasoningProps['expandIconPlacement']): boolean { + if (!val) return true; + return ['left', 'right'].includes(val); + }, + }, + /** 折叠面板头内容。优先级低于collapsePanelProps.header */ + header: { + type: Function as PropType, + }, + /** 折叠面板尾内容。优先级低于collapsePanelProps.headerRightContent */ + headerRightContent: { + type: Function as PropType, + }, + /** 展开图标点击事件 */ + onExpandChange: Function as PropType, +}; diff --git a/packages/products/tdesign-vue/src/chat/chat-sender-props.ts b/packages/products/tdesign-vue/src/chat/chat-sender-props.ts new file mode 100644 index 000000000..ca980a101 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat-sender-props.ts @@ -0,0 +1,52 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdChatSenderProps } from '../chat/type'; +import { PropType } from 'vue'; + +export default { + /** 是否禁用输入框 */ + disabled: Boolean, + /** 输入框默认文案 */ + placeholder: { + type: String, + default: '', + }, + /** 输入框左下角区域扩展 */ + prefix: { + type: [String, Function] as PropType, + }, + /** 中止按钮是否可点击。等流式数据全部返回结束置为false,注意跟textLoading的控制时机不是同一个 */ + stopDisabled: Boolean, + /** 输入框右下角区域扩展 */ + suffix: { + type: [String, Function] as PropType, + }, + /** 透传给 Textarea 组件的全部属性 */ + textareaProps: { + type: Object as PropType, + }, + /** 输入框的值 */ + value: { + type: String, + default: '', + }, + /** 输入框的值,非受控属性 */ + defaultValue: { + type: String, + default: '', + }, + /** 输入框聚焦时触发 */ + onBlur: Function as PropType, + /** 输入框值发生变化时触发 */ + onChange: Function as PropType, + /** 输入框聚焦时触发 */ + onFocus: Function as PropType, + /** 点击消息发送的回调方法 */ + onSend: Function as PropType, + /** 点击消息终止的回调方法 */ + onStop: Function as PropType, +}; diff --git a/packages/products/tdesign-vue/src/chat/chat.en-US.md b/packages/products/tdesign-vue/src/chat/chat.en-US.md new file mode 100644 index 000000000..75a777cf8 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat.en-US.md @@ -0,0 +1,164 @@ +:: BASE_DOC :: + +## API + +### Chat Props + +name | type | default | description | required +-- | -- | -- | -- | -- +actions | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +animation | String | skeleton | options: skeleton/moving/gradient | N +avatar | Slot / Function | - | Typescript:`TNode<{ item: TdChatItemProps, index: number }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +clearHistory | Boolean | true | \- | N +content | Slot / Function | - | Typescript:`TNode<{ item: TdChatItemProps, index: number }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +data | Array | - | Typescript:`Array` ` interface TdChatItemMeta { avatar?: string; name?:string; role?:string; datetime?: string; content?: string; reasoning?: string }`。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +datetime | Slot / Function | - | Typescript:`TNode<{ item: TdChatItemProps, index: number }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +isStreamLoad | Boolean | false | \- | N +layout | String | both | options: both/single | N +name | Slot / Function | - | Typescript:`TNode<{ item: TdChatItemProps, index: number }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +reasoning | Slot / Function | - | Typescript:`TNode<{ item: TdChatItemProps, index: number }>`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +reverse | Boolean | true | \- | N +textLoading | Boolean | false | \- | N +onClear | Function | | Typescript:`(context: { e: MouseEvent }) => void`
Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +onScroll | Function | | Typescript:`(context: { e: MouseEvent }) => void`
Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### Chat Events + +name | params | description +-- | -- | -- +clear | `(context: { e: MouseEvent })` | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) +scroll | `(context: { e: MouseEvent })` | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) + +### ChatInstanceFunctions 组件实例方法 + +name | params | return | description +-- | -- | -- | -- +scrollToBottom | `(params: ScrollToBottomParams)` | \- | [see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts)。
` type ScrollToBottomParams = { behavior: 'auto' \| 'smooth'} `
+ + +### ChatLoading Props + +name | type | default | description | required +-- | -- | -- | -- | -- +animation | String | gradient | options: moving/gradient | N +text | String | - | text of chat loading | N + + +### ChatItem Props + +name | type | default | description | required +-- | -- | -- | -- | -- +actions | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +animation | String | skeleton | options: skeleton/moving/gradient | N +avatar | String / Object / Slot / Function | - | Typescript:`String \| AvatarProps \| TNode `,[Avatar API Documents](./avatar?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +content | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +datetime | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +name | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +reasoning | String / Boolean / Object | false | Typescript:`boolean \| TdChatReasoning ` ` interface TdChatReasoning { expandIconPlacement?: 'left' \| 'right';onExpandChange?: (isExpand: boolean) => void; collapsePanelProps?: Object } `。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +role | String | - | options: user/assistant/error/model-change/system | N +textLoading | Boolean | false | \- | N +variant | String | text | options: base/outline/text | N + + +### ChatContent Props + +name | type | default | description | required +-- | -- | -- | -- | -- +content | String | - | \- | N +role | String | - | options: user/assistant/error/model-change/system | N + + +### ChatAction Props + +name | type | default | description | required +-- | -- | -- | -- | -- +content | String | - | \- | N +disabled | Boolean | false | \- | N +isBad | Boolean | false | \- | N +isGood | Boolean | false | \- | N +operationBtn | Array | ["replay", "copy", "good", "bad"] | Typescript:`Array<'replay'\|'copy'\|'good'\|'bad'>` | N +onOperation | Function | | Typescript:`(value:string, context: { e: MouseEvent }) => void`
| N + +### ChatAction Events + +name | params | description +-- | -- | -- +operation | `(value:string, context: { e: MouseEvent })` | \- + + +### ChatInput Props + +name | type | default | description | required +-- | -- | -- | -- | -- +autofocus | Boolean | false | \- | N +autosize | Boolean / Object | { minRows: 1, maxRows: 5 } | Typescript:`boolean \| { minRows?: number; maxRows?: number }` | N +disabled | Boolean | false | \- | N +placeholder | String | - | \- | N +stopDisabled | Boolean | false | \- | N +suffixIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +value | String | - | input value。`v-model` is supported | N +defaultValue | String | - | input value。uncontrolled property | N +onBlur | Function | | Typescript:`(value:string, context: { e: FocusEvent }) => void`
| N +onChange | Function | | Typescript:`(value:string, context: { e: InputEvent \| MouseEvent \| KeyboardEvent }) => void`
| N +onFocus | Function | | Typescript:`(value:string, context: { e: FocusEvent }) => void`
| N +onSend | Function | | Typescript:`(value:string, context: { e: MouseEvent \| KeyboardEvent }) => void`
| N +onStop | Function | | Typescript:`(value:string, context: { e: MouseEvent }) => void`
| N + +### ChatInput Events + +name | params | description +-- | -- | -- +blur | `(value:string, context: { e: FocusEvent })` | \- +change | `(value:string, context: { e: InputEvent \| MouseEvent \| KeyboardEvent })` | \- +focus | `(value:string, context: { e: FocusEvent }) ` | \- +send | `(value:string, context: { e: MouseEvent \| KeyboardEvent })` | \- +stop | `(value:string, context: { e: MouseEvent })` | \- + + +### ChatSender Props + +name | type | default | description | required +-- | -- | -- | -- | -- +disabled | Boolean | false | \- | N +placeholder | String | - | \- | N +prefix | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +stopDisabled | Boolean | false | \- | N +suffix | String / Slot / Function | - | Typescript:`string \| TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +textareaProps | Object | - | Typescript:`TextareaProps`,[Textarea API Documents](./textarea?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +value | String | - | input value。`v-model` is supported | N +defaultValue | String | - | input value。uncontrolled property | N +onBlur | Function | | Typescript:`(value:string, context: { e: FocusEvent }) => void`
| N +onChange | Function | | Typescript:`(value:string, context: { e: InputEvent \| MouseEvent \| KeyboardEvent }) => void`
| N +onFocus | Function | | Typescript:`(value:string, context: { e: FocusEvent }) => void`
| N +onSend | Function | | Typescript:`(value:string, context: { e: MouseEvent \| KeyboardEvent }) => void`
| N +onStop | Function | | Typescript:`(value:string, context: { e: MouseEvent }) => void`
| N + +### ChatSender Events + +name | params | description +-- | -- | -- +blur | `(value:string, context: { e: FocusEvent })` | \- +change | `(value:string, context: { e: InputEvent \| MouseEvent \| KeyboardEvent })` | \- +focus | `(value:string, context: { e: FocusEvent }) ` | \- +send | `(value:string, context: { e: MouseEvent \| KeyboardEvent })` | \- +stop | `(value:string, context: { e: MouseEvent })` | \- + + +### ChatReasoning Props + +name | type | default | description | required +-- | -- | -- | -- | -- +collapsePanelProps | Object | { destroyOnCollapse: false } | Typescript:`CollapsePanelProps`,[Collapse API Documents](./collapse?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +expand | Boolean | - | `.sync` is supported | N +defaultExpand | Boolean | - | uncontrolled property | N +expandIcon | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +expandIconPlacement | String | right | options: left/right | N +header | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +headerRightContent | Slot / Function | - | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +onExpandChange | Function | | Typescript:`(value: boolean) => void`
Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### ChatReasoning Events + +name | params | description +-- | -- | -- +expand-change | `(value: boolean)` | Typescript:`TNode`。[see more ts definition](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) diff --git a/packages/products/tdesign-vue/src/chat/chat.md b/packages/products/tdesign-vue/src/chat/chat.md new file mode 100644 index 000000000..84033659c --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/chat.md @@ -0,0 +1,164 @@ +:: BASE_DOC :: + +## API + +### Chat Props + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +actions | Slot / Function | - | 自定义操作按钮的插槽。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +animation | String | skeleton | 动画效果,支持「渐变加载动画」,「闪烁加载动画」, 「骨架屏」三种。可选项:skeleton/moving/gradient | N +avatar | Slot / Function | - | 自定义每个对话单元的头像插槽。TS 类型:`TNode<{ item: TdChatItemProps, index: number }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +clearHistory | Boolean | true | 是否显示清空历史 | N +content | Slot / Function | - | 自定义每个对话单独的聊天内容。TS 类型:`TNode<{ item: TdChatItemProps, index: number }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +data | Array | - | 对话列表的数据。TS 类型:`Array` ` interface TdChatItemMeta { avatar?: string; name?:string; role?:string; datetime?: string; content?: string; reasoning?: string }`。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +datetime | Slot / Function | - | 自定义每个对话单元的时间。TS 类型:`TNode<{ item: TdChatItemProps, index: number }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +isStreamLoad | Boolean | false | 流式加载是否结束 | N +layout | String | both | 对话布局形式,支持两侧对齐与左对齐。可选项:both/single | N +name | Slot / Function | - | 自定义每个对话单元的昵称。TS 类型:`TNode<{ item: TdChatItemProps, index: number }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +reasoning | Slot / Function | - | 自定义每个对话单元的思考过程的插槽。TS 类型:`TNode<{ item: TdChatItemProps, index: number }>`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +reverse | Boolean | true | 是否表现为倒序 | N +textLoading | Boolean | false | 新消息是否处于加载状态,加载状态默认显示骨架屏,接口请求返回数据时请将新消息加载状态置为false | N +onClear | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
点击清空历史按钮回调。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +onScroll | Function | | TS 类型:`(context: { e: MouseEvent }) => void`
滚动事件的回调。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### Chat Events + +名称 | 参数 | 描述 +-- | -- | -- +clear | `(context: { e: MouseEvent })` | 点击清空历史按钮回调。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) +scroll | `(context: { e: MouseEvent })` | 滚动事件的回调。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) + +### ChatInstanceFunctions 组件实例方法 + +名称 | 参数 | 返回值 | 描述 +-- | -- | -- | -- +scrollToBottom | `(params: ScrollToBottomParams)` | \- | 对话列表过长时,支持对话列表重新滚动回底部的方法。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts)。
` type ScrollToBottomParams = { behavior: 'auto' \| 'smooth'} `
+ + +### ChatLoading Props + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +animation | String | gradient | 加载的状态形式。可选项:moving/gradient | N +text | String | - | 加载过程展示的文字内容 | N + + +### ChatItem Props + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +actions | String / Slot / Function | - | 自定义的操作内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +animation | String | skeleton | 动画效果,支持「渐变加载动画」,「闪烁加载动画」, 「骨架屏」三种。可选项:skeleton/moving/gradient | N +avatar | String / Object / Slot / Function | - | 自定义的头像配置。TS 类型:`String \| AvatarProps \| TNode `,[Avatar API Documents](./avatar?tab=api)。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts)。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +content | String / Slot / Function | - | 对话单元的内容。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +datetime | String / Slot / Function | - | 对话单元的时间配置。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +name | String / Slot / Function | - | 自定义的昵称。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +reasoning | String / Boolean / Object | false | 值为false不显示思维链,为string则显示内置推理内容交互,为对象则单独配置推理内容。TS 类型:`boolean \| TdChatReasoning ` ` interface TdChatReasoning { expandIconPlacement?: 'left' \| 'right';onExpandChange?: (isExpand: boolean) => void; collapsePanelProps?: Object } `。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +role | String | - | 角色,不同选项配置不同的样式,支持类型包括用户、助手、错误、模型切换、系统消息。可选项:user/assistant/error/model-change/system | N +textLoading | Boolean | false | 新消息是否处于加载状态,加载状态默认显示骨架屏,接口请求返回数据时请将新消息加载状态置为false | N +variant | String | text | 气泡框样式,支持基础、线框、文字三种类型。可选项:base/outline/text | N + + +### ChatContent Props + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +content | String | - | 聊天内容,支持 markdown 格式 | N +role | String | - | 角色,不同选项配置不同的样式,支持类型包括用户、助手、错误、模型切换、系统消息。可选项:user/assistant/error/model-change/system | N + + +### ChatAction Props + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +content | String | - | 被复制的内容 | N +disabled | Boolean | false | 操作按钮是否可点击 | N +isBad | Boolean | false | 是否点踩 | N +isGood | Boolean | false | 是否点赞 | N +operationBtn | Array | ["replay", "copy", "good", "bad"] | 操作按钮配置项,可配置操作按钮选项和顺序。TS 类型:`Array<'replay'\|'copy'\|'good'\|'bad'>` | N +onOperation | Function | | TS 类型:`(value:string, context: { e: MouseEvent }) => void`
点击点赞,点踩,复制,重新生成按钮时触发 | N + +### ChatAction Events + +名称 | 参数 | 描述 +-- | -- | -- +operation | `(value:string, context: { e: MouseEvent })` | 点击点赞,点踩,复制,重新生成按钮时触发 + + +### ChatInput Props + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +autofocus | Boolean | false | 输入框是否自动聚焦 | N +autosize | Boolean / Object | { minRows: 1, maxRows: 5 } | 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度。TS 类型:`boolean \| { minRows?: number; maxRows?: number }` | N +disabled | Boolean | false | 是否禁用输入框 | N +placeholder | String | - | 输入框默认文案 | N +stopDisabled | Boolean | false | 中止按钮是否可点击。等流式数据全部返回结束置为false,注意跟textLoading的控制时机不是同一个 | N +suffixIcon | Slot / Function | - | 发送按钮的自定义扩展。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +value | String | - | 输入框的值。支持语法糖 `v-model` | N +defaultValue | String | - | 输入框的值。非受控属性 | N +onBlur | Function | | TS 类型:`(value:string, context: { e: FocusEvent }) => void`
输入框聚焦时触发 | N +onChange | Function | | TS 类型:`(value:string, context: { e: InputEvent \| MouseEvent \| KeyboardEvent }) => void`
输入框值发生变化时触发 | N +onFocus | Function | | TS 类型:`(value:string, context: { e: FocusEvent }) => void`
输入框聚焦时触发 | N +onSend | Function | | TS 类型:`(value:string, context: { e: MouseEvent \| KeyboardEvent }) => void`
点击消息发送的回调方法 | N +onStop | Function | | TS 类型:`(value:string, context: { e: MouseEvent }) => void`
点击消息终止的回调方法 | N + +### ChatInput Events + +名称 | 参数 | 描述 +-- | -- | -- +blur | `(value:string, context: { e: FocusEvent })` | 输入框聚焦时触发 +change | `(value:string, context: { e: InputEvent \| MouseEvent \| KeyboardEvent })` | 输入框值发生变化时触发 +focus | `(value:string, context: { e: FocusEvent }) ` | 输入框聚焦时触发 +send | `(value:string, context: { e: MouseEvent \| KeyboardEvent })` | 点击消息发送的回调方法 +stop | `(value:string, context: { e: MouseEvent })` | 点击消息终止的回调方法 + + +### ChatSender Props + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +disabled | Boolean | false | 是否禁用输入框 | N +placeholder | String | - | 输入框默认文案 | N +prefix | String / Slot / Function | - | 输入框左下角区域扩展。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +stopDisabled | Boolean | false | 中止按钮是否可点击。等流式数据全部返回结束置为false,注意跟textLoading的控制时机不是同一个 | N +suffix | String / Slot / Function | - | 输入框右下角区域扩展。TS 类型:`string \| TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +textareaProps | Object | - | 透传给 Textarea 组件的全部属性。TS 类型:`TextareaProps`,[Textarea API Documents](./textarea?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +value | String | - | 输入框的值。支持语法糖 `v-model` | N +defaultValue | String | - | 输入框的值。非受控属性 | N +onBlur | Function | | TS 类型:`(value:string, context: { e: FocusEvent }) => void`
输入框聚焦时触发 | N +onChange | Function | | TS 类型:`(value:string, context: { e: InputEvent \| MouseEvent \| KeyboardEvent }) => void`
输入框值发生变化时触发 | N +onFocus | Function | | TS 类型:`(value:string, context: { e: FocusEvent }) => void`
输入框聚焦时触发 | N +onSend | Function | | TS 类型:`(value:string, context: { e: MouseEvent \| KeyboardEvent }) => void`
点击消息发送的回调方法 | N +onStop | Function | | TS 类型:`(value:string, context: { e: MouseEvent }) => void`
点击消息终止的回调方法 | N + +### ChatSender Events + +名称 | 参数 | 描述 +-- | -- | -- +blur | `(value:string, context: { e: FocusEvent })` | 输入框聚焦时触发 +change | `(value:string, context: { e: InputEvent \| MouseEvent \| KeyboardEvent })` | 输入框值发生变化时触发 +focus | `(value:string, context: { e: FocusEvent }) ` | 输入框聚焦时触发 +send | `(value:string, context: { e: MouseEvent \| KeyboardEvent })` | 点击消息发送的回调方法 +stop | `(value:string, context: { e: MouseEvent })` | 点击消息终止的回调方法 + + +### ChatReasoning Props + +名称 | 类型 | 默认值 | 描述 | 必传 +-- | -- | -- | -- | -- +collapsePanelProps | Object | { destroyOnCollapse: false } | 透传给 CollapsePanel 组件的全部属性。TS 类型:`CollapsePanelProps`,[Collapse API Documents](./collapse?tab=api)。[详细类型定义](https://github.com/Tencent/tdesign-vue/tree/develop/src/chat/type.ts) | N +expand | Boolean | - | 支持语法糖 `.sync` | N +defaultExpand | Boolean | - | 非受控属性 | N +expandIcon | Slot / Function | - | 当前折叠面板展开图标。优先级低于collapsePanelProps.expandIcon。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +expandIconPlacement | String | right | 展开图标位置,可选项:left/right。可选项:left/right | N +header | Slot / Function | - | 折叠面板头内容。优先级低于collapsePanelProps.header。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +headerRightContent | Slot / Function | - | 折叠面板尾内容。优先级低于collapsePanelProps.headerRightContent。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N +onExpandChange | Function | | TS 类型:`(value: boolean) => void`
展开图标点击事件。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) | N + +### ChatReasoning Events + +名称 | 参数 | 描述 +-- | -- | -- +expand-change | `(value: boolean)` | 展开图标点击事件。TS 类型:`TNode`。[通用类型定义](https://github.com/Tencent/tdesign-vue/blob/develop/src/common.ts) diff --git a/packages/products/tdesign-vue/src/chat/props.ts b/packages/products/tdesign-vue/src/chat/props.ts new file mode 100644 index 000000000..b269207a5 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/props.ts @@ -0,0 +1,75 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { TdChatProps } from './type'; +import { PropType } from 'vue'; + +export default { + /** 自定义操作按钮的插槽 */ + actions: { + type: Function as PropType, + }, + /** 动画效果,支持「渐变加载动画」,「闪烁加载动画」, 「骨架屏」三种 */ + animation: { + type: String as PropType, + default: 'skeleton' as TdChatProps['animation'], + validator(val: TdChatProps['animation']): boolean { + if (!val) return true; + return ['skeleton', 'moving', 'gradient'].includes(val); + }, + }, + /** 自定义每个对话单元的头像插槽 */ + avatar: { + type: Function as PropType, + }, + /** 是否显示清空历史 */ + clearHistory: { + type: Boolean, + default: true, + }, + /** 自定义每个对话单独的聊天内容 */ + content: { + type: Function as PropType, + }, + /** 对话列表的数据 */ + data: { + type: Array as PropType, + }, + /** 自定义每个对话单元的时间 */ + datetime: { + type: Function as PropType, + }, + /** 流式加载是否结束 */ + isStreamLoad: Boolean, + /** 对话布局形式,支持两侧对齐与左对齐 */ + layout: { + type: String as PropType, + default: 'both' as TdChatProps['layout'], + validator(val: TdChatProps['layout']): boolean { + if (!val) return true; + return ['both', 'single'].includes(val); + }, + }, + /** 自定义每个对话单元的昵称 */ + name: { + type: Function as PropType, + }, + /** 自定义每个对话单元的思考过程的插槽 */ + reasoning: { + type: Function as PropType, + }, + /** 是否表现为倒序 */ + reverse: { + type: Boolean, + default: true, + }, + /** 新消息是否处于加载状态,加载状态默认显示骨架屏,接口请求返回数据时请将新消息加载状态置为false */ + textLoading: Boolean, + /** 点击清空历史按钮回调 */ + onClear: Function as PropType, + /** 滚动事件的回调 */ + onScroll: Function as PropType, +}; diff --git a/packages/products/tdesign-vue/src/chat/type.ts b/packages/products/tdesign-vue/src/chat/type.ts new file mode 100644 index 000000000..730845282 --- /dev/null +++ b/packages/products/tdesign-vue/src/chat/type.ts @@ -0,0 +1,367 @@ +/* eslint-disable */ + +/** + * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC + * */ + +import { AvatarProps } from '../avatar'; +import { TextareaProps } from '../textarea'; +import { CollapsePanelProps } from '../collapse'; +import { TNode } from '../common'; + +export interface TdChatProps { + /** + * 自定义操作按钮的插槽 + */ + actions?: TNode; + /** + * 动画效果,支持「渐变加载动画」,「闪烁加载动画」, 「骨架屏」三种 + * @default skeleton + */ + animation?: 'skeleton' | 'moving' | 'gradient'; + /** + * 自定义每个对话单元的头像插槽 + */ + avatar?: TNode<{ item: TdChatItemProps; index: number }>; + /** + * 是否显示清空历史 + * @default true + */ + clearHistory?: boolean; + /** + * 自定义每个对话单独的聊天内容 + */ + content?: TNode<{ item: TdChatItemProps; index: number }>; + /** + * 对话列表的数据 + */ + data?: Array; + /** + * 自定义每个对话单元的时间 + */ + datetime?: TNode<{ item: TdChatItemProps; index: number }>; + /** + * 流式加载是否结束 + * @default false + */ + isStreamLoad?: boolean; + /** + * 对话布局形式,支持两侧对齐与左对齐 + * @default both + */ + layout?: 'both' | 'single'; + /** + * 自定义每个对话单元的昵称 + */ + name?: TNode<{ item: TdChatItemProps; index: number }>; + /** + * 自定义每个对话单元的思考过程的插槽 + */ + reasoning?: TNode<{ item: TdChatItemProps; index: number }>; + /** + * 是否表现为倒序 + * @default true + */ + reverse?: boolean; + /** + * 新消息是否处于加载状态,加载状态默认显示骨架屏,接口请求返回数据时请将新消息加载状态置为false + * @default false + */ + textLoading?: boolean; + /** + * 点击清空历史按钮回调 + */ + onClear?: (context: { e: MouseEvent }) => void; + /** + * 滚动事件的回调 + */ + onScroll?: (context: { e: MouseEvent }) => void; +} + +/** 组件实例方法 */ +export interface ChatInstanceFunctions { + /** + * 对话列表过长时,支持对话列表重新滚动回底部的方法 + */ + scrollToBottom?: (params: ScrollToBottomParams) => void; +} + +export interface TdChatLoadingProps { + /** + * 加载的状态形式 + * @default gradient + */ + animation?: 'moving' | 'gradient'; + /** + * 加载过程展示的文字内容 + * @default '' + */ + text?: string; +} + +export interface TdChatItemProps { + /** + * 自定义的操作内容 + */ + actions?: string | TNode; + /** + * 动画效果,支持「渐变加载动画」,「闪烁加载动画」, 「骨架屏」三种 + * @default skeleton + */ + animation?: 'skeleton' | 'moving' | 'gradient'; + /** + * 自定义的头像配置 + */ + avatar?: String | AvatarProps | TNode; + /** + * 对话单元的内容 + */ + content?: string | TNode; + /** + * 对话单元的时间配置 + */ + datetime?: string | TNode; + /** + * 自定义的昵称 + */ + name?: string | TNode; + /** + * 值为false不显示思维链,为string则显示内置推理内容交互,为对象则单独配置推理内容 + * @default false + */ + reasoning?: boolean | TdChatReasoning; + /** + * 角色,不同选项配置不同的样式,支持类型包括用户、助手、错误、模型切换、系统消息 + */ + role?: 'user' | 'assistant' | 'error' | 'model-change' | 'system'; + /** + * 新消息是否处于加载状态,加载状态默认显示骨架屏,接口请求返回数据时请将新消息加载状态置为false + * @default false + */ + textLoading?: boolean; + /** + * 气泡框样式,支持基础、线框、文字三种类型 + * @default text + */ + variant?: 'base' | 'outline' | 'text'; +} + +export interface TdChatContentProps { + /** + * 聊天内容,支持 markdown 格式 + * @default '' + */ + content?: string; + /** + * 角色,不同选项配置不同的样式,支持类型包括用户、助手、错误、模型切换、系统消息 + */ + role?: 'user' | 'assistant' | 'error' | 'model-change' | 'system'; +} + +export interface TdChatActionProps { + /** + * 被复制的内容 + * @default '' + */ + content?: string; + /** + * 操作按钮是否可点击 + * @default false + */ + disabled?: boolean; + /** + * 是否点踩 + * @default false + */ + isBad?: boolean; + /** + * 是否点赞 + * @default false + */ + isGood?: boolean; + /** + * 操作按钮配置项,可配置操作按钮选项和顺序 + * @default ["replay", "copy", "good", "bad"] + */ + operationBtn?: Array<'replay' | 'copy' | 'good' | 'bad'>; + /** + * 点击点赞,点踩,复制,重新生成按钮时触发 + */ + onOperation?: (value: string, context: { e: MouseEvent }) => void; +} + +export interface TdChatInputProps { + /** + * 输入框是否自动聚焦 + * @default false + */ + autofocus?: boolean; + /** + * 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度 + * @default { minRows: 1, maxRows: 5 } + */ + autosize?: boolean | { minRows?: number; maxRows?: number }; + /** + * 是否禁用输入框 + * @default false + */ + disabled?: boolean; + /** + * 输入框默认文案 + * @default '' + */ + placeholder?: string; + /** + * 中止按钮是否可点击。等流式数据全部返回结束置为false,注意跟textLoading的控制时机不是同一个 + * @default false + */ + stopDisabled?: boolean; + /** + * 发送按钮的自定义扩展 + */ + suffixIcon?: TNode; + /** + * 输入框的值 + * @default '' + */ + value?: string; + /** + * 输入框的值,非受控属性 + * @default '' + */ + defaultValue?: string; + /** + * 输入框聚焦时触发 + */ + onBlur?: (value: string, context: { e: FocusEvent }) => void; + /** + * 输入框值发生变化时触发 + */ + onChange?: (value: string, context: { e: InputEvent | MouseEvent | KeyboardEvent }) => void; + /** + * 输入框聚焦时触发 + */ + onFocus?: (value: string, context: { e: FocusEvent }) => void; + /** + * 点击消息发送的回调方法 + */ + onSend?: (value: string, context: { e: MouseEvent | KeyboardEvent }) => void; + /** + * 点击消息终止的回调方法 + */ + onStop?: (value: string, context: { e: MouseEvent }) => void; +} + +export interface TdChatSenderProps { + /** + * 是否禁用输入框 + * @default false + */ + disabled?: boolean; + /** + * 输入框默认文案 + * @default '' + */ + placeholder?: string; + /** + * 输入框左下角区域扩展 + */ + prefix?: string | TNode; + /** + * 中止按钮是否可点击。等流式数据全部返回结束置为false,注意跟textLoading的控制时机不是同一个 + * @default false + */ + stopDisabled?: boolean; + /** + * 输入框右下角区域扩展 + */ + suffix?: string | TNode; + /** + * 透传给 Textarea 组件的全部属性 + */ + textareaProps?: TextareaProps; + /** + * 输入框的值 + * @default '' + */ + value?: string; + /** + * 输入框的值,非受控属性 + * @default '' + */ + defaultValue?: string; + /** + * 输入框聚焦时触发 + */ + onBlur?: (value: string, context: { e: FocusEvent }) => void; + /** + * 输入框值发生变化时触发 + */ + onChange?: (value: string, context: { e: InputEvent | MouseEvent | KeyboardEvent }) => void; + /** + * 输入框聚焦时触发 + */ + onFocus?: (value: string, context: { e: FocusEvent }) => void; + /** + * 点击消息发送的回调方法 + */ + onSend?: (value: string, context: { e: MouseEvent | KeyboardEvent }) => void; + /** + * 点击消息终止的回调方法 + */ + onStop?: (value: string, context: { e: MouseEvent }) => void; +} + +export interface TdChatReasoningProps { + /** + * 透传给 CollapsePanel 组件的全部属性 + * @default { destroyOnCollapse: false } + */ + collapsePanelProps?: CollapsePanelProps; + /** + * null + */ + expand?: boolean; + /** + * null,非受控属性 + */ + defaultExpand?: boolean; + /** + * 当前折叠面板展开图标。优先级低于collapsePanelProps.expandIcon + */ + expandIcon?: TNode; + /** + * 展开图标位置,可选项:left/right + * @default right + */ + expandIconPlacement?: 'left' | 'right'; + /** + * 折叠面板头内容。优先级低于collapsePanelProps.header + */ + header?: TNode; + /** + * 折叠面板尾内容。优先级低于collapsePanelProps.headerRightContent + */ + headerRightContent?: TNode; + /** + * 展开图标点击事件 + */ + onExpandChange?: (value: boolean) => void; +} + +export interface TdChatItemMeta { + avatar?: string; + name?: string; + role?: string; + datetime?: string; + content?: string; + reasoning?: string; +} + +export type ScrollToBottomParams = { behavior: 'auto' | 'smooth' }; + +export interface TdChatReasoning { + expandIconPlacement?: 'left' | 'right'; + onExpandChange?: (isExpand: boolean) => void; + collapsePanelProps?: Object; +} diff --git a/packages/scripts/api.json b/packages/scripts/api.json index 7d3db426b..97ec7ef3a 100644 --- a/packages/scripts/api.json +++ b/packages/scripts/api.json @@ -26504,6 +26504,47 @@ "Object" ] }, + { + "id": 1744966447, + "platform_framework": [ + "1", + "2", + "4" + ], + "component": "ChatReasoning", + "field_category": 1, + "field_name": "expand", + "field_type": [ + "4" + ], + "field_default_value": "", + "field_enum": "", + "field_desc_zh": null, + "field_desc_en": null, + "field_required": 0, + "event_input": "", + "create_time": "2025-04-18 08:54:07", + "update_time": "2025-04-18 08:54:07", + "event_output": null, + "custom_field_type": null, + "syntactic_sugar": "sync", + "readonly": 1, + "html_attribute": 0, + "trigger_elements": "", + "deprecated": 0, + "version": "", + "test_description": null, + "support_default_value": 1, + "field_category_text": "Props", + "platform_framework_text": [ + "Vue(PC)", + "React(PC)", + "Angular(PC)" + ], + "field_type_text": [ + "Boolean" + ] + }, { "id": 1742886498, "platform_framework": [ @@ -26686,7 +26727,7 @@ "field_desc_zh": "展开图标点击事件", "field_desc_en": null, "field_required": 0, - "event_input": "(value: CollapseValue)【import { CollapseValue } from '@Collapse'】", + "event_input": "(value: boolean)", "create_time": "2025-03-25 07:08:56", "update_time": "2025-03-25 07:08:56", "event_output": null,