opt: automatic get the host for api and websocket from the 'location' var

This commit is contained in:
RockYang 2023-06-15 14:39:05 +08:00
parent 088fd14c03
commit 06fb7b41b4
8 changed files with 36 additions and 3 deletions

2
.gitignore vendored
View File

@ -8,7 +8,7 @@ pnpm-debug.log*
lerna-debug.log*
node_modules
src/dist
web/dist
dist-ssr
*.local

5
api/go/README.md Normal file
View File

@ -0,0 +1,5 @@
# chatgpt-plus-go
chatgpt-plus 后端 API Go 语言实现。技术选型采用 Gin + Mysql 架构,依赖注入使用的是 fx 框架ORM 采用的是 GORM 框架。

5
api/java/README.md Normal file
View File

@ -0,0 +1,5 @@
# chatgpt-plus-java
chatgpt-plus 后端 API Java 语言实现,待开发。

5
api/php/README.md Normal file
View File

@ -0,0 +1,5 @@
# chatgpt-plus-php
chatgpt-plus 后端 API PHP 语言实现,待开发。

5
api/python/README.md Normal file
View File

@ -0,0 +1,5 @@
# chatgpt-plus-python
chatgpt-plus 后端 API Python 语言实现,待开发。

5
web/README.md Normal file
View File

@ -0,0 +1,5 @@
# chatgpt-plus-web
chatgpt-plus 项目前端实现,采用 Vue3 + element-plus 架构。

View File

@ -29,7 +29,7 @@ const routes = [
},
{
name: 'plus', path: '/chat', component: ChatPlus, meta: {
title: 'ChatGPT-Plus for PC'
title: 'ChatGPT-智能助手V3'
}
},
{

View File

@ -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 = '';