From 278645230a9e4218e2ddd769197c1c63fb78fd28 Mon Sep 17 00:00:00 2001 From: jing <1683105490@qq.com> Date: Mon, 14 Sep 2026 08:57:45 +0800 Subject: [PATCH] =?UTF-8?q?chore=EF=BC=9A=E5=9B=9E=E7=AD=94=E8=A1=8C?= =?UTF-8?q?=E8=B7=9D=E5=8F=98=E5=B0=8F=EF=BC=8C=E5=8A=A0=E4=B8=8A=E6=B0=94?= =?UTF-8?q?=E6=B3=A1=EF=BC=8C=E9=9A=90=E8=97=8F=E6=B0=94=E6=B3=A1=E4=B8=8B?= =?UTF-8?q?=E9=9D=A2=E7=9A=84"..."?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages_tool/ai-chat/ai-chat-message.vue | 58 ++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/pages_tool/ai-chat/ai-chat-message.vue b/pages_tool/ai-chat/ai-chat-message.vue index 3ce309c..33dd9a1 100644 --- a/pages_tool/ai-chat/ai-chat-message.vue +++ b/pages_tool/ai-chat/ai-chat-message.vue @@ -1219,6 +1219,18 @@ _handleStreamError(msg) { const TEXT = '#1a1a1a' const LINK = '#3a7afe' + // 微信小程序端: 回答更紧凑 (行高/段距收紧, 不改变颜色与字号) + let COMPACT = false + /* #ifdef MP-WEIXIN */ + COMPACT = true + /* #endif */ + const LH = COMPACT ? '1.6' : '1.75' + const LI_LH = COMPACT ? '1.55' : '1.75' + const P_MARGIN = COMPACT ? '1rpx 0' : '2rpx 0' + const HR_MARGIN = COMPACT ? '10rpx 0' : '16rpx 0' + const BQ_MARGIN = COMPACT ? '6rpx 0' : '8rpx 0' + const BQ_LH = COMPACT ? '1.6' : '1.7' + // 辅助:内联格式处理 // 思路: 先把"链接/图片/裸URL/电话"整体抽成占位符保护起来, 再做加粗/斜体等, // 最后还原, 避免各规则互相串改对方的 href / 数字。 @@ -1300,7 +1312,7 @@ _handleStreamError(msg) { while (buf.length > 0 && buf[buf.length - 1] === '') buf.pop() if (buf.length === 0) return const content = buf.map(l => parseInline(l)).join('
') - out.push(`
${content}
`) + out.push(`
${content}
`) buf = [] } const flushTable = () => { @@ -1355,7 +1367,7 @@ _handleStreamError(msg) { const lv = hMatch[1].length const size = ['', '36rpx', '32rpx', '30rpx', '28rpx', '26rpx', '24rpx'][lv] const wgt = ['', '700', '700', '600', '600', '500', '500'][lv] - const mg = ['', '20rpx 0 10rpx', '16rpx 0 8rpx', '14rpx 0 6rpx', '12rpx 0 6rpx', '10rpx 0 4rpx', '8rpx 0 4rpx'][lv] + const mg = COMPACT ? ['', '14rpx 0 7rpx', '12rpx 0 6rpx', '10rpx 0 5rpx', '8rpx 0 5rpx', '7rpx 0 3rpx', '6rpx 0 3rpx'][lv] : ['', '20rpx 0 10rpx', '16rpx 0 8rpx', '14rpx 0 6rpx', '12rpx 0 6rpx', '10rpx 0 4rpx', '8rpx 0 4rpx'][lv] out.push(`${parseInline(hMatch[2])}`) continue } @@ -1363,7 +1375,7 @@ _handleStreamError(msg) { // 分隔线 if (/^(-{3,}|\*{3,}|_{3,})\s*$/.test(trimmed)) { flushBuf(); out.push(closeList()) - out.push('
') + out.push('
') continue } @@ -1371,7 +1383,7 @@ _handleStreamError(msg) { const bqMatch = line.match(/^>\s?(.+)$/) if (bqMatch) { flushBuf(); out.push(closeList()) - out.push(`
${parseInline(bqMatch[1])}
`) + out.push(`
${parseInline(bqMatch[1])}
`) continue } @@ -1380,7 +1392,7 @@ _handleStreamError(msg) { if (ulMatch) { flushBuf() if (!inList) { out.push('