Fix window close: use RegisterHook to hide instead of destroy
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled
Desktop App / Build Linux (amd64) (push) Has been cancelled
Desktop App / Attach to Release (push) Has been cancelled

RegisterHook + e.Cancel() prevents Wails from destroying the WebView
when the window is closed. The app now hides to the system tray. Left-
click on the tray icon correctly restores the window.
This commit is contained in:
2026-07-14 00:34:01 +02:00
parent 7063c90898
commit 06c6f4eb8c

View File

@@ -23,6 +23,7 @@ import (
"time"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/pkg/events"
"github.com/zalando/go-keyring"
)
@@ -760,6 +761,12 @@ func main() {
} else {
window.Center()
}
window.RegisterHook(events.Common.WindowClosing, func(e *application.WindowEvent) {
window.Hide()
e.Cancel()
})
window.Show()
systemTray.AttachWindow(window)