mirror of
				https://github.com/yangjian102621/geekai.git
				synced 2025-11-04 16:23:42 +08:00 
			
		
		
		
	opt: automatic get the host for api and websocket from the 'location' var
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -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
									
								
							
							
						
						
									
										5
									
								
								api/go/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
# chatgpt-plus-go
 | 
			
		||||
 | 
			
		||||
chatgpt-plus 后端 API Go 语言实现。技术选型采用 Gin + Mysql 架构,依赖注入使用的是 fx 框架,ORM 采用的是 GORM 框架。
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								api/java/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								api/java/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
# chatgpt-plus-java
 | 
			
		||||
 | 
			
		||||
chatgpt-plus 后端 API Java 语言实现,待开发。
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								api/php/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								api/php/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
# chatgpt-plus-php
 | 
			
		||||
 | 
			
		||||
chatgpt-plus 后端 API PHP 语言实现,待开发。
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								api/python/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								api/python/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
# chatgpt-plus-python
 | 
			
		||||
 | 
			
		||||
chatgpt-plus 后端 API Python 语言实现,待开发。
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										5
									
								
								web/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								web/README.md
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,5 @@
 | 
			
		||||
# chatgpt-plus-web
 | 
			
		||||
 | 
			
		||||
chatgpt-plus 项目前端实现,采用 Vue3 + element-plus 架构。
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -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