This commit is contained in:
2026-05-13 20:40:14 +08:00
parent bd13c842a8
commit c8a75ef2d5
17 changed files with 920 additions and 93 deletions

34
app.go
View File

@@ -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) {