Skip to content

Commit 2e63f5e

Browse files
committed
feat: 更新聊天内容类型及界面插槽名称
1 parent f45535a commit 2e63f5e

File tree

2 files changed

+61
-18
lines changed

2 files changed

+61
-18
lines changed

packages/pro-components/chat/chat-actionbar/chat-actionbar.wxml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<wxs src="../../../components/common/utils.wxs" module="_" />
2-
<!-- TODO: api 可选项没有 longpress,这部分是否可移除? -->
2+
<!-- TODO: api 可选项 longpress 下个版本迭代发布长按气泡样式 -->
33
<view
44
class="class {{[classPrefix, placement==='longpress' ? classPrefix+'__inner--popover' : '', computedPlacement]}}"
55
style="{{_._style([style, customStyle])}}"
66
>
77
<view class="{{classPrefix}}__inner {{classPrefix}}__inner--column">
88
<view class="{{classPrefix}}__item {{classPrefix}}__left">
9-
<!-- TODO: 推荐改成 prefix 表示前缀插槽 -->
10-
<slot name="left" />
9+
<slot name="prefix" />
1110
</view>
1211
<block wx:for="{{actions}}" wx:for-item="item" wx:for-index="index" wx:key="index">
1312
<!-- 分享按钮使用 button 标签 -->

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

Lines changed: 59 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,69 @@
44
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
55
* */
66
import { TdChatLoadingProps } from '../chat-loading/type';
7-
import { TdChatAttachmentsProps } from '../attachments/type';
7+
import { TdChatAttachmentsProps, FileItem } from '../attachments/type';
88

9-
export type ChatContentType = 'text' | 'markdown' | 'search' | 'thinking' | 'suggestion' | 'attachment';
9+
export type ChatContentType =
10+
| 'text'
11+
| 'markdown'
12+
| 'thinking'
13+
| 'attachment'
1014

11-
// todo: 下个版本
12-
// export interface TdChatMarkdownContentProps {
13-
// content: string;
14-
// [key: string]: any;
15-
// }
15+
export type ChatMessageStatus = 'pending' | 'streaming' | 'complete' | 'stop' | 'error';
1616

17-
// export interface TdChatContentSearchProps {
18-
// query: string;
19-
// results: any[];
20-
// [key: string]: any;
21-
// }
17+
/**
18+
* 基础内容结构,所有内容类型都遵循此结构
19+
*/
20+
export interface ChatBaseContent<T extends ChatContentType, TData> {
21+
type: T;
22+
data: TData;
23+
}
24+
25+
/**
26+
* 思考内容数据结构
27+
*/
28+
export interface ThinkingContentData {
29+
/**
30+
* 思考标题
31+
*/
32+
title?: string;
33+
/**
34+
* 思考内容文本
35+
*/
36+
text: string;
37+
}
38+
39+
/**
40+
* 文本内容类型
41+
*/
42+
export type TextContent = ChatBaseContent<'text', string>;
43+
44+
/**
45+
* Markdown内容类型
46+
*/
47+
export type MarkdownContent = ChatBaseContent<'markdown', string>;
48+
49+
/**
50+
* 思考内容类型
51+
*/
52+
export type ThinkingContent = ChatBaseContent<'thinking', ThinkingContentData>;
53+
54+
/**
55+
* 附件内容类型
56+
*/
57+
export type AttachmentContent = ChatBaseContent<'attachment', FileItem[]>;
58+
59+
/**
60+
* 消息内容联合类型
61+
*/
62+
export type MessageContent = TextContent | MarkdownContent | ThinkingContent | AttachmentContent;
2263

2364
export type TdChatContentThinkProps = {
2465
maxHeight?: number;
2566
animation?: TdChatLoadingProps['animation'];
2667
collapsed?: boolean;
2768
layout?: 'block' | 'border';
69+
status?: 'pending' | 'complete' ;
2870
};
2971

3072
export type TdChatContentProps = {
@@ -73,12 +115,14 @@ export interface TdChatMessageProps {
73115
value?: 'base' | 'outline' | 'text';
74116
};
75117
/**
76-
* 消息内容对象 todo: 需要完善
77-
* @default {}
118+
* 消息内容对象,支持多种内容类型的数组
119+
* - 用户消息:TextContent | AttachmentContent
120+
* - AI消息:TextContent | MarkdownContent | ThinkingContent | AttachmentContent
121+
* @default []
78122
*/
79123
content?: {
80124
type: ArrayConstructor;
81-
value?: Array<any>;
125+
value?: MessageContent[];
82126
};
83127
role?: {
84128
type: StringConstructor;

0 commit comments

Comments
 (0)