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