From 2fdd9636131b7023f5fe85d0729ac27791123186 Mon Sep 17 00:00:00 2001 From: tbphp Date: Mon, 14 Jul 2025 14:08:05 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=AB=AF=E5=8F=A3=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 2 +- Dockerfile | 2 +- docker-compose.yml | 2 +- internal/config/manager.go | 2 +- internal/config/system_settings.go | 4 ++-- internal/types/types.go | 2 +- web/vite.config.ts | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.env.example b/.env.example index ed3294b..a87520a 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ # 服务器配置 -PORT=3000 +PORT=3001 HOST=0.0.0.0 # 服务器读取、写入和空闲连接的超时时间(秒) diff --git a/Dockerfile b/Dockerfile index 8b93dd9..7f3f0a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,5 +32,5 @@ RUN apk upgrade --no-cache \ && update-ca-certificates COPY --from=builder2 /build/gpt-load . -EXPOSE 3000 +EXPOSE 3001 ENTRYPOINT ["/app/gpt-load"] diff --git a/docker-compose.yml b/docker-compose.yml index 0e1783f..6879519 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: # dockerfile: Dockerfile container_name: gpt-load ports: - - "3000:3000" + - "${PORT:-3001}:${PORT:-3001}" env_file: - .env restart: always diff --git a/internal/config/manager.go b/internal/config/manager.go index 6117b42..0b1b829 100644 --- a/internal/config/manager.go +++ b/internal/config/manager.go @@ -70,7 +70,7 @@ func (m *Manager) ReloadConfig() error { config := &Config{ Server: types.ServerConfig{ - Port: utils.ParseInteger(os.Getenv("PORT"), 3000), + Port: utils.ParseInteger(os.Getenv("PORT"), 3001), Host: utils.GetEnvOrDefault("HOST", "0.0.0.0"), ReadTimeout: utils.ParseInteger(os.Getenv("SERVER_READ_TIMEOUT"), 120), WriteTimeout: utils.ParseInteger(os.Getenv("SERVER_WRITE_TIMEOUT"), 1800), diff --git a/internal/config/system_settings.go b/internal/config/system_settings.go index 1762c34..be678f6 100644 --- a/internal/config/system_settings.go +++ b/internal/config/system_settings.go @@ -130,7 +130,7 @@ func (sm *SystemSettingsManager) EnsureSettingsInitialized() error { } port := os.Getenv("PORT") if port == "" { - port = "3000" + port = "3001" } value = fmt.Sprintf("http://%s:%s", host, port) } @@ -172,7 +172,7 @@ func (sm *SystemSettingsManager) GetAppUrl() string { } port := os.Getenv("PORT") if port == "" { - port = "3000" + port = "3001" } return fmt.Sprintf("http://%s:%s", host, port) } diff --git a/internal/types/types.go b/internal/types/types.go index 4ef8beb..f86483a 100644 --- a/internal/types/types.go +++ b/internal/types/types.go @@ -17,7 +17,7 @@ type ConfigManager interface { // SystemSettings 定义所有系统配置项 type SystemSettings struct { // 基础参数 - AppUrl string `json:"app_url" default:"http://localhost:3000" name:"项目地址" category:"基础参数" desc:"项目的基础 URL,用于拼接分组终端节点地址。系统配置优先于环境变量 APP_URL。"` + AppUrl string `json:"app_url" default:"http://localhost:3001" name:"项目地址" category:"基础参数" desc:"项目的基础 URL,用于拼接分组终端节点地址。系统配置优先于环境变量 APP_URL。"` RequestLogRetentionDays int `json:"request_log_retention_days" default:"7" name:"日志保留时长(天)" category:"基础参数" desc:"请求日志在数据库中的保留天数,0为不清理日志。" validate:"min=0"` RequestLogWriteIntervalMinutes int `json:"request_log_write_interval_minutes" default:"5" name:"日志延迟写入周期(分钟)" category:"基础参数" desc:"请求日志从缓存写入数据库的周期(分钟),0为实时写入数据。" validate:"min=0"` diff --git a/web/vite.config.ts b/web/vite.config.ts index e049282..9a7bc7d 100644 --- a/web/vite.config.ts +++ b/web/vite.config.ts @@ -21,7 +21,7 @@ export default defineConfig(({ mode }) => { // 代理配置示例 proxy: { "/api": { - target: env.VITE_API_BASE_URL || "http://127.0.0.1:3000", + target: env.VITE_API_BASE_URL || "http://127.0.0.1:3001", changeOrigin: true, }, },