From f90cf8b8553cf71e25122a284e15ab6d771b51a9 Mon Sep 17 00:00:00 2001 From: ayflying Date: Thu, 30 Oct 2025 18:24:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E5=90=8E=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=A7=E7=9A=84=E5=8E=8B=E7=BC=A9=E5=8C=85=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E7=89=88=E6=9C=AC=E5=AF=B9=E6=AF=94=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/logic/system/update.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/internal/logic/system/update.go b/internal/logic/system/update.go index 5f94bb5..62fad73 100644 --- a/internal/logic/system/update.go +++ b/internal/logic/system/update.go @@ -24,6 +24,8 @@ import ( ) // 本地版本号(建议从编译参数注入,如 -ldflags "-X main.version=v0.1.3") +const versionFile = "version.txt" + var localVersion = "v0.0.0" // 对应 GitHub API 响应的核心字段(按需精简) @@ -59,6 +61,8 @@ func (s *sSystem) Update(ctx context.Context, gzFile string) (err error) { if gzFile == "" { gzFile = path.Join("download", platform+".gz") } + //结束后删除压缩包 + defer gfile.RemoveFile(gzFile) ext := gfile.Ext(gzFile) if ext == ".zip" { @@ -198,7 +202,7 @@ func (s *sSystem) CheckUpdate() (err error) { return } - localVersion = gfile.GetContents("download/version.txt") + localVersion = gfile.GetContents(versionFile) if s.isNewVersion(localVersion, latestVersion) { g.Log().Printf(ctx, "发现新版本:%s(当前版本:%s)", latestVersion, localVersion) @@ -223,7 +227,7 @@ func (s *sSystem) CheckUpdate() (err error) { return } // 保存最新版本号到文件 - gfile.PutContents("download/version.txt", latestVersion) + gfile.PutContents(versionFile, latestVersion) break } }