From 4b127fb3f82508a2971eeb3869ea22157a9129d6 Mon Sep 17 00:00:00 2001 From: yisier <1340976576@qq.com> Date: Sat, 24 Jan 2026 00:03:06 +0800 Subject: [PATCH] pkg test15 --- .github/workflows/pkg.yml | 80 +++++----------------------------- cmd/npc/npc-gui/tray.go | 22 +--------- cmd/npc/npc-gui/tray_common.go | 23 ++++++++++ cmd/npc/npc-gui/tray_darwin.go | 13 ++++++ 4 files changed, 48 insertions(+), 90 deletions(-) create mode 100644 cmd/npc/npc-gui/tray_common.go create mode 100644 cmd/npc/npc-gui/tray_darwin.go diff --git a/.github/workflows/pkg.yml b/.github/workflows/pkg.yml index 7b6916e..24cd43b 100644 --- a/.github/workflows/pkg.yml +++ b/.github/workflows/pkg.yml @@ -74,80 +74,20 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - build_npc_gui: - - runs-on: ${{ matrix.os }} - strategy: - matrix: - include: - - os: ubuntu-latest - platform: linux/amd64 - artifact: linux_amd64 - - os: windows-latest - platform: windows/amd64 - artifact: windows_amd64 - - os: macos-latest - platform: darwin/amd64 - artifact: darwin_amd64 + build_android: + runs-on: ubuntu-latest steps: - - - name: Check out code + - name: Check out code into the Go module directory uses: actions/checkout@v2 - - - name: Set up Go 1.x - uses: actions/setup-go@v2 - with: - go-version: 1.22 - - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '18' - - - name: Enable Yarn (corepack) - run: corepack enable - - - name: Install frontend deps + - name: Build run: | - cd cmd/npc/npc-gui/frontend - yarn install --frozen-lockfile - - - name: Install Linux Dependencies - if: runner.os == 'Linux' - run: | - sudo apt-get update - sudo apt-get install -y upx libgtk-3-dev libwebkit2gtk-4.0-dev - - - name: Install UPX (macOS) - if: runner.os == 'macOS' - run: brew install upx - - - name: Install UPX (Windows) - if: runner.os == 'Windows' - run: choco install upx - - - name: Install Wails CLI - run: | - go install github.com/wailsapp/wails/v2/cmd/wails@latest - echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - - name: Build Wails app - run: | - cd cmd/npc/npc-gui - $(go env GOPATH)/bin/wails build -platform ${{ matrix.platform }} -upx - shell: bash - - - name: Package build output - run: | - cd cmd/npc/npc-gui/build/bin - tar -czvf ../../../npc_gui_${{ matrix.artifact }}.tar.gz ./* - ls -la ../../../npc_gui_${{ matrix.artifact }}.tar.gz - shell: bash - - - name: Upload npc-gui artifact + chmod +x build.android.sh + docker run --rm -i -w /app -v $(pwd):/app -e ANDROID_HOME=/usr/local/android_sdk -e GOPROXY=direct fyneio/fyne-cross:android-latest /app/build.android.sh + - name: Upload uses: softprops/action-gh-release@v1 if: startsWith(github.ref, 'refs/tags/') with: - files: cmd/npc/npc-gui/npc_gui_${{ matrix.artifact }}.tar.gz + files: | + android_client.apk env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/cmd/npc/npc-gui/tray.go b/cmd/npc/npc-gui/tray.go index 7ea72b6..4040a67 100644 --- a/cmd/npc/npc-gui/tray.go +++ b/cmd/npc/npc-gui/tray.go @@ -1,3 +1,5 @@ +//go:build !darwin + package main import ( @@ -12,26 +14,6 @@ import ( wailsRuntime "github.com/wailsapp/wails/v2/pkg/runtime" ) -// 定义退出标志 -var ( - quitting bool - quitMutex sync.Mutex -) - -// setQuitting 设置退出状态 -func setQuitting() { - quitMutex.Lock() - defer quitMutex.Unlock() - quitting = true -} - -// isQuitting 检查是否正在退出 -func isQuitting() bool { - quitMutex.Lock() - defer quitMutex.Unlock() - return quitting -} - // QuitTray 退出托盘程序 func QuitTray() { systray.Quit() diff --git a/cmd/npc/npc-gui/tray_common.go b/cmd/npc/npc-gui/tray_common.go new file mode 100644 index 0000000..3711f35 --- /dev/null +++ b/cmd/npc/npc-gui/tray_common.go @@ -0,0 +1,23 @@ +package main + +import "sync" + +// 退出状态由公共文件维护,避免平台实现重复定义。 +var ( + quitting bool + quitMutex sync.Mutex +) + +// setQuitting 设置退出状态 +func setQuitting() { + quitMutex.Lock() + defer quitMutex.Unlock() + quitting = true +} + +// isQuitting 检查是否正在退出 +func isQuitting() bool { + quitMutex.Lock() + defer quitMutex.Unlock() + return quitting +} diff --git a/cmd/npc/npc-gui/tray_darwin.go b/cmd/npc/npc-gui/tray_darwin.go new file mode 100644 index 0000000..bfec192 --- /dev/null +++ b/cmd/npc/npc-gui/tray_darwin.go @@ -0,0 +1,13 @@ +//go:build darwin + +package main + +import "log" + +// QuitTray no-op on macOS to avoid AppDelegate conflict with systray. +func QuitTray() {} + +// startTray on macOS: disable systray to avoid duplicate AppDelegate symbols. +func (a *App) startTray() { + log.Println("tray: disabled on darwin (systray AppDelegate conflict)") +}