Files
Anitrack/app.go
T
John O'Keefe 850c1c6aee chore(wailsv3): migrate Go backend from Wails v2 to v3
Minimal-structure migration to Wails v3.0.0-beta.20 (CLI-matching pin). Single App service preserved; no domain logic touched.

- main.go: wails.Run(options.App) -> application.New + RegisterService + Window.NewWithOptions. Window keeps title-with-version, 1024x768, RGBA background, Linux icon/translucency/GpuPolicyNever, ProgramName. SingleInstanceLock -> SingleInstanceOptions (same UniqueID); callback closes over the service variable set right after New.
- app.go: App holds *application.App instead of a context. startup(ctx) is gone; the version title moves into the window options via appTitle(). onSecondInstanceLaunch takes v3 SecondInstanceData (Args/WorkingDir) and uses Window.Current() Restore+Focus plus Event.Emit for launchArgs. ShowVersion uses Dialog.Info.
- AniList/MAL/Simkl *UserFunctions.go: runtime.BrowserOpenURL -> app.Browser.OpenURL (errors logged), runtime.MessageDialog -> app.Dialog.Info chains. OAuth callback servers, token flows, and key names unchanged.
- Secrets: 99designs/keyring replaced with zalando/go-keyring (what v3 itself depends on) under the same AniTrack service name, so existing stored tokens keep working. Per-file Set helpers kept; Open/Ready boilerplate deleted (zalando needs no handle).
- go.mod: v2 + 99designs dropped (stale v2 replace directive removed), v3 beta.20 + zalando v0.2.8 added.
2026-09-13 17:10:09 -04:00

50 lines
1.0 KiB
Go

package main
import (
_ "embed"
"strings"
"github.com/tidwall/gjson"
"github.com/wailsapp/wails/v3/pkg/application"
)
//go:embed wails.json
var wailsJSON string
// App struct
type App struct {
app *application.App
}
// NewApp creates a new App application struct
func NewApp(app *application.App) *App {
return &App{app: app}
}
// appVersion reads the product version from wails.json.
func appVersion() string {
return gjson.Get(wailsJSON, "info.productVersion").String()
}
// appTitle is the window title: "AniTrack <version>".
func appTitle() string {
return "AniTrack " + appVersion()
}
func (a *App) onSecondInstanceLaunch(data application.SecondInstanceData) {
println("user opened second instance", strings.Join(data.Args, ","))
println("user opened second from", data.WorkingDir)
if w := a.app.Window.Current(); w != nil {
w.Restore()
w.Focus()
}
go a.app.Event.Emit("launchArgs", data.Args)
}
func (a *App) ShowVersion() {
a.app.Dialog.Info().
SetTitle("Version").
SetMessage("AniTrack Version: " + appVersion()).
Show()
}