From 3c848e5216d3829af940bd1984f1d4f709591dcb Mon Sep 17 00:00:00 2001 From: yisier <1340976576@qq.com> Date: Sun, 12 Jul 2026 18:20:19 -0600 Subject: [PATCH] =?UTF-8?q?`nps=20-server`=20=E5=AE=89=E8=A3=85=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E5=90=8E=20`web=5Fport`=20=E6=9C=AA=E6=AD=A3=E5=B8=B8?= =?UTF-8?q?=E6=98=BE=E7=A4=BABUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/nps/nps.go | 22 ++++++++++++++++++++-- docs/changelog/index.md | 4 +++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/cmd/nps/nps.go b/cmd/nps/nps.go index 0d114f8..2829e01 100644 --- a/cmd/nps/nps.go +++ b/cmd/nps/nps.go @@ -51,6 +51,7 @@ func main() { return } if *serverCmd { + _ = logs.SetLogger(logs.AdapterConsole, `{"level":7,"color":true}`) printSlogan() inputCmd() return @@ -269,7 +270,15 @@ func inputCmd() { _ = service.Control(s, "uninstall") binPath := install.InstallNpsToCurrentDir() - beego.LoadAppConfig("ini", filepath.Join(common.GetAppPath(), "conf", "nps.conf")) + // Ensure conf exists (same as normal startup), then load it for display. + // Previously LoadAppConfig error was ignored and web_port could be empty, + // printing "127.0.0.1:" with no port. See #317. + confDir := filepath.Join(common.GetAppPath(), "conf") + initConfig(confDir) + if err := beego.LoadAppConfig("ini", filepath.Join(confDir, "nps.conf")); err != nil { + fmt.Println("加载配置文件失败:", err) + break + } logPath := filepath.Join(common.GetAppPath(), "nps.log") if common.IsWindows() { @@ -302,7 +311,16 @@ func inputCmd() { if err != nil { fmt.Println("启动NPS服务失败", err) } else { - fmt.Println("NPS服务已启动,管理面板访问地址:127.0.0.1:" + beego.AppConfig.String("web_port")) + webPort := beego.AppConfig.String("web_port") + if webPort == "" { + fmt.Println("NPS服务已启动(未配置 web_port,管理面板已关闭)") + } else { + scheme := "http" + if beego.AppConfig.DefaultBool("web_open_ssl", false) { + scheme = "https" + } + fmt.Println("NPS服务已启动,管理面板访问地址:" + scheme + "://127.0.0.1:" + webPort) + } } break diff --git a/docs/changelog/index.md b/docs/changelog/index.md index 0bf32ba..642c8f9 100644 --- a/docs/changelog/index.md +++ b/docs/changelog/index.md @@ -1,7 +1,9 @@ # 更新日志 - 2026-07-12 v0.26.36 - 优化: - - Web 管理界面完全从可执行文件内嵌资源加载:启动时不再释放或创建 `web` 目录,即使存在外部 `web` 目录也不再读取;安装/更新流程也不再复制 `web` 静态文件 + - 不再依赖外部 `web` 目录的静态文件 + - 修复: + - `nps -server` 安装成功后 `web_port` 未正常显示BUG [#317](https://github.com/yisier/nps/issues/317) - 2026-07-04 v0.26.35 - 新增: