tmp save
This commit is contained in:
parent
ae85cf6ba2
commit
0a1908616f
|
@ -12,6 +12,7 @@
|
|||
"@rangermauve/fetch-event-source": "^1.0.3",
|
||||
"axios": "^1.6.3",
|
||||
"pinia": "^2.1.7",
|
||||
"uuid": "^9.0.1",
|
||||
"vant": "^4.8.0",
|
||||
"vue": "^3.3.4",
|
||||
"vue-router": "^4.2.5"
|
||||
|
@ -675,6 +676,14 @@
|
|||
"node": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "9.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/uuid/-/uuid-9.0.1.tgz",
|
||||
"integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==",
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/vant": {
|
||||
"version": "4.8.0",
|
||||
"resolved": "https://registry.npmmirror.com/vant/-/vant-4.8.0.tgz",
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"@rangermauve/fetch-event-source": "^1.0.3",
|
||||
"axios": "^1.6.3",
|
||||
"pinia": "^2.1.7",
|
||||
"uuid": "^9.0.1",
|
||||
"vant": "^4.8.0",
|
||||
"vue": "^3.3.4",
|
||||
"vue-router": "^4.2.5"
|
||||
|
|
|
@ -280,12 +280,8 @@
|
|||
|
||||
<script setup>
|
||||
import { ref, reactive, nextTick, onMounted, watch } from 'vue'
|
||||
// import { fetchEventSource } from '@microsoft/fetch-event-source'
|
||||
// import {fetchEventSource} from '@/rangermauve/fetch-event-source'
|
||||
|
||||
// import fetchEventSource from '@rangermauve/fetch-event-source';
|
||||
import { fetchEventSource } from '@microsoft/fetch-event-source';
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import http from '@/api/http.js'
|
||||
// import http from '@/utils/request.js'
|
||||
let recomanTags = ref(['公积金查询', '2024放假安排', '附近推荐的锻炼场所'])
|
||||
|
@ -294,7 +290,7 @@ let inputText = ref('')
|
|||
let messages = reactive([
|
||||
|
||||
]);
|
||||
|
||||
// let lastMessageId = ref(0); // 初始化消息ID计数器
|
||||
// let messages = ref([
|
||||
|
||||
// ]);
|
||||
|
@ -340,14 +336,15 @@ 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', });
|
||||
console.log("模型", pathname.value);
|
||||
// lastMessageId.value += 1;
|
||||
messages.push({ id: uuidv4(), text: inputText.value, isMe: true, type: 'txt', });
|
||||
console.log("模型", pathname.value, messages);
|
||||
if (pathname.value == '/generate') {
|
||||
messages.push({ id: Date.now(), text: '思考中。。。', isMe: true, type: 'loading', });
|
||||
messages.push({ id: uuidv4(), text: '思考中。。。', isMe: true, type: 'loading', });
|
||||
http.post(pathname.value, { "text": messageValue }).then((res) => {
|
||||
// var msg = JSON.parse(res.name)
|
||||
var msg = res.response
|
||||
messages.push({ id: Date.now() + 1, text: msg, isMe: false, type: 'txt' });
|
||||
messages.push({ id: uuidv4(), text: msg, isMe: false, type: 'txt' });
|
||||
messages.map((vv, ii) => {
|
||||
if (vv.type == 'loading') {
|
||||
messages.splice(ii, 1)
|
||||
|
@ -363,6 +360,8 @@ const sendMessage = () => {
|
|||
console.log('error', error)
|
||||
})
|
||||
} else if (pathname.value == '/main_serve') {
|
||||
var mgsid= uuidv4()
|
||||
messages.push({ id: mgsid, text: '媒体流加载中', isMe: false, type: 'txt' });
|
||||
fetchEventSource('/main_serve', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
@ -372,8 +371,13 @@ const sendMessage = () => {
|
|||
"text": messageValue
|
||||
}),
|
||||
onmessage(ev) {
|
||||
console.log("媒体流", ev.data);
|
||||
// messages.push({ id: Date.now() + 1, text: msg, isMe: false, type: 'txt' });
|
||||
console.log("媒体流", JSON.parse(ev.data).response);
|
||||
messages.map((v,i)=>{
|
||||
if(v.id==mgsid){
|
||||
// console.log("JSON.parse(ev.data).response",JSON.parse(ev.data).response);
|
||||
v.text+=JSON.parse(ev.data).response
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -406,7 +410,8 @@ const sendMessage = () => {
|
|||
const goke = () => {
|
||||
// console.log("goke");
|
||||
const insertWord = '您想看普通还是专家门诊?如有其他需求,也请告诉我'
|
||||
messagesCopy[11].id = Date.now();
|
||||
// messagesCopy[11].id = Date.now();
|
||||
messagesCopy[11].id = uuidv4();
|
||||
messagesCopy[11].text = insertWord
|
||||
|
||||
messages.push(messagesCopy[11]);
|
||||
|
@ -444,7 +449,8 @@ onMounted(() => {
|
|||
scollToButtom()
|
||||
// messages
|
||||
setTimeout(() => {
|
||||
messages.push({ id: Date.now(), type: 'fstxt', text: '您可以点击下方快捷方式选择问题,或直接编辑问题发送给我哟', isMe: false });
|
||||
// messages.push({ id: Date.now(), type: 'fstxt', text: '您可以点击下方快捷方式选择问题,或直接编辑问题发送给我哟', isMe: false });
|
||||
messages.push({ id: uuidv4(), type: 'fstxt', text: '您可以点击下方快捷方式选择问题,或直接编辑问题发送给我哟', isMe: false });
|
||||
}, 500);
|
||||
|
||||
})
|
||||
|
|
|
@ -389,6 +389,11 @@ to-regex-range@^5.0.1:
|
|||
dependencies:
|
||||
is-number "^7.0.0"
|
||||
|
||||
uuid@^9.0.1:
|
||||
version "9.0.1"
|
||||
resolved "https://registry.npmmirror.com/uuid/-/uuid-9.0.1.tgz"
|
||||
integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==
|
||||
|
||||
vant@^4.8.0:
|
||||
version "4.8.0"
|
||||
resolved "https://registry.npmmirror.com/vant/-/vant-4.8.0.tgz"
|
||||
|
|
Loading…
Reference in New Issue