init
This commit is contained in:
34
app.go
34
app.go
@@ -5,12 +5,16 @@ import (
|
||||
|
||||
"sgg-ai-skill-manager/internal/domain"
|
||||
"sgg-ai-skill-manager/internal/service"
|
||||
"sgg-ai-skill-manager/internal/tray"
|
||||
|
||||
wailsruntime "github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
service *service.Service
|
||||
initErr error
|
||||
ctx context.Context
|
||||
service *service.Service
|
||||
initErr error
|
||||
trayStop func()
|
||||
}
|
||||
|
||||
func NewApp() *App {
|
||||
@@ -23,6 +27,30 @@ func (a *App) startup(ctx context.Context) {
|
||||
if a.service != nil {
|
||||
a.service.StartAutoUpdate(ctx)
|
||||
}
|
||||
a.startTray(ctx)
|
||||
}
|
||||
|
||||
func (a *App) shutdown(context.Context) {
|
||||
if a.trayStop != nil {
|
||||
a.trayStop()
|
||||
a.trayStop = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) startTray(ctx context.Context) {
|
||||
stop, err := tray.Start(ctx, tray.Config{
|
||||
Tooltip: appTitle,
|
||||
IconPath: defaultTrayIconPath,
|
||||
OnOpen: func() {
|
||||
wailsruntime.WindowShow(ctx)
|
||||
wailsruntime.WindowUnminimise(ctx)
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
wailsruntime.LogErrorf(ctx, "failed to start tray icon: %v", err)
|
||||
return
|
||||
}
|
||||
a.trayStop = stop
|
||||
}
|
||||
|
||||
func (a *App) LoadConfig() (domain.Config, error) {
|
||||
|
||||
Reference in New Issue
Block a user