Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,10 @@ Component({
data: markdownData,
},
},
methods: {},
methods: {
onClick(e) {
const { node } = e.detail;
console.log('点击节点', node);
},
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
<view class="chat-example">
<view class="title">助手内容(Markdown)</view>
<view class="chat-example-block">
<t-chat-content content="{{assistantContent}}" role="assistant"></t-chat-content>
<t-chat-content content="{{assistantContent}}" role="assistant" bindclick="onClick"></t-chat-content>
</view>
</view>
3 changes: 3 additions & 0 deletions packages/pro-components/chat/chat-content/chat-content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ export default class ChatContent extends SuperComponent {
return html;
},

onMarkdownClick(e) {
this.triggerEvent('click', e.detail);
},
setTextInfo() {
// error 状态下统一按纯文本处理,避免走 markdown 渲染
if (this.properties.content.type === 'text' || this.properties.status === 'error') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</block>
<block wx:else>
<view class="{{classPrefix}}__assistant">
<t-chat-markdown content="{{textInfo}}" options="{{markdownProps && markdownProps.options}}"></t-chat-markdown>
<t-chat-markdown content="{{textInfo}}" options="{{markdownProps && markdownProps.options}}" bindclick="onMarkdownClick"></t-chat-markdown>
</view>
</block>
</view>
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ Component({
e.detail.chatId = this.data.activePopoverId;
this.handleAction(e);
},
onClick(e) {
const { node } = e.detail;
console.log('点击节点', node);
},
},
lifetimes: {
attached: function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
placement="{{item.role === 'user' ? 'right' : 'left'}}"
status="{{item.status || ''}}"
bind:message-longpress="showPopover"
bind:click="onClick"
>
<t-chat-actionbar
wx:if="{{index !== chatList.length - 1 && item.status === 'complete' && item.role === 'assistant'}}"
Expand Down
3 changes: 3 additions & 0 deletions packages/pro-components/chat/chat-message/chat-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ export default class ChatMessage extends SuperComponent {
},
});
},
onContentClick(e) {
this.triggerEvent('click', e.detail);
},
setShowAvatar() {
this.setData({
showAvatar: this.properties?.avatar || '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
content="{{item}}"
role="{{role}}"
status="{{status}}"
catchclick="onContentClick"
></chat-content>
</block>
</block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<t-chat-content
:content="assistantContent"
role="assistant"
@click="onClick"
/>
</view>
</view>
Expand Down Expand Up @@ -83,7 +84,12 @@ export default {
};
},
created() {},
methods: {},
methods: {
onClick(e) {
const { node } = e;
console.log('点击节点', node);
},
},
};
</script>
<style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<view
:class="classPrefix"
:style="'' + tools._style([customStyle])"
@click.stop
>
<block v-if="status === 'error' || content.type === 'text'">
<view :class="classPrefix + '__' + role + ' ' + classPrefix + '__' + status">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:placement="item.role === 'user' ? 'right' : 'left'"
:status="item.status || ''"
@message-longpress="showPopover"
@click="onClick"
>
<template #actionbar>
<t-chat-actionbar
Expand Down Expand Up @@ -359,6 +360,11 @@ export default {
e.chatId = this.activePopoverId;
this.handleAction(e);
},

onClick(e) {
const { node } = e;
console.log('点击节点', node);
},
},
};
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
:content="item"
:role="role"
:status="status === 'error' ? 'error' : ''"
@click.stop="onContentClick"
/>
</block>
</block>
Expand Down Expand Up @@ -112,6 +113,12 @@ export default {
props: {
...props,
},

emits: [
'message-longpress',
'click',
],

data() {
return {
classPrefix: name,
Expand Down Expand Up @@ -146,6 +153,10 @@ export default {
},

methods: {
onContentClick(e) {
this.$emit('click', e);
},

handleLongPress(e) {
this.$emit('message-longpress', {
e,
Expand Down
Loading