From 16972b41cd3e434a1a5c62741304e10a51aa6dbf Mon Sep 17 00:00:00 2001 From: yml2213 Date: Sat, 8 Aug 2026 19:52:00 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E7=89=88=E6=9C=AC=E5=B9=B6?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8F=8C=E5=B9=B3=E5=8F=B0=E6=89=93=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 41 +++++++++++++++++++++++++++++++-- internal/constants/constants.go | 2 +- wails.json | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index 0ea38dd..e5c1178 100755 --- a/build.sh +++ b/build.sh @@ -5,6 +5,8 @@ # ./build.sh dev # 开发模式(带热更新) # ./build.sh build # 生产构建 # ./build.sh win # 构建 Windows 版本 +# ./build.sh mac-arm # 构建 macOS ARM64 版本 +# ./build.sh release # 构建 Windows amd64 和 macOS ARM64 # ./build.sh linux # 构建 Linux 版本 # ./build.sh clean # 清理构建产物 # ./build.sh install # 安装前端依赖 @@ -117,7 +119,7 @@ build_windows() { local VERSION=$(get_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" + local OUTPUT_NAME="douyu_go_v${VERSION}_${DATE_TAG}_windows_amd64.exe" info "构建 Windows 版本 v${VERSION} 构建时间=${BUILD_TIME}" GOOS=windows GOARCH=amd64 wails build -platform windows/amd64 -o "${OUTPUT_NAME}" -ldflags "-X 'douyu_go/internal/constants.BuildTime=${BUILD_TIME}'" @@ -128,6 +130,33 @@ build_windows() { ls -lh build/bin/ } +# 构建 macOS ARM64 版本 +build_mac_arm() { + local VERSION=$(get_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}_mac_arm64.app" + info "构建 macOS ARM64 版本 v${VERSION} 构建时间=${BUILD_TIME}" + + GOOS=darwin GOARCH=arm64 wails build -platform darwin/arm64 -o "${OUTPUT_NAME}" -ldflags "-X 'douyu_go/internal/constants.BuildTime=${BUILD_TIME}'" + if [ -d "build/bin/douyu_go.app" ]; then + rm -rf "build/bin/${OUTPUT_NAME}" + mv "build/bin/douyu_go.app" "build/bin/${OUTPUT_NAME}" + fi + + success "macOS ARM64 构建完成!" + echo "" + echo "=== 构建产物 ===" + ls -lh build/bin/ +} + +# 构建发布版本:Windows amd64 与 macOS ARM64 +build_release() { + rm -rf build/bin/* + build_windows + build_mac_arm +} + # 构建 Linux 版本 build_linux() { local VERSION=$(get_version) @@ -163,7 +192,9 @@ show_help() { echo " ./build.sh # 开发模式(带热更新)" echo " ./build.sh dev # 开发模式(带热更新)" echo " ./build.sh build # 生产构建" - echo " ./build.sh win # 构建 Windows 版本" + echo " ./build.sh win # 构建 Windows 版本" + echo " ./build.sh mac-arm # 构建 macOS ARM64 版本" + echo " ./build.sh release # 构建 Windows amd64 和 macOS ARM64" echo " ./build.sh linux # 构建 Linux 版本" echo " ./build.sh clean # 清理构建产物" echo " ./build.sh install # 安装前端依赖" @@ -192,6 +223,12 @@ main() { win|windows) build_windows ;; + mac-arm|macos-arm|darwin-arm64) + build_mac_arm + ;; + release) + build_release + ;; linux) build_linux ;; diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 028a48f..9ece992 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -3,7 +3,7 @@ package constants import "time" // Version 应用版本号,与 wails.json version 同步。 -const Version = "0.1.3" +const Version = "0.1.4" // BuildTime 构建时间,由编译时 ldflags 注入。 var BuildTime = "unknown" diff --git a/wails.json b/wails.json index 5650057..3f12951 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.3", + "version": "0.1.4", "frontend:dir": "frontend", "frontend:install": "npm install", "frontend:build": "npm run build",