feat: 优化
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user