From bb24858e2b1553558ed93084b07457e191f16a3a Mon Sep 17 00:00:00 2001 From: yml2213 Date: Fri, 26 Jun 2026 15:29:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=96=E8=AF=91=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.go | 3 +++ build.sh | 21 ++++++++++++++------- internal/constants/constants.go | 5 ++++- wails.json | 2 +- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app.go b/app.go index 616a924..e9ede85 100644 --- a/app.go +++ b/app.go @@ -533,6 +533,9 @@ func (a *App) OrganizeAccounts(commodityID, commodityName string, startTime, end // GetVersion 返回应用版本号。 func (a *App) GetVersion() string { + if constants.BuildTime != "unknown" { + return constants.Version + " (" + constants.BuildTime + ")" + } return constants.Version } diff --git a/build.sh b/build.sh index 8fd33c1..0ea38dd 100755 --- a/build.sh +++ b/build.sh @@ -94,7 +94,8 @@ dev_mode() { # 生产构建 build_production() { local VERSION=$(get_version) - info "开始生产构建 v${VERSION}" + local BUILD_TIME=$(date '+%Y-%m-%d %H:%M:%S') + info "开始生产构建 v${VERSION} 构建时间=${BUILD_TIME}" # 类型检查 info "TypeScript 类型检查..." @@ -102,8 +103,8 @@ build_production() { npm run type-check cd .. - # Wails 构建 - wails build + # Wails 构建,注入构建时间 + wails build -ldflags "-X 'douyu_go/internal/constants.BuildTime=${BUILD_TIME}'" success "构建完成!" echo "" @@ -114,9 +115,12 @@ build_production() { # 构建 Windows 版本 build_windows() { local VERSION=$(get_version) - info "构建 Windows 版本 v${VERSION}" + local BUILD_TIME=$(date '+%Y-%m-%d %H:%M:%S') + local DATE_TAG=$(date '+%y.%-m.%-d') + local OUTPUT_NAME="douyu_go_v${VERSION}_${DATE_TAG}.exe" + info "构建 Windows 版本 v${VERSION} 构建时间=${BUILD_TIME}" - GOOS=windows GOARCH=amd64 wails build -platform windows/amd64 -o "douyu_go_v${VERSION}.exe" + GOOS=windows GOARCH=amd64 wails build -platform windows/amd64 -o "${OUTPUT_NAME}" -ldflags "-X 'douyu_go/internal/constants.BuildTime=${BUILD_TIME}'" success "Windows 构建完成!" echo "" @@ -127,9 +131,12 @@ build_windows() { # 构建 Linux 版本 build_linux() { local VERSION=$(get_version) - info "构建 Linux 版本 v${VERSION}" + local BUILD_TIME=$(date '+%Y-%m-%d %H:%M:%S') + local DATE_TAG=$(date '+%y.%-m.%-d') + local OUTPUT_NAME="douyu_go_v${VERSION}_${DATE_TAG}" + info "构建 Linux 版本 v${VERSION} 构建时间=${BUILD_TIME}" - GOOS=linux GOARCH=amd64 wails build -platform linux/amd64 -o "douyu_go_v${VERSION}" + GOOS=linux GOARCH=amd64 wails build -platform linux/amd64 -o "${OUTPUT_NAME}" -ldflags "-X 'douyu_go/internal/constants.BuildTime=${BUILD_TIME}'" success "Linux 构建完成!" echo "" diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 687d613..a58353a 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -3,7 +3,10 @@ package constants import "time" // Version 应用版本号,与 wails.json version 同步。 -const Version = "0.1.0" +const Version = "0.1.1" + +// BuildTime 构建时间,由编译时 ldflags 注入。 +var BuildTime = "unknown" const ( ManualID = "G4KA4Qnz4LDp7" diff --git a/wails.json b/wails.json index 873f9d7..a49b840 100644 --- a/wails.json +++ b/wails.json @@ -2,7 +2,7 @@ "$schema": "https://wails.io/schemas/config.v2.json", "name": "douyu_go", "outputfilename": "douyu_go", - "version": "0.1.0", + "version": "0.1.1", "frontend:dir": "frontend", "frontend:install": "npm install", "frontend:build": "npm run build",