feat: 优化

This commit is contained in:
2026-01-18 18:43:25 +08:00
parent e050a960c5
commit 41ebb5017d
2 changed files with 54 additions and 47 deletions

View File

@@ -1,11 +1,8 @@
<template>
<div class="w-full h-full">
<!-- 主渲染区域 -->
<div
:class="{ 'streaming': isStreaming }"
>
<!-- 消息渲染器 - GitHub 风格 -->
<div :class="{ 'streaming': isStreaming }">
<div
ref="markdownContainer"
class="markdown-body"
:class="{ 'streaming': isStreaming }"
v-html="renderedContent"
@@ -39,6 +36,7 @@ const emit = defineEmits<{
const internalContent = ref('')
const renderedContent = ref('')
const isPageVisible = ref(true)
const markdownContainer = ref<HTMLElement | null>(null)
watch(() => props.content, (newContent) => {
if (newContent !== undefined && newContent !== null) {
@@ -96,9 +94,22 @@ async function renderContent(content: string) {
} else {
renderedContent.value = content.replace(/\n/g, '<br>')
}
setTimeout(() => {
scrollToBottom()
}, 0)
} catch (error) {
console.error('[ChatMessageRendererV2] 渲染错误:', error)
renderedContent.value = content
setTimeout(() => {
scrollToBottom()
}, 0)
}
}
function scrollToBottom() {
if (markdownContainer.value) {
markdownContainer.value.scrollTop = markdownContainer.value.scrollHeight
}
}