增加 环境检测

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

@ -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)
@ -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()