This commit is contained in:
liuyalei 2024-03-06 16:52:27 +08:00
parent 14b29edc75
commit f175124139
1 changed files with 12 additions and 10 deletions

View File

@ -279,12 +279,12 @@ import http from '@/api/http.js'
// import http from '@/utils/request.js' // import http from '@/utils/request.js'
let recomanTags = ref(['公积金查询', '2024放假安排', '附近推荐的锻炼场所']) let recomanTags = ref(['公积金查询', '2024放假安排', '附近推荐的锻炼场所'])
let inputText = ref('') let inputText = ref('')
// let messages = reactive([ let messages = reactive([
// ]);
let messages = ref([
]); ]);
// let messages = ref([
// ]);
let kearr = reactive([{ name: '神经内科', path: '' }, { name: '儿科', path: '' }, { name: '外科', path: '' }]) let kearr = reactive([{ name: '神经内科', path: '' }, { name: '儿科', path: '' }, { name: '外科', path: '' }])
let messagesCopy = reactive([ let messagesCopy = reactive([
@ -313,18 +313,20 @@ const sendMessage = () => {
let messageValue = inputText.value.trim() let messageValue = inputText.value.trim()
if (inputText.value.trim()) { if (inputText.value.trim()) {
messages.value.push({ id: Date.now(), text: inputText.value, isMe: true, type: 'txt', }); messages.push({ id: Date.now(), text: inputText.value, isMe: true, type: 'txt', });
messages.value.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); 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.value.push({ id: Date.now() + 1, text: msg, isMe: false, type: 'txt' }); messages.push({ id: Date.now() + 1, text: msg, isMe: false, type: 'txt' });
messages.value.splice(messages.value.length - 2, 1); messages.splice(messages.length - 2, 1);
// console.log("messages.value",messages.value,dd); // console.log("messages.value",messages.value,dd);
scollToButtom() scollToButtom()
}).catch(error => { }).catch(error => {
messages.splice(messages.length - 2, 1);
messages.push({ id: Date.now() + 1, text: error, isMe: false, type: 'txt' });
console.log(error) console.log(error)
}) })
// if (inputText.value.indexOf('') != -1 || inputText.value.indexOf('') != -1) { // if (inputText.value.indexOf('') != -1 || inputText.value.indexOf('') != -1) {
@ -358,7 +360,7 @@ const goke = () => {
messagesCopy[11].id = Date.now(); messagesCopy[11].id = Date.now();
messagesCopy[11].text = insertWord messagesCopy[11].text = insertWord
messages.value.push(messagesCopy[11]); messages.push(messagesCopy[11]);
scollToButtom(); scollToButtom();
}; };
// //
@ -381,7 +383,7 @@ onMounted(() => {
scollToButtom() scollToButtom()
// messages // messages
setTimeout(() => { setTimeout(() => {
messages.value.push({ id: Date.now(), type: 'fstxt', text: '您可以点击下方快捷方式选择问题,或直接编辑问题发送给我哟', isMe: false }); messages.push({ id: Date.now(), type: 'fstxt', text: '您可以点击下方快捷方式选择问题,或直接编辑问题发送给我哟', isMe: false });
}, 500); }, 500);
}) })