mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-06 17:23:42 +08:00
opt: automatic get the host for api and websocket from the 'location' var
This commit is contained in:
@@ -29,7 +29,7 @@ const routes = [
|
||||
},
|
||||
{
|
||||
name: 'plus', path: '/chat', component: ChatPlus, meta: {
|
||||
title: 'ChatGPT-Plus for PC'
|
||||
title: 'ChatGPT-智能助手V3'
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -419,7 +419,15 @@ const connect = function (chat_id, role_id) {
|
||||
const _role = getRoleById(role_id);
|
||||
// 初始化 WebSocket 对象
|
||||
const _sessionId = getSessionId();
|
||||
const _socket = new WebSocket(process.env.VUE_APP_WS_HOST + `/api/chat/new?sessionId=${_sessionId}&roleId=${role_id}&chatId=${chat_id}&model=${model.value}`);
|
||||
let host = process.env.VUE_APP_WS_HOST
|
||||
if (host === '') {
|
||||
if (location.protocol === 'https') {
|
||||
host = 'wss://'+location.host;
|
||||
} else {
|
||||
host = 'ws://'+location.host;
|
||||
}
|
||||
}
|
||||
const _socket = new WebSocket(host + `/api/chat/new?sessionId=${_sessionId}&roleId=${role_id}&chatId=${chat_id}&model=${model.value}`);
|
||||
_socket.addEventListener('open', () => {
|
||||
chatData.value = []; // 初始化聊天数据
|
||||
previousText.value = '';
|
||||
|
||||
Reference in New Issue
Block a user