From 7348a3444e62f2e561bad2fc344653f5d318be21 Mon Sep 17 00:00:00 2001 From: Nixevol Date: Thu, 9 Jul 2026 15:11:43 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=AE=89=E8=A3=85=E5=90=91?= =?UTF-8?q?=E5=AF=BC=E7=A7=BB=E9=99=A4=E3=80=8C=E7=9B=91=E5=90=AC=E7=AB=AF?= =?UTF-8?q?=E5=8F=A3=E3=80=8D=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 端口由启动方式(PM2 项目端口 / compose / API_PORT 环境变量)决定,默认 3000, 向导填的值会被进程环境覆盖,属误导项;写 .env 的 API_PORT 改取 process.env.API_PORT。 反代 HTTPS/域名仍由 Nginx/宝塔/1Panel 配置,与安装页无关。 --- apps/admin/src/locales/en-US.json | 3 +-- apps/admin/src/locales/zh-CN.json | 3 +-- apps/admin/src/views/Install.vue | 4 ---- apps/api/src/install/dto/install.dto.ts | 9 +-------- apps/api/src/install/install.service.ts | 5 ++--- 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/apps/admin/src/locales/en-US.json b/apps/admin/src/locales/en-US.json index 01cec2b..0895f75 100644 --- a/apps/admin/src/locales/en-US.json +++ b/apps/admin/src/locales/en-US.json @@ -192,8 +192,7 @@ "base": "Base", "appName": "Platform Name", "baseUrl": "Public URL", - "listenPort": "Listen Port", - "baseUrlHint": "All three apps share this URL: admin at /admin, client at /trace, API at /api. Use Nginx / a control panel to reverse-proxy the domain and HTTPS to the listen port.", + "baseUrlHint": "All three apps share this URL: admin at /admin, client at /trace, API at /api. Reverse-proxy the domain and HTTPS to the service port (default 3000, decided by how the service is launched — not set here).", "host": "Host", "port": "Port", "database": "Database", diff --git a/apps/admin/src/locales/zh-CN.json b/apps/admin/src/locales/zh-CN.json index b91bea6..8c1f760 100644 --- a/apps/admin/src/locales/zh-CN.json +++ b/apps/admin/src/locales/zh-CN.json @@ -192,8 +192,7 @@ "base": "基础", "appName": "平台名称", "baseUrl": "对外访问地址", - "listenPort": "监听端口", - "baseUrlHint": "三端共用此地址:后台 /admin、客户端 /trace、接口 /api。域名与 HTTPS 建议由 Nginx/宝塔/1Panel 反代到监听端口。", + "baseUrlHint": "三端共用此地址:后台 /admin、客户端 /trace、接口 /api。域名与 HTTPS 由 Nginx/宝塔/1Panel 反代到服务端口(默认 3000,由启动方式决定,此处无需填写)。", "host": "主机", "port": "端口", "database": "数据库", diff --git a/apps/admin/src/views/Install.vue b/apps/admin/src/views/Install.vue index 1637f03..31c1644 100644 --- a/apps/admin/src/views/Install.vue +++ b/apps/admin/src/views/Install.vue @@ -29,7 +29,6 @@

{{ tt('base') }}

-

{{ tt('baseUrlHint') }}

@@ -100,7 +99,6 @@ import { useI18n } from 'vue-i18n'; interface InstallForm { appName: string; baseUrl: string; - port: number; mysql: { host: string; port: number; @@ -138,7 +136,6 @@ const driverOptions = computed(() => [ const form = reactive({ appName: tt('defaultAppName'), baseUrl: location.origin, - port: 3000, mysql: { host: '127.0.0.1', port: 3306, @@ -223,7 +220,6 @@ onMounted(async () => { const body = await res.json(); installed.value = Boolean(body.data?.installed); const d = body.data?.defaults || {}; - form.port = d.port || form.port; form.mysql.host = d.mysqlHost || form.mysql.host; form.mysql.port = d.mysqlPort || form.mysql.port; form.mysql.database = d.mysqlDatabase || form.mysql.database; diff --git a/apps/api/src/install/dto/install.dto.ts b/apps/api/src/install/dto/install.dto.ts index 6197124..21c9ddf 100644 --- a/apps/api/src/install/dto/install.dto.ts +++ b/apps/api/src/install/dto/install.dto.ts @@ -158,18 +158,11 @@ export class InstallRequestDto { appName!: string; // 对外访问地址(域名,可含端口);后台、客户端、短链、二维码均基于此推导。 + // 服务监听端口不在此处填写:由启动方式(PM2 项目端口 / compose / API_PORT 环境变量)决定,默认 3000。 @ApiProperty() @IsUrl({ require_tld: false }) baseUrl!: string; - // 服务监听端口(默认 3000),由前置 Nginx/宝塔/1Panel 反代指向该端口。 - @ApiPropertyOptional({ default: 3000 }) - @IsOptional() - @Type(() => Number) - @IsInt() - @Min(1) - port?: number; - @ApiProperty() @ValidateNested() @Type(() => InstallMysqlDto) diff --git a/apps/api/src/install/install.service.ts b/apps/api/src/install/install.service.ts index 3db87db..95e7aa5 100644 --- a/apps/api/src/install/install.service.ts +++ b/apps/api/src/install/install.service.ts @@ -26,7 +26,6 @@ export class InstallService { redisHost: process.env.INSTALL_REDIS_HOST || '127.0.0.1', redisPort: Number(process.env.INSTALL_REDIS_PORT || 6379), redisPassword: prefillSecrets ? process.env.INSTALL_REDIS_PASSWORD || '' : '', - port: Number(process.env.API_PORT || 3000), }, }; } @@ -192,8 +191,8 @@ export class InstallService { '# ===== 应用 =====', `APP_NAME=${q(dto.appName)}`, 'NODE_ENV=production', - '# 服务监听端口(由前置 Nginx/宝塔反代指向此端口)', - `API_PORT=${q(String(dto.port || 3000))}`, + '# 服务监听端口:由启动方式决定(PM2 项目端口 / compose / API_PORT 环境变量),默认 3000', + `API_PORT=${q(String(process.env.API_PORT || 3000))}`, '# 对外访问地址:三端共用,客户端在 /trace、后台 /admin、接口 /api、短链 /t', `BASE_URL=${q(baseUrl)}`, 'PUBLIC_TRACE_PATH=/t',