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;