a little bug

This commit is contained in:
liuyalei 2024-03-06 17:08:35 +08:00
parent f175124139
commit a571c51cea
1 changed files with 23 additions and 13 deletions

View File

@ -245,8 +245,8 @@
<div v-if="message.type == 'txt'" class="txt txt_r"> {{ message.text }}</div> <div v-if="message.type == 'txt'" class="txt txt_r"> {{ message.text }}</div>
</div> </div>
</div> </div>
<div class="Left" v-if="message.type=='loading'"> <div class="Left" v-if="message.type == 'loading'">
<div class="txt_l middle " > <div class="txt_l middle ">
<!-- <van-loading type="spinner" color="#1989fa">{{ message.text }} </van-loading> --> <!-- <van-loading type="spinner" color="#1989fa">{{ message.text }} </van-loading> -->
<van-loading type="spinner" color="#000">{{ message.text }} </van-loading> <van-loading type="spinner" color="#000">{{ message.text }} </van-loading>
@ -312,22 +312,26 @@ const sendMessage = () => {
console.log("信息发送成功", inputText.value); console.log("信息发送成功", inputText.value);
let messageValue = inputText.value.trim() let messageValue = inputText.value.trim()
if (inputText.value.trim()) { if (inputText.value.trim()) {
messages.push({ id: Date.now(), text: inputText.value, isMe: true, type: 'txt', }); messages.push({ id: Date.now(), text: inputText.value, isMe: true, type: 'txt', });
messages.push({ id: Date.now(), text: '思考中。。。', isMe: true, type: 'loading', }); messages.push({ id: Date.now(), text: '思考中。。。', isMe: true, type: 'loading', });
http.post('/generate', { "text": messageValue }).then((res) => { http.post('/generate', { "text": messageValue }).then((res) => {
console.log("res", res);
// var msg = JSON.parse(res.name) // var msg = JSON.parse(res.name)
var msg = res.response var msg = res.response
messages.push({ id: Date.now() + 1, text: msg, isMe: false, type: 'txt' }); messages.push({ id: Date.now() + 1, text: msg, isMe: false, type: 'txt' });
messages.splice(messages.length - 2, 1); messages.map((vv, ii) => {
// console.log("messages.value",messages.value,dd); if (vv.type == 'loading') {
messages.splice(ii, 1)
}
})
// console.log("messages ==", messages);
scollToButtom() scollToButtom()
}).catch(error => { }).catch(error => {
messages.splice(messages.length - 2, 1); messages.map((vv, ii) => {
messages.push({ id: Date.now() + 1, text: error, isMe: false, type: 'txt' }); if (vv.type == 'loading') {
console.log(error) messages.splice(ii, 1)
}
})
console.log('error',error)
}) })
// if (inputText.value.indexOf('') != -1 || inputText.value.indexOf('') != -1) { // if (inputText.value.indexOf('') != -1 || inputText.value.indexOf('') != -1) {
// messagesCopy[10].id = Date.now(); // messagesCopy[10].id = Date.now();
@ -395,9 +399,15 @@ onMounted(() => {
color: #999999; color: #999999;
font-size: 14px; font-size: 14px;
} }
.middle{
display: flex;justify-content: center;align-items: center; height: 64px;width: 300px; .middle {
display: flex;
justify-content: center;
align-items: center;
height: 64px;
width: 300px;
} }
.sendinput { .sendinput {
height: 36px; height: 36px;
width: calc(100vw - 154px); width: calc(100vw - 154px);