From cfa23e2b9b65d4ec3054e11a27dd4100a8cb821c Mon Sep 17 00:00:00 2001 From: wangyi <3432649580@qq.com> Date: Thu, 30 Oct 2025 17:02:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96deepmate=E8=BE=93=E5=87=BA?= =?UTF-8?q?=E6=97=B6=E5=B8=A6html=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/deepMate/deepMate.vue | 77 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 61 insertions(+), 16 deletions(-) diff --git a/pages/deepMate/deepMate.vue b/pages/deepMate/deepMate.vue index d887782..1a4ddbd 100644 --- a/pages/deepMate/deepMate.vue +++ b/pages/deepMate/deepMate.vue @@ -677,26 +677,48 @@ const simulateBotResponse = async (userMessage) => { const typeWriter = () => { if (index < responseText.length) { - const ch = responseText.charAt(index); + let ch = responseText.charAt(index); + let charsToAdd = ch; + let newIndex = index + 1; + + // 检查是否遇到HTML标签开始 + if (ch === '<') { + // 寻找标签结束位置 + let tagEndIndex = responseText.indexOf('>', index); + if (tagEndIndex !== -1) { + // 完整获取标签内容 + charsToAdd = responseText.substring(index, tagEndIndex + 1); + newIndex = tagEndIndex + 1; + } + } + const current = messages.value[botIndex]; // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应 messages.value.splice(botIndex, 1, { ...current, - content: current.content + ch, + content: current.content + charsToAdd, isTyping: true, }); - index++; + index = newIndex; scrollToBottom(); // 字符间延迟,模拟打字效果 const baseDelay = 5; // 普通字符基础延迟(毫秒) const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿 const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿 - const delay = slowPunct.test(ch) - ? 220 - : midPunct.test(ch) - ? 120 - : baseDelay; + + // 如果是标签,使用更短的延迟或者立即显示 + let delay; + if (charsToAdd.startsWith('<')) { + delay = 1; // 标签快速显示 + } else { + delay = slowPunct.test(ch) + ? 220 + : midPunct.test(ch) + ? 120 + : baseDelay; + } + setTimeout(typeWriter, delay); } else { // 打字完成,更新状态 @@ -786,22 +808,33 @@ const simulateBotResponse = async (userMessage) => { const typeWriter = () => { if (index < responseText.length) { - const ch = responseText.charAt(index); + let ch = responseText.charAt(index); + let charsToAdd = ch; + let newIndex = index + 1; + let delay = baseDelay; + + // 检查是否遇到HTML标签开始 + if (ch === '<') { + // 寻找标签结束位置 + let tagEndIndex = responseText.indexOf('>', index); + if (tagEndIndex !== -1) { + // 完整获取标签内容 + charsToAdd = responseText.substring(index, tagEndIndex + 1); + newIndex = tagEndIndex + 1; + delay = 1; // 标签快速显示 + } + } + const current = messages.value[botIndex]; // 通过数组替换触发渲染,避免部分平台对子项属性变更不响应 messages.value.splice(botIndex, 1, { ...current, - content: current.content + ch, + content: current.content + charsToAdd, isTyping: true, }); - index++; + index = newIndex; scrollToBottom(); - const delay = slowPunct.test(ch) - ? 220 - : midPunct.test(ch) - ? 120 - : baseDelay; setTimeout(typeWriter, delay); } else { const current = messages.value[botIndex]; @@ -1769,9 +1802,21 @@ async function itemClick(item) { } .thinking-content { + transition: transform 1s ease; /* 添加过渡效果 */ + transform-origin: top center; /* 设置变换原点 */ padding: 20rpx 30rpx; } +@keyframes transform { + from { + transform: scaleY(0); + } + to { + transform: scaleY(1); + } + +} + .thinking-item { display: flex; align-items: center;