mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
refactor(app): 调整系统托盘创建逻辑并更新应用配置
- 将系统托盘创建逻辑从 main.go 移动到 app.go 中的 startup 方法- 更新应用配置,添加生产环境日志级别配置 - 移除 main.go 中的冗余注释
This commit is contained in:
parent
6483243d2a
commit
02bfe4758e
8
app.go
8
app.go
@ -39,6 +39,14 @@ func NewApp() *App {
|
|||||||
func (a *App) startup(ctx context.Context) {
|
func (a *App) startup(ctx context.Context) {
|
||||||
// Perform your setup here
|
// Perform your setup here
|
||||||
a.ctx = ctx
|
a.ctx = ctx
|
||||||
|
|
||||||
|
// 创建系统托盘
|
||||||
|
go systray.Run(func() {
|
||||||
|
onReady(a)
|
||||||
|
}, func() {
|
||||||
|
onExit(a)
|
||||||
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// domReady is called after front-end resources have been loaded
|
// domReady is called after front-end resources have been loaded
|
||||||
|
53
main.go
53
main.go
@ -4,7 +4,6 @@ import (
|
|||||||
"embed"
|
"embed"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"github.com/duke-git/lancet/v2/convertor"
|
"github.com/duke-git/lancet/v2/convertor"
|
||||||
"github.com/getlantern/systray"
|
|
||||||
"github.com/wailsapp/wails/v2"
|
"github.com/wailsapp/wails/v2"
|
||||||
"github.com/wailsapp/wails/v2/pkg/logger"
|
"github.com/wailsapp/wails/v2/pkg/logger"
|
||||||
"github.com/wailsapp/wails/v2/pkg/menu"
|
"github.com/wailsapp/wails/v2/pkg/menu"
|
||||||
@ -84,37 +83,31 @@ func main() {
|
|||||||
// runtime.Quit(app.ctx)
|
// runtime.Quit(app.ctx)
|
||||||
//})
|
//})
|
||||||
|
|
||||||
// 创建系统托盘
|
|
||||||
go systray.Run(func() {
|
|
||||||
onReady(app)
|
|
||||||
}, func() {
|
|
||||||
onExit(app)
|
|
||||||
})
|
|
||||||
|
|
||||||
// Create application with options
|
// Create application with options
|
||||||
err := wails.Run(&options.App{
|
err := wails.Run(&options.App{
|
||||||
Title: "go-stock",
|
Title: "go-stock",
|
||||||
Width: 1366,
|
Width: 1366,
|
||||||
Height: 920,
|
Height: 920,
|
||||||
MinWidth: 1024,
|
MinWidth: 1024,
|
||||||
MinHeight: 768,
|
MinHeight: 768,
|
||||||
MaxWidth: 1280,
|
MaxWidth: 1280,
|
||||||
MaxHeight: 960,
|
MaxHeight: 960,
|
||||||
DisableResize: false,
|
DisableResize: false,
|
||||||
Fullscreen: false,
|
Fullscreen: false,
|
||||||
Frameless: true,
|
Frameless: true,
|
||||||
StartHidden: false,
|
StartHidden: false,
|
||||||
HideWindowOnClose: false,
|
HideWindowOnClose: false,
|
||||||
BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
|
BackgroundColour: &options.RGBA{R: 255, G: 255, B: 255, A: 255},
|
||||||
Assets: assets,
|
Assets: assets,
|
||||||
Menu: AppMenu,
|
Menu: AppMenu,
|
||||||
Logger: nil,
|
Logger: nil,
|
||||||
LogLevel: logger.DEBUG,
|
LogLevel: logger.DEBUG,
|
||||||
OnStartup: app.startup,
|
LogLevelProduction: logger.ERROR,
|
||||||
OnDomReady: app.domReady,
|
OnStartup: app.startup,
|
||||||
OnBeforeClose: app.beforeClose,
|
OnDomReady: app.domReady,
|
||||||
OnShutdown: app.shutdown,
|
OnBeforeClose: app.beforeClose,
|
||||||
WindowStartState: options.Normal,
|
OnShutdown: app.shutdown,
|
||||||
|
WindowStartState: options.Normal,
|
||||||
Bind: []interface{}{
|
Bind: []interface{}{
|
||||||
app,
|
app,
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user