mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 03:21:32 +08:00
[v2] Add WindowStartState. Fix startHidden option. Only windows supported atm
This commit is contained in:
parent
bad9ad3dd7
commit
56ef4ddd47
@ -130,10 +130,6 @@ func (f *Frontend) Run(ctx context.Context) error {
|
||||
}
|
||||
}()
|
||||
|
||||
if f.frontendOptions.Fullscreen {
|
||||
mainWindow.Fullscreen()
|
||||
}
|
||||
|
||||
mainWindow.Run()
|
||||
mainWindow.Close()
|
||||
return nil
|
||||
@ -412,11 +408,6 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC
|
||||
go f.frontendOptions.OnDomReady(f.ctx)
|
||||
}
|
||||
|
||||
// If you want to start hidden, return
|
||||
if f.frontendOptions.StartHidden {
|
||||
return
|
||||
}
|
||||
|
||||
// Hack to make it visible: https://github.com/MicrosoftEdge/WebView2Feedback/issues/1077#issuecomment-825375026
|
||||
err := f.chromium.Hide()
|
||||
if err != nil {
|
||||
@ -426,6 +417,24 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
f.mainWindow.Show()
|
||||
|
||||
if f.frontendOptions.StartHidden {
|
||||
return
|
||||
}
|
||||
|
||||
switch f.frontendOptions.WindowStartState {
|
||||
case options.Maximised:
|
||||
f.mainWindow.Maximise()
|
||||
case options.Minimised:
|
||||
f.mainWindow.Minimise()
|
||||
case options.Fullscreen:
|
||||
f.mainWindow.Fullscreen()
|
||||
f.mainWindow.Show()
|
||||
default:
|
||||
if f.frontendOptions.Fullscreen {
|
||||
f.mainWindow.Fullscreen()
|
||||
}
|
||||
f.mainWindow.Show()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,15 @@ import (
|
||||
"github.com/wailsapp/wails/v2/pkg/logger"
|
||||
)
|
||||
|
||||
type WindowStartState int
|
||||
|
||||
const (
|
||||
Normal WindowStartState = 0
|
||||
Maximised WindowStartState = 1
|
||||
Minimised WindowStartState = 2
|
||||
Fullscreen WindowStartState = 3
|
||||
)
|
||||
|
||||
// App contains options for creating the App
|
||||
type App struct {
|
||||
Title string
|
||||
@ -39,6 +48,7 @@ type App struct {
|
||||
OnDomReady func(ctx context.Context) `json:"-"`
|
||||
OnShutdown func(ctx context.Context) `json:"-"`
|
||||
Bind []interface{}
|
||||
WindowStartState WindowStartState
|
||||
|
||||
//ContextMenus []*menu.ContextMenu
|
||||
//TrayMenus []*menu.TrayMenu
|
||||
|
Loading…
Reference in New Issue
Block a user