From adafb6522175ca43597cc430c9cd2ac006d2888d Mon Sep 17 00:00:00 2001 From: chenchun Date: Wed, 28 Jan 2026 16:27:07 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96markdown=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Yi.Ai.Vue3/src/components/MarkedMarkdown/index.vue | 12 +++++------- .../src/pages/chat/layouts/chatWithId/index.vue | 10 +++------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/Yi.Ai.Vue3/src/components/MarkedMarkdown/index.vue b/Yi.Ai.Vue3/src/components/MarkedMarkdown/index.vue index 56a6a73c..b457c6ad 100644 --- a/Yi.Ai.Vue3/src/components/MarkedMarkdown/index.vue +++ b/Yi.Ai.Vue3/src/components/MarkedMarkdown/index.vue @@ -110,11 +110,6 @@ const renderer = { const titleAttr = title ? ` title="${title}"` : ''; return `${text}`; }, - - // 表格 - table(token: { header: string; body: string }) { - return `
${token.header}${token.body}
`; - }, }; marked.use({ renderer }); @@ -149,7 +144,10 @@ async function renderContent(content: string) { lastContent = content; try { - const rawHtml = await marked.parse(content); + let rawHtml = await marked.parse(content); + // 包装表格,添加 table-wrapper 以支持横向滚动 + rawHtml = rawHtml.replace(//g, '
'); + rawHtml = rawHtml.replace(/<\/table>/g, '
'); // 使用 DOMPurify 清理 HTML,防止 XSS renderedHtml.value = DOMPurify.sanitize(rawHtml, { ADD_TAGS: ['iframe'], @@ -649,7 +647,7 @@ onUnmounted(() => { font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace; font-size: 14px; //line-height: 21px; - height: 22.72px; + height: 22px; min-width: 40px; } } diff --git a/Yi.Ai.Vue3/src/pages/chat/layouts/chatWithId/index.vue b/Yi.Ai.Vue3/src/pages/chat/layouts/chatWithId/index.vue index 01017b85..a38b66be 100644 --- a/Yi.Ai.Vue3/src/pages/chat/layouts/chatWithId/index.vue +++ b/Yi.Ai.Vue3/src/pages/chat/layouts/chatWithId/index.vue @@ -202,13 +202,6 @@ function handleDataChunk(chunk: AnyObject) { latest.content += parsed.content; } } - - // 流式输出时保持滚动条在底部(等待 DOM 更新后再滚动) - nextTick(() => { - requestAnimationFrame(() => { - bubbleListRef.value?.scrollToBottom(); - }); - }); } catch (err) { console.error('解析数据时出错:', err); @@ -1248,4 +1241,7 @@ onUnmounted(() => { } } } +.footer-time .el-button{ + margin-left: 10px; +}