diff --git a/index.html b/index.html index 713fc13..4da2d74 100755 --- a/index.html +++ b/index.html @@ -1312,6 +1312,11 @@ } chatInput.value = ""; + if (controller) { + controller.abort(); + controller = null; + + } if (!sendBtnImg.classList.contains('none')) { sendBtnImg.classList.add('none'); stopBtn.classList.remove('none') @@ -1362,7 +1367,14 @@ while (true) { const { done, value } = await reader.read(); - if (done) break; + console.log(done, value, 'done') + if (done) { + const sendBtnImg = document.querySelector('#sendBtn img'); + const stopBtn = document.querySelector('#stopBtn'); + sendBtnImg.classList.add('none'); + stopBtn.classList.remove('none'); + break; + }; buffer += decoder.decode(value, { stream: true }); let lines = buffer.split("\n"); @@ -1373,8 +1385,14 @@ if (!line.startsWith("data:")) continue; const data = line.slice(5).trim(); - if (data === "[DONE]") { + console.log("完成回答", data) + if (data == "[DONE]") { + console.log("完成回答") // 更新聊天滚动条 + const sendBtnImg = document.querySelector('#sendBtn img'); + const stopBtn = document.querySelector('#stopBtn'); + sendBtnImg.classList.remove('none'); + stopBtn.classList.add('none'); setTimeout(scrollToBottom, 0); // chatMessages.scrollTop = chatMessages.scrollHeight; return; @@ -1391,7 +1409,7 @@ // } if (obj.content && obj.type !== "title") { for (const char of obj.content) { - await new Promise(r => setTimeout(r, 20)); // 控制字速 + await new Promise(r => setTimeout(r, 5)); // 控制字速 aiMsg.content += char; msgDiv.innerHTML = marked.parse(aiMsg.content); diff --git a/modal.html b/modal.html index e5a5d63..15e89e6 100644 --- a/modal.html +++ b/modal.html @@ -281,7 +281,6 @@ background-size: cover; background-repeat: no-repeat; padding: 10px 0 20px 0; - ; } /* 先给表格四列添加细微分色(可按需移除) */ @@ -333,7 +332,7 @@