feat: 对话气泡增加引用摘要模块,解决多用户混杂交谈上下文不清晰问题
- 后端 ConversationMessage Record 新增 quoteOwner/quoteContent 字段 - 后端 getConversation 方法重写,构建 Reply 映射字典溯源引用关系 - 前端 ConversationMessage 类型定义新增 quoteOwner/quoteContent - 前端新增 truncateQuote 截断方法(复用 stripHtml,限30字符) - 前端对话气泡模板渲染灰色引用条(bg-black/5 + border-l-2)
This commit is contained in:
@@ -299,8 +299,19 @@
|
||||
:class="msg.isAi
|
||||
? 'bg-blue-50 text-gray-800 rounded-tl-md'
|
||||
: 'bg-gray-100 text-gray-800 rounded-tr-md'"
|
||||
v-html="renderContent(msg.content)"
|
||||
></div>
|
||||
>
|
||||
<!-- 引用摘要模块(仅当存在引用时显示) -->
|
||||
<div
|
||||
v-if="msg.quoteOwner && msg.quoteContent"
|
||||
class="mb-2 px-3 py-1.5 bg-black/5 rounded-lg border-l-2 border-gray-300 text-xs text-gray-500"
|
||||
>
|
||||
<span class="font-medium text-gray-600">@{{ msg.quoteOwner }}</span>:
|
||||
{{ truncateQuote(msg.quoteContent, 30) }}
|
||||
</div>
|
||||
|
||||
<!-- 实际回复内容 -->
|
||||
<div v-html="renderContent(msg.content)"></div>
|
||||
</div>
|
||||
<!-- Time -->
|
||||
<div class="text-[10px] text-gray-300 mt-1" :class="msg.isAi ? 'text-left' : 'text-right'">
|
||||
{{ formatDate(msg.time) }}
|
||||
@@ -358,6 +369,8 @@ interface ConversationMessage {
|
||||
content: string
|
||||
time: string
|
||||
isAi: boolean
|
||||
quoteOwner?: string
|
||||
quoteContent?: string
|
||||
}
|
||||
|
||||
const replies = ref<AiCommentReplyItem[]>([])
|
||||
@@ -639,6 +652,15 @@ const stripHtml = (html: string) => {
|
||||
.trim()
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate quote content for preview
|
||||
*/
|
||||
const truncateQuote = (content: string, length = 30) => {
|
||||
if (!content) return ""
|
||||
const plain = stripHtml(content)
|
||||
return plain.length > length ? plain.substring(0, length) + "..." : plain
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize and render HTML content for conversation bubbles.
|
||||
* Only allows safe inline tags, strips dangerous elements.
|
||||
|
||||
Reference in New Issue
Block a user