style(styles): 优化聊天界面用户体验

This commit is contained in:
ronger 2024-05-29 10:26:38 +08:00
parent 1dd347582e
commit 373c2d5bd0

View File

@ -197,6 +197,7 @@ export default {
return a.dataId - b.dataId; return a.dataId - b.dataId;
}); });
_ts.contentEditor.setValue('') _ts.contentEditor.setValue('')
_ts.scrollToBottom();
_ts.$axios.$post('/api/openai/new-chat', _ts.messages).then(async res => { _ts.$axios.$post('/api/openai/new-chat', _ts.messages).then(async res => {
const html = await Vue.Vditor.md2html(_ts.message, { const html = await Vue.Vditor.md2html(_ts.message, {
cdn: apiConfig.VDITOR cdn: apiConfig.VDITOR
@ -213,6 +214,7 @@ export default {
return a.dataId - b.dataId; return a.dataId - b.dataId;
}); });
_ts.message = ''; _ts.message = '';
_ts.scrollToBottom();
}); });
}, },
close() { close() {
@ -243,14 +245,23 @@ export default {
}, },
//message //message
handleMessage(res) { handleMessage(res) {
let _ts = this;
if (typeof res !== "undefined") { if (typeof res !== "undefined") {
this.message += res; _ts.message += res;
_ts.scrollToBottom();
} }
}, },
//handleCustomEvents //handleCustomEvents
handleCustomEvents(res) { handleCustomEvents(res) {
let {data} = res; let {data} = res;
this.customEvents = data; this.customEvents = data;
},
scrollToBottom() {
setTimeout(() => {
// DOM
let container = document.getElementById("messagesContent");
container.scrollTop = container.scrollHeight;
}, 100);
} }
}, },
async mounted() { async mounted() {