Skip to content

Commit dce1e64

Browse files
authored
Feature/markdown stream tail (#4390)
* feat: 新增tail功能 * feat: list示例更新 * feat: 新增小程序端tail-component抽象组件 * feat: tail示例 * feat: table和code节点内光标 * feat: uniapp端tail示例 * feat: 示例调整 * feat: 光标样式调整
1 parent 686b5d6 commit dce1e64

51 files changed

Lines changed: 657 additions & 34 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
{
22
"component": true,
33
"styleIsolation": "apply-shared",
4+
"componentGenerics": {
5+
"tail-component": {
6+
"default": "tdesign-miniprogram/chat-markdown/chat-markdown-tail/chat-markdown-tail"
7+
}
8+
},
49
"usingComponents": {
510
"t-chat-markdown": "tdesign-miniprogram/chat-markdown/chat-markdown"
611
}
7-
}
12+
}

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@
1010
</block>
1111
<block wx:else>
1212
<view class="{{classPrefix}}__assistant">
13-
<t-chat-markdown content="{{textInfo}}" options="{{markdownProps && markdownProps.options}}" bindclick="onMarkdownClick"></t-chat-markdown>
13+
<t-chat-markdown
14+
content="{{textInfo}}"
15+
options="{{markdownProps && markdownProps.options}}"
16+
streaming="{{markdownProps && markdownProps.streaming}}"
17+
generic:tail-component="tail-component"
18+
bindclick="onMarkdownClick"
19+
></t-chat-markdown>
1420
</view>
1521
</block>
1622
</view>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Component({
2+
properties: {},
3+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"component": true,
3+
"styleIsolation": "apply-shared"
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- 自定义光标组件示例:渲染一个彩色方块光标 -->
2+
<text class="custom-tail">●</text>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/* 自定义光标样式:蓝色渐变闪烁 */
2+
.custom-tail {
3+
display: inline-block;
4+
color: #0052d9;
5+
font-weight: bold;
6+
animation: custom-tail-blink 0.8s ease-in-out infinite;
7+
}
8+
9+
@keyframes custom-tail-blink {
10+
0%, 100% { opacity: 1; }
11+
50% { opacity: 0.2; }
12+
}

packages/pro-components/chat/chat-list/_example/docs/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ Component({
189189
},
190190
],
191191
},
192+
markdownProps: { streaming: { hasNextChunk: true, tail: true } },
192193
chatId: getUniqueKey(),
193194
};
194195

@@ -208,6 +209,7 @@ Component({
208209
complete() {
209210
that.setData({
210211
'chatList[0].message.status': 'complete',
212+
'chatList[0].markdownProps': {},
211213
loading: false,
212214
});
213215
},
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
{
22
"component": true,
33
"styleIsolation": "shared",
4+
"componentGenerics": {
5+
"tail-component": {
6+
"default": "./custom-tail/custom-tail"
7+
}
8+
},
49
"usingComponents": {
10+
"custom-tail": "./custom-tail/custom-tail",
511
"t-chat-message": "tdesign-miniprogram/chat-message/chat-message",
612
"t-chat-content": "tdesign-miniprogram/chat-content/chat-content",
713
"t-chat": "tdesign-miniprogram/chat-list/chat-list",
814
"t-chat-sender": "tdesign-miniprogram/chat-sender/chat-sender",
915
"t-chat-actionbar": "tdesign-miniprogram/chat-actionbar/chat-actionbar",
1016
"t-toast": "tdesign-miniprogram/toast/toast"
1117
}
12-
}
18+
}

packages/pro-components/chat/chat-list/_example/docs/index.wxml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,26 @@
66
avatar="{{item.avatar || ''}}"
77
name="{{item.name || ''}}"
88
datetime="{{item.datetime || ''}}"
9-
content="{{item.message.content}}"
109
role="{{item.message.role}}"
11-
chatContentProps="{{chatContentProps}}"
1210
placement="{{item.message.role === 'user' ? 'right' : 'left'}}"
1311
bind:message-longpress="showPopover"
1412
>
13+
<view slot="content">
14+
<block
15+
wx:for="{{item.message.content}}"
16+
wx:for-item="contentItem"
17+
wx:for-index="contentIndex"
18+
wx:key="contentIndex"
19+
>
20+
<t-chat-content
21+
wx:if="{{contentItem.type === 'text' || contentItem.type === 'markdown'}}"
22+
content="{{contentItem}}"
23+
role="{{item.message.role}}"
24+
markdownProps="{{item.markdownProps}}"
25+
generic:tail-component="custom-tail"
26+
/>
27+
</block>
28+
</view>
1529
<t-chat-actionbar
1630
wx:if="{{chatIndex !== chatList.length - 1 && item.message.status === 'complete' && item.message.role === 'assistant'}}"
1731
slot="actionbar"

0 commit comments

Comments
 (0)