mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(app): 为 Windows 系统添加系统托盘功能并支持 Linux
- 在 app.go 中添加了对 Windows 操作系统的判断- 仅在 Windows 系统上创建系统托盘 - 更新 GitHub Actions 工作流,添加 Linux 平台的构建
This commit is contained in:
parent
64270d5df2
commit
9a3393bfc3
3
.github/workflows/main.yml
vendored
3
.github/workflows/main.yml
vendored
@ -20,6 +20,9 @@ jobs:
|
|||||||
- name: 'go-stock.exe'
|
- name: 'go-stock.exe'
|
||||||
platform: 'windows/amd64'
|
platform: 'windows/amd64'
|
||||||
os: 'windows-latest'
|
os: 'windows-latest'
|
||||||
|
- name: 'go-stock'
|
||||||
|
platform: 'linux/amd64'
|
||||||
|
os: 'ubuntu-latest'
|
||||||
|
|
||||||
runs-on: ${{ matrix.build.os }}
|
runs-on: ${{ matrix.build.os }}
|
||||||
steps:
|
steps:
|
||||||
|
5
app.go
5
app.go
@ -29,12 +29,16 @@ func (a *App) startup(ctx context.Context) {
|
|||||||
// Perform your setup here
|
// Perform your setup here
|
||||||
a.ctx = ctx
|
a.ctx = ctx
|
||||||
|
|
||||||
|
//判断是否是windows操作系统
|
||||||
|
platform := runtime.Environment(ctx).Platform
|
||||||
|
if platform == "windows" {
|
||||||
// 创建系统托盘
|
// 创建系统托盘
|
||||||
go systray.Run(func() {
|
go systray.Run(func() {
|
||||||
onReady(a)
|
onReady(a)
|
||||||
}, func() {
|
}, func() {
|
||||||
onExit(a)
|
onExit(a)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +136,7 @@ func onExit(a *App) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func onReady(a *App) {
|
func onReady(a *App) {
|
||||||
|
|
||||||
// 初始化操作
|
// 初始化操作
|
||||||
logger.SugaredLogger.Infof("onReady")
|
logger.SugaredLogger.Infof("onReady")
|
||||||
systray.SetIcon(icon2)
|
systray.SetIcon(icon2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user