From 373c2d5bd0f7bc63873a467b618b2dd48d75d239 Mon Sep 17 00:00:00 2001 From: ronger Date: Wed, 29 May 2024 10:26:38 +0800 Subject: [PATCH] =?UTF-8?q?style(styles):=20=E4=BC=98=E5=8C=96=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=E7=95=8C=E9=9D=A2=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/chats/_account.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pages/chats/_account.vue b/pages/chats/_account.vue index 22fd3ab..c35acda 100644 --- a/pages/chats/_account.vue +++ b/pages/chats/_account.vue @@ -197,6 +197,7 @@ export default { return a.dataId - b.dataId; }); _ts.contentEditor.setValue('') + _ts.scrollToBottom(); _ts.$axios.$post('/api/openai/new-chat', _ts.messages).then(async res => { const html = await Vue.Vditor.md2html(_ts.message, { cdn: apiConfig.VDITOR @@ -213,6 +214,7 @@ export default { return a.dataId - b.dataId; }); _ts.message = ''; + _ts.scrollToBottom(); }); }, close() { @@ -243,14 +245,23 @@ export default { }, //message回调 handleMessage(res) { + let _ts = this; if (typeof res !== "undefined") { - this.message += res; + _ts.message += res; + _ts.scrollToBottom(); } }, //handleCustomEvents回调 handleCustomEvents(res) { let {data} = res; this.customEvents = data; + }, + scrollToBottom() { + setTimeout(() => { + // 获取指定容器的 DOM 元素 + let container = document.getElementById("messagesContent"); + container.scrollTop = container.scrollHeight; + }, 100); } }, async mounted() {