feat:修改ws的配置
This commit is contained in:
parent
060e4944fa
commit
7734d33697
@ -66,6 +66,19 @@ SEGMENT_PROVIDER=imageseg
|
|||||||
# 自部署 rembg:http://127.0.0.1:7000/api/remove
|
# 自部署 rembg:http://127.0.0.1:7000/api/remove
|
||||||
SEGMENT_INFERENCE_URL=
|
SEGMENT_INFERENCE_URL=
|
||||||
|
|
||||||
|
# ==================== WebSocket ====================
|
||||||
|
# AI Chat WebSocket 路径(用于 Nginx 反向代理)
|
||||||
|
# 完整连接 URL = ws://<host>:<port><WS_AI_CHAT_PATH>?token=Bearer_xxx
|
||||||
|
# 需与 frontend/.env.{development,production} 的 VITE_WS_AI_CHAT_PATH 保持一致
|
||||||
|
# Nginx 反代示例:
|
||||||
|
# location /ai-chat {
|
||||||
|
# proxy_pass http://gateway:8080;
|
||||||
|
# proxy_http_version 1.1;
|
||||||
|
# proxy_set_header Upgrade $http_upgrade;
|
||||||
|
# proxy_set_header Connection "upgrade";
|
||||||
|
# }
|
||||||
|
WS_AI_CHAT_PATH=/ai-chat
|
||||||
|
|
||||||
# ==================== Dify AI Workflow ====================
|
# ==================== Dify AI Workflow ====================
|
||||||
# Dify API 地址(自部署或云服务)
|
# Dify API 地址(自部署或云服务)
|
||||||
DIFY_API_BASE=https://api.dify.ai/v1
|
DIFY_API_BASE=https://api.dify.ai/v1
|
||||||
|
|||||||
@ -114,7 +114,7 @@ func (c *OSSConfig) GetUploadDir(uploadType string) string {
|
|||||||
|
|
||||||
// WebSocketConfig WebSocket 配置
|
// WebSocketConfig WebSocket 配置
|
||||||
type WebSocketConfig struct {
|
type WebSocketConfig struct {
|
||||||
AIChatPath string // WebSocket 路径,默认 /ws/ai-chat
|
AIChatPath string // WebSocket 路径,默认 /ai-chat
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load 加载配置
|
// Load 加载配置
|
||||||
@ -181,7 +181,7 @@ func Load() *Config {
|
|||||||
TimeZone: getEnv("DB_TIMEZONE", "Asia/Shanghai"),
|
TimeZone: getEnv("DB_TIMEZONE", "Asia/Shanghai"),
|
||||||
},
|
},
|
||||||
WebSocket: WebSocketConfig{
|
WebSocket: WebSocketConfig{
|
||||||
AIChatPath: getEnv("WS_AI_CHAT_PATH", "/ws/ai-chat"),
|
AIChatPath: getEnv("WS_AI_CHAT_PATH", "/ai-chat"),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
131872
docker/init-db.sql
Normal file
131872
docker/init-db.sql
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,14 @@
|
|||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
# HBuilderX「运行」时自动加载;CLI 用 --mode development
|
# HBuilderX「运行」时自动加载;CLI 用 --mode development
|
||||||
VITE_API_BASE_URL=http://192.168.110.60:8080
|
# VITE_API_BASE_URL=http://192.168.110.60:8080
|
||||||
# VITE_API_BASE_URL=https://api.topfans.online
|
VITE_API_BASE_URL=https://api.topfans.online
|
||||||
# WebSocket 地址:如与 API 同源可省略(自动从 VITE_API_BASE_URL 推导 http→ws、https→wss)
|
# WebSocket 地址:如与 API 同源可省略(自动从 VITE_API_BASE_URL 推导 http→ws、https→wss)
|
||||||
# 独立部署时直接覆盖,例如:ws://192.168.110.60:8081
|
# 独立部署时直接覆盖,例如:ws://192.168.110.60:8081
|
||||||
VITE_WS_BASE_URL=ws://192.168.110.60:8080
|
VITE_WS_BASE_URL=ws://192.168.110.60:8080
|
||||||
# VITE_WS_BASE_URL=ws://101.132.250.62:8080
|
# VITE_WS_BASE_URL=ws://101.132.250.62:8080
|
||||||
|
# WebSocket 路径:用于 Nginx 反向代理(前端连接的完整 URL = VITE_WS_BASE_URL + VITE_WS_AI_CHAT_PATH)
|
||||||
|
# 需与后端 backend/.env 的 WS_AI_CHAT_PATH 保持一致
|
||||||
|
# Nginx 示例:location /ai-chat { proxy_pass http://gateway:8080; ... }
|
||||||
|
VITE_WS_AI_CHAT_PATH=/ai-chat
|
||||||
VITE_USE_MOCK_API=false
|
VITE_USE_MOCK_API=false
|
||||||
# VITE_ENV_NAME=development
|
# VITE_ENV_NAME=development
|
||||||
|
|||||||
@ -2,6 +2,10 @@
|
|||||||
# HBuilderX「发行」时自动加载;CLI 用 --mode production
|
# HBuilderX「发行」时自动加载;CLI 用 --mode production
|
||||||
VITE_API_BASE_URL=https://api.topfans.online
|
VITE_API_BASE_URL=https://api.topfans.online
|
||||||
# WebSocket 地址:生产环境使用 wss(与 HTTPS 对应),如 WS 部署在独立端口/域名可覆盖
|
# WebSocket 地址:生产环境使用 wss(与 HTTPS 对应),如 WS 部署在独立端口/域名可覆盖
|
||||||
|
# 走 Nginx 反向代理时建议改为同源 wss://api.topfans.online,由 Nginx 转发到后端 ws://gateway:8080
|
||||||
|
# VITE_WS_BASE_URL=wss://api.topfans.online
|
||||||
VITE_WS_BASE_URL=ws://101.132.250.62:8080
|
VITE_WS_BASE_URL=ws://101.132.250.62:8080
|
||||||
|
# WebSocket 路径:与后端 backend/.env 的 WS_AI_CHAT_PATH 保持一致
|
||||||
|
VITE_WS_AI_CHAT_PATH=/ai-chat
|
||||||
VITE_USE_MOCK_API=false
|
VITE_USE_MOCK_API=false
|
||||||
# VITE_ENV_NAME=production
|
# VITE_ENV_NAME=production
|
||||||
|
|||||||
@ -1,5 +1,18 @@
|
|||||||
import SocketManager from './SocketManager'
|
import SocketManager from './SocketManager'
|
||||||
|
|
||||||
|
// AI Chat WebSocket 路径
|
||||||
|
// 优先取 VITE_WS_AI_CHAT_PATH(方便 Nginx 反向代理时统一改前缀),
|
||||||
|
// 未配置时回退到 /ai-chat
|
||||||
|
const AI_CHAT_WS_PATH = (() => {
|
||||||
|
const configured = import.meta.env.VITE_WS_AI_CHAT_PATH
|
||||||
|
if (configured && String(configured).trim()) {
|
||||||
|
const p = String(configured).trim()
|
||||||
|
// 兜底:若用户忘了写前导 /,补上
|
||||||
|
return p.startsWith('/') ? p : `/${p}`
|
||||||
|
}
|
||||||
|
return '/ai-chat'
|
||||||
|
})()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AI Chat WebSocket 连接
|
* AI Chat WebSocket 连接
|
||||||
* 继承自 SocketManager,添加 AI Chat 特定的业务逻辑
|
* 继承自 SocketManager,添加 AI Chat 特定的业务逻辑
|
||||||
@ -9,7 +22,7 @@ class AiChatSocket extends SocketManager {
|
|||||||
super({
|
super({
|
||||||
serviceName: 'AiChat',
|
serviceName: 'AiChat',
|
||||||
baseUrl: 'ws://gateway:8080',
|
baseUrl: 'ws://gateway:8080',
|
||||||
path: '/ws/ai-chat',
|
path: AI_CHAT_WS_PATH,
|
||||||
reconnectInterval: 3000,
|
reconnectInterval: 3000,
|
||||||
heartbeatInterval: 30000,
|
heartbeatInterval: 30000,
|
||||||
maxReconnectAttempts: 5
|
maxReconnectAttempts: 5
|
||||||
@ -57,7 +70,7 @@ class AiChatSocket extends SocketManager {
|
|||||||
* 连接到 AI Chat 服务
|
* 连接到 AI Chat 服务
|
||||||
*/
|
*/
|
||||||
async connect(token) {
|
async connect(token) {
|
||||||
await super.connect(token, '/ws/ai-chat')
|
await super.connect(token, AI_CHAT_WS_PATH)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user