From 2f3df076de558b458de5900701f1d75de73860f1 Mon Sep 17 00:00:00 2001 From: yisier <1340976576@qq.com> Date: Fri, 23 Jan 2026 13:49:59 +0800 Subject: [PATCH] pkg test8 --- .github/workflows/gui.yml | 40 ++++++++++++++++++++++----------- cmd/npc/npc-gui/app_bindings.go | 5 +++-- cmd/npc/npc-gui/tray.go | 5 +++++ 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/.github/workflows/gui.yml b/.github/workflows/gui.yml index 8bf81ff..eda2f6f 100644 --- a/.github/workflows/gui.yml +++ b/.github/workflows/gui.yml @@ -21,10 +21,10 @@ jobs: - os: windows-latest platform: windows/arm64 artifact_name: npc-gui-windows-arm64 - - os: macos-15 # 使用最新的 macOS 15 Intel 运行器 + - os: macos-latest # GitHub 已下线 macos-13,统一使用最新 ARM 运行器 platform: darwin/amd64 artifact_name: npc-gui-macos-amd64 - - os: macos-latest # Apple Silicon (M系列) + - os: macos-latest platform: darwin/arm64 artifact_name: npc-gui-macos-arm64 - os: ubuntu-latest @@ -58,7 +58,6 @@ jobs: - name: Install Linux dependencies if: runner.os == 'Linux' run: | - # 增加重试机制,防止 apt 锁死或网络抖动 for i in {1..3}; do sudo apt-get update && \ sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev build-essential pkg-config && break || \ @@ -85,12 +84,23 @@ jobs: CGO_ENABLED: 1 shell: bash run: | - # 动态构建参数 - FLAGS="-clean -trimpath" + # 提取架构信息 + ARCH=${{ matrix.platform }} + ARCH=${ARCH#*/} + + # 设置基础编译标志 + # -s -w 减小体积并减少符号冲突 + FLAGS="-clean -trimpath -ldflags \"-s -w\"" + if [[ "${{ runner.os }}" == "Windows" ]]; then FLAGS="$FLAGS -webview2 embed" fi + # 针对 macOS 的特殊处理:即使在 ARM 运行器上,也强制通过环境变量指定架构 + if [[ "${{ runner.os }}" == "macOS" ]]; then + export GOARCH=$ARCH + fi + # 执行构建 wails build -platform ${{ matrix.platform }} $FLAGS @@ -113,20 +123,24 @@ jobs: run: | cd build/bin if [ "${{ runner.os }}" == "macOS" ]; then - # 打包 Mac 的 .app 目录 - APP_DIR=$(ls -d *.app | head -n 1) - if [ -n "$APP_DIR" ]; then - zip -r "${{ matrix.artifact_name }}.zip" "$APP_DIR" + # macOS 打包:寻找 .app 目录 + APP_PATH=$(find . -maxdepth 1 -name "*.app" -type d | head -n 1) + if [ -n "$APP_PATH" ]; then + zip -r "${{ matrix.artifact_name }}.zip" "$APP_PATH" else - echo "No .app found" && exit 1 + echo "Error: No .app directory found in $(pwd)" + ls -la + exit 1 fi else - # 打包 Linux 二进制文件 - BINARY_NAME=$(ls -F | grep -v / | head -n 1 | sed 's/\*//') + # Linux 打包:寻找二进制文件 + BINARY_NAME=$(find . -maxdepth 1 -type f -executable | head -n 1) if [ -n "$BINARY_NAME" ]; then zip "${{ matrix.artifact_name }}.zip" "$BINARY_NAME" else - echo "No binary found" && exit 1 + echo "Error: No executable binary found in $(pwd)" + ls -la + exit 1 fi fi diff --git a/cmd/npc/npc-gui/app_bindings.go b/cmd/npc/npc-gui/app_bindings.go index 86761a4..081b5cf 100644 --- a/cmd/npc/npc-gui/app_bindings.go +++ b/cmd/npc/npc-gui/app_bindings.go @@ -14,7 +14,6 @@ import ( "ehang.io/nps/client" "ehang.io/nps/lib/version" - "fyne.io/systray" _ "github.com/astaxie/beego" "github.com/astaxie/beego/logs" wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" @@ -180,7 +179,9 @@ func closeClientLogger(id string) { } func (a *App) shutdown(ctx context.Context) { - systray.Quit() + setQuitting() + QuitTray() + wailsRuntime.Quit(a.ctx) } // 持久化文件结构(向后兼容旧的仅数组格式) diff --git a/cmd/npc/npc-gui/tray.go b/cmd/npc/npc-gui/tray.go index 6ec7cde..e6c5953 100644 --- a/cmd/npc/npc-gui/tray.go +++ b/cmd/npc/npc-gui/tray.go @@ -32,6 +32,11 @@ func isQuitting() bool { return quitting } +// QuitTray 退出托盘程序 +func QuitTray() { + systray.Quit() +} + // startTray 初始化系统托盘 func (a *App) startTray() { // 锁定 OS 线程,确保 Windows 消息循环稳定运行