chore:回答行距变小,加上气泡,隐藏气泡下面的"..."

This commit is contained in:
2026-09-14 08:57:45 +08:00
parent 21ee661cef
commit 278645230a

View File

@@ -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('<br>')
out.push(`<div style="line-height:1.75;font-size:30rpx;color:${TEXT};margin:2rpx 0;">${content}</div>`)
out.push(`<div style="line-height:${LH};font-size:30rpx;color:${TEXT};margin:${P_MARGIN};">${content}</div>`)
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(`<h${lv} style="font-size:${size};font-weight:${wgt};margin:${mg};line-height:1.35;color:${TEXT};">${parseInline(hMatch[2])}</h${lv}>`)
continue
}
@@ -1363,7 +1375,7 @@ _handleStreamError(msg) {
// 分隔线
if (/^(-{3,}|\*{3,}|_{3,})\s*$/.test(trimmed)) {
flushBuf(); out.push(closeList())
out.push('<hr style="border:none;border-top:2rpx solid #eaecef;margin:16rpx 0;">')
out.push('<hr style="border:none;border-top:2rpx solid #eaecef;margin:${HR_MARGIN};">')
continue
}
@@ -1371,7 +1383,7 @@ _handleStreamError(msg) {
const bqMatch = line.match(/^>\s?(.+)$/)
if (bqMatch) {
flushBuf(); out.push(closeList())
out.push(`<blockquote style="border-left:4rpx solid #d0d7de;padding:8rpx 16rpx;margin:8rpx 0;background:#f6f8fa;color:#57606a;line-height:1.7;font-size:28rpx;border-radius:0 6rpx 6rpx 0;">${parseInline(bqMatch[1])}</blockquote>`)
out.push(`<blockquote style="border-left:4rpx solid #d0d7de;padding:8rpx 16rpx;margin:${BQ_MARGIN};background:#f6f8fa;color:#57606a;line-height:${BQ_LH};font-size:28rpx;border-radius:0 6rpx 6rpx 0;">${parseInline(bqMatch[1])}</blockquote>`)
continue
}
@@ -1380,7 +1392,7 @@ _handleStreamError(msg) {
if (ulMatch) {
flushBuf()
if (!inList) { out.push('<ul style="padding-left:30rpx;margin:8rpx 0;color:' + TEXT + ';">'); inList = 'ul' }
out.push(`<li style="margin:5rpx 0;line-height:1.75;font-size:30rpx;">${parseInline(ulMatch[1])}</li>`)
out.push(`<li style="margin:5rpx 0;line-height:${LI_LH};font-size:30rpx;">${parseInline(ulMatch[1])}</li>`)
continue
}
@@ -1389,7 +1401,7 @@ _handleStreamError(msg) {
if (olMatch) {
flushBuf()
if (!inList) { out.push('<ol style="padding-left:30rpx;margin:8rpx 0;color:' + TEXT + ';">'); inList = 'ol' }
out.push(`<li style="margin:5rpx 0;line-height:1.75;font-size:30rpx;">${parseInline(olMatch[1])}</li>`)
out.push(`<li style="margin:5rpx 0;line-height:${LI_LH};font-size:30rpx;">${parseInline(olMatch[1])}</li>`)
continue
}
@@ -3205,9 +3217,9 @@ _handleStreamError(msg) {
line-height: 1;
}
&.more-btn .iconfont {
font-size: 32rpx;
letter-spacing: -2rpx;
/* 隐藏"更多(···)"按钮: 只保留 复制 / 点赞 / 不喜欢 */
&.more-btn {
display: none !important;
}
&.active {
@@ -3942,4 +3954,32 @@ _handleStreamError(msg) {
letter-spacing: 0.8rpx;
}
}
/* ========== AI 回答: 高级质感卡片 (替换生硬蓝框, 更大气) ==========
微渐变卡面 + 极细中性描边 + 多层柔和阴影 + 24rpx 大圆角, 去掉高饱和蓝框 */
.ai-chat-container .chat-messages .message-item .ai-message .message-content .message-bubble {
position: relative !important;
background: #f5f5f5 !important;
border: 1rpx solid rgba(17, 24, 39, 0.05) !important;
border-radius: 24rpx !important;
padding: 26rpx 28rpx 26rpx 30rpx !important;
box-shadow:
0 1rpx 2rpx rgba(16, 24, 40, 0.04),
0 10rpx 24rpx rgba(16, 24, 40, 0.05),
0 28rpx 56rpx rgba(16, 24, 40, 0.045) !important;
}
/* 昵称更精致 */
.ai-chat-container .chat-messages .message-item .ai-message .message-content .message-nickname .ai-nickname-text {
color: #3a4353 !important;
font-weight: 600;
letter-spacing: 0.4rpx;
}
/* #ifdef MP-WEIXIN */
/* 微信小程序: 回答更紧凑 (内边距略收紧, 质感与颜色不变) */
.ai-chat-container .chat-messages .message-item .ai-message .message-content .message-bubble {
padding: 20rpx 22rpx 20rpx 24rpx !important;
}
/* #endif */
</style>