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.
This commit is contained in:
@@ -2,45 +2,56 @@ package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"log"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||
"github.com/wailsapp/wails/v2/pkg/options/linux"
|
||||
"github.com/wailsapp/wails/v3/pkg/application"
|
||||
)
|
||||
|
||||
//go:embed all:frontend/dist
|
||||
var assets embed.FS
|
||||
|
||||
func main() {
|
||||
// Create an instance of the app structure
|
||||
app := NewApp()
|
||||
// The service is created after the application (it needs the app
|
||||
// reference), so the single-instance callback closes over the variable
|
||||
// and resolves it at call time. A second instance can only launch once
|
||||
// this one is running, by which point svc is always set.
|
||||
var svc *App
|
||||
|
||||
// Create application with options
|
||||
err := wails.Run(&options.App{
|
||||
Title: "AniTrack",
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
AssetServer: &assetserver.Options{
|
||||
Assets: assets,
|
||||
app := application.New(application.Options{
|
||||
Name: "AniTrack",
|
||||
Description: "Track anime watchlists across AniList, MyAnimeList, and Simkl",
|
||||
Assets: application.AssetOptions{
|
||||
Handler: application.AssetFileServerFS(assets),
|
||||
},
|
||||
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
|
||||
OnStartup: app.startup,
|
||||
SingleInstanceLock: &options.SingleInstanceLock{
|
||||
UniqueId: "49c93b6d-663d-4b7a-9cb0-8a469ea9182b",
|
||||
OnSecondInstanceLaunch: app.onSecondInstanceLaunch,
|
||||
SingleInstance: &application.SingleInstanceOptions{
|
||||
UniqueID: "49c93b6d-663d-4b7a-9cb0-8a469ea9182b",
|
||||
OnSecondInstanceLaunch: func(data application.SecondInstanceData) {
|
||||
svc.onSecondInstanceLaunch(data)
|
||||
},
|
||||
},
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
Linux: &linux.Options{
|
||||
Icon: []byte("./build/AniTrack.png"),
|
||||
WindowIsTranslucent: false,
|
||||
WebviewGpuPolicy: linux.WebviewGpuPolicyNever,
|
||||
ProgramName: "AniTrack",
|
||||
Linux: application.LinuxOptions{
|
||||
ProgramName: "AniTrack",
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
|
||||
svc = NewApp(app)
|
||||
app.RegisterService(application.NewService(svc))
|
||||
|
||||
app.Window.NewWithOptions(application.WebviewWindowOptions{
|
||||
Title: appTitle(),
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
BackgroundColour: application.NewRGBA(27, 38, 54, 1),
|
||||
URL: "/",
|
||||
Linux: application.LinuxWindow{
|
||||
Icon: []byte("./build/AniTrack.png"),
|
||||
WindowIsTranslucent: false,
|
||||
WebviewGpuPolicy: application.WebviewGpuPolicyNever,
|
||||
},
|
||||
})
|
||||
|
||||
if err := app.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user