增加 环境检测

This commit is contained in:
liuyalei 2024-03-21 09:41:06 +08:00
parent ae936fc49b
commit fa450f92a8
1 changed files with 17 additions and 7 deletions

View File

@ -291,11 +291,11 @@ let sinalModel = ref(false)
let pathname = ref('') let pathname = ref('')
let modeldata = ref('') let modeldata = ref('')
if (sinalModel.value) { if (sinalModel.value) {
pathname.value='/three' pathname.value = '/three'
modeldata.value = ['模型三'] modeldata.value = ['模型三']
} else { } else {
pathname.value='/generate' pathname.value = '/generate'
modeldata.value = ['模型一', '模型二', '模型三'] modeldata.value = ['模型一', '模型二', '模型三']
} }
let inputText = ref('') let inputText = ref('')
@ -317,6 +317,14 @@ let messagesCopy = reactive([
{ id: 11, type: 'card5', text: '卡片5', carddata: { name: '', text: '卡片5' }, isMe: false }, { id: 11, type: 'card5', text: '卡片5', carddata: { name: '', text: '卡片5' }, isMe: false },
{ id: 12, type: 'txt', text: '空白', isMe: false }, { id: 12, type: 'txt', text: '空白', isMe: false },
]); ]);
let prefixpath=ref('/three')
if (process.env.NODE_ENV === 'production') {
console.log('生产');
prefixpath.value=''
} else {
console.log("dev");
prefixpath.value='/three'
}
const cksend = (val) => { const cksend = (val) => {
if (val.trim()) { if (val.trim()) {
inputText.value = val.trim() inputText.value = val.trim()
@ -345,7 +353,8 @@ const handleInputFocus = () => {
} }
const uid = uuidv4() const uid = uuidv4()
const event = new EventSource('/three/srv/platform/chat/connect/' + uid, { withCredentials: true }); // const event = new EventSource( prefixpath.value+'/three/srv/platform/chat/connect/' + uid, { withCredentials: true });
const event = new EventSource( prefixpath.value+'/srv/platform/chat/connect/' + uid, { withCredentials: true });
event.onmessage = function (e) { event.onmessage = function (e) {
console.log("e", JSON.parse(e.data)); console.log("e", JSON.parse(e.data));
var strpart = JSON.parse(e.data) var strpart = JSON.parse(e.data)
@ -363,7 +372,7 @@ const sendMessage = () => {
if (inputText.value.trim()) { if (inputText.value.trim()) {
messages.push({ usrid: uid, qid: uuidv4(), text: inputText.value, isMe: true, type: 'txt', }); messages.push({ usrid: uid, qid: uuidv4(), text: inputText.value, isMe: true, type: 'txt', });
// console.log("", pathname.value, messages); // console.log("", pathname.value, messages);
console.log("模型", pathname.value ); console.log("模型", pathname.value);
if (pathname.value == '/generate') { if (pathname.value == '/generate') {
messages.push({ usrid: uid, qid: uuidv4(), text: '思考中。。。', isMe: true, type: 'loading', }); messages.push({ usrid: uid, qid: uuidv4(), text: '思考中。。。', isMe: true, type: 'loading', });
http.post(pathname.value, { "text": messageValue }).then((res) => { http.post(pathname.value, { "text": messageValue }).then((res) => {
@ -408,7 +417,8 @@ const sendMessage = () => {
}); });
} else if (pathname.value == '/three') { } else if (pathname.value == '/three') {
var msid = uuidv4() var msid = uuidv4()
http.post(pathname.value + '/srv/platform/chat', { 'id': uid, 'qid': msid, "prompt": messageValue }).then((res) => { // http.post(pathname.value + '/srv/platform/chat', { 'id': uid, 'qid': msid, "prompt": messageValue }).then((res) => {
http.post(prefixpath.value + '/srv/platform/chat', { 'id': uid, 'qid': msid, "prompt": messageValue }).then((res) => {
console.log("three message", res); console.log("three message", res);
messages.push({ usrid: uid, qid: msid, text: '思考中...', isMe: false, type: 'txt' }); messages.push({ usrid: uid, qid: msid, text: '思考中...', isMe: false, type: 'txt' });
scollToButtom() scollToButtom()
@ -484,7 +494,7 @@ onMounted(() => {
// messages // messages
setTimeout(() => { setTimeout(() => {
// messages.push({ id: Date.now(), type: 'fstxt', text: '', isMe: false }); // messages.push({ id: Date.now(), type: 'fstxt', text: '', isMe: false });
messages.push({ usrid: uid,qid:uuidv4(), type: 'fstxt', text: '您可以点击下方快捷方式选择问题,或直接编辑问题发送给我哟', isMe: false }); messages.push({ usrid: uid, qid: uuidv4(), type: 'fstxt', text: '您可以点击下方快捷方式选择问题,或直接编辑问题发送给我哟', isMe: false });
}, 500); }, 500);
}) })