fix: 第二轮修复 — 数据库启动检查、会话持久化、URL路由、设备排序等
1. DevTools 启动前检查数据库状态,失败时自动尝试启动 2. ai-core 添加数据库断线重连机制 (30秒间隔) 3. Dashboard 添加数据库状态卡片 (启动/停止/重启) 4. Gateway 会话空闲超时管理 (30分钟标记空闲) 5. 会话/消息 PostgreSQL 持久化 (SessionStore + REST API) 6. 前端服务端会话持久化 + URL hash 路由 + 侧边栏管理 7. 管理员回到主对话按钮 8. IoT 设备卡片固定排序 9. 更新相关文档
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
@@ -49,6 +50,9 @@ type Config struct {
|
||||
// WebSocket
|
||||
WSMaxConnections int
|
||||
|
||||
// 会话闲置超时 (分钟) — 超过此时间后会话标记为 idle 但不删除
|
||||
SessionIdleTimeoutMin int
|
||||
|
||||
// Webhook (第三方平台接入)
|
||||
WebhookAPIKey string
|
||||
}
|
||||
@@ -87,12 +91,23 @@ func Load() *Config {
|
||||
LLMAPIKey: getEnv("LLM_API_KEY", ""),
|
||||
LLMModel: getEnv("LLM_MODEL", "gpt-4o"),
|
||||
|
||||
WSMaxConnections: getEnvInt("WS_MAX_CONNECTIONS", 1000),
|
||||
WSMaxConnections: getEnvInt("WS_MAX_CONNECTIONS", 1000),
|
||||
SessionIdleTimeoutMin: getEnvInt("SESSION_IDLE_TIMEOUT_MIN", 30),
|
||||
|
||||
WebhookAPIKey: getEnv("WEBHOOK_API_KEY", ""),
|
||||
}
|
||||
}
|
||||
|
||||
// DatabaseURL 构建 PostgreSQL 连接字符串
|
||||
func (c *Config) DatabaseURL() string {
|
||||
return fmt.Sprintf(
|
||||
"postgres://%s:%s@%s:%s/%s?sslmode=disable",
|
||||
c.PostgresUser, c.PostgresPass,
|
||||
c.PostgresHost, c.PostgresPort,
|
||||
c.PostgresDB,
|
||||
)
|
||||
}
|
||||
|
||||
// GenerateToken 生成JWT token
|
||||
func (c *Config) GenerateToken(userID string) (string, error) {
|
||||
claims := jwt.MapClaims{
|
||||
|
||||
Reference in New Issue
Block a user