From e7dd6aff62c3d6b335ee2e8a424be8e59ef4537f Mon Sep 17 00:00:00 2001 From: jing <1683105490@qq.com> Date: Fri, 9 Oct 2026 16:56:05 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=E5=BE=AE=E4=BF=A1=E5=B0=8F?= =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E7=9A=84AI=E6=99=BA=E8=83=BD=E5=AE=A2?= =?UTF-8?q?=E6=9C=8D=E6=A0=87=E9=A2=98=E5=92=8C=E5=9B=BE=E7=89=87=E4=B9=8B?= =?UTF-8?q?=E9=97=B4=E6=9C=89=E8=B7=9D=E7=A6=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/ai-chat/ai-chat-message.vue | 31 ++++++++++++++++---------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index ecaffa6..fe0ee3b 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -234,10 +234,10 @@ - + - + @@ -250,10 +250,10 @@ - + - + @@ -3937,17 +3937,24 @@ _handleStreamError(msg) { }, // AI 消息渲染(含关键词高亮) - getAIDisplayContent(content) { + // isWelcome: 欢迎语消息 — 小程序端 mp-html 组件有样式隔离, 页面样式(::v-deep)进不去, + // 图片间距只能在内容层面改内联样式(机器人图片与下方标题的间距, 对齐 WorkBuddy 参考稿) + getAIDisplayContent(content, isWelcome) { + let html if (!this.searchKeyword || !content) { - return this.parseMarkdown(content) + html = this.parseMarkdown(content) + } else if (content.toLowerCase().indexOf(this.searchKeyword.toLowerCase()) === -1) { + html = this.parseMarkdown(content) + } else { + // 先做 markdown 渲染,再做关键词高亮 + const mdHtml = this.parseMarkdown(content) + html = this._wrapHighlightInHtml(mdHtml, this.searchKeyword) } - // 仅当内容包含关键词时才执行高亮,避免非匹配消息的额外处理 - if (content.toLowerCase().indexOf(this.searchKeyword.toLowerCase()) === -1) { - return this.parseMarkdown(content) + if (isWelcome && html) { + // 仅替换 img 的 margin(机器人图片), 不影响列表等其他元素的 margin:8rpx 0 + html = html.replace(/(]*style="[^"]*?)margin:\s*8rpx 0;/, '$1margin:0 0 48rpx 0;') } - // 先做 markdown 渲染,再做关键词高亮 - const mdHtml = this.parseMarkdown(content) - return this._wrapHighlightInHtml(mdHtml, this.searchKeyword) + return html }, // 在纯文本中高亮关键词(用于用户消息)