From 9a3393bfc3a99ca2a7e4b6746ae03cdea4d5a310 Mon Sep 17 00:00:00 2001 From: spark Date: Mon, 6 Jan 2025 16:30:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(app):=20=E4=B8=BA=20Windows=20=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=B7=BB=E5=8A=A0=E7=B3=BB=E7=BB=9F=E6=89=98=E7=9B=98?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=94=AF=E6=8C=81=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 app.go 中添加了对 Windows 操作系统的判断- 仅在 Windows 系统上创建系统托盘 - 更新 GitHub Actions 工作流,添加 Linux 平台的构建 --- .github/workflows/main.yml | 3 +++ app.go | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3029d29..611bed6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,6 +20,9 @@ jobs: - name: 'go-stock.exe' platform: 'windows/amd64' os: 'windows-latest' + - name: 'go-stock' + platform: 'linux/amd64' + os: 'ubuntu-latest' runs-on: ${{ matrix.build.os }} steps: diff --git a/app.go b/app.go index 2a8f0e9..82ce23d 100644 --- a/app.go +++ b/app.go @@ -29,12 +29,16 @@ func (a *App) startup(ctx context.Context) { // Perform your setup here a.ctx = ctx - // 创建系统托盘 - go systray.Run(func() { - onReady(a) - }, func() { - onExit(a) - }) + //判断是否是windows操作系统 + platform := runtime.Environment(ctx).Platform + if platform == "windows" { + // 创建系统托盘 + go systray.Run(func() { + onReady(a) + }, func() { + onExit(a) + }) + } } @@ -132,6 +136,7 @@ func onExit(a *App) { } func onReady(a *App) { + // 初始化操作 logger.SugaredLogger.Infof("onReady") systray.SetIcon(icon2)