mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 04:11:56 +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.Run()
|
||||||
mainWindow.Close()
|
mainWindow.Close()
|
||||||
return nil
|
return nil
|
||||||
@ -412,11 +408,6 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC
|
|||||||
go f.frontendOptions.OnDomReady(f.ctx)
|
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
|
// Hack to make it visible: https://github.com/MicrosoftEdge/WebView2Feedback/issues/1077#issuecomment-825375026
|
||||||
err := f.chromium.Hide()
|
err := f.chromium.Hide()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -426,6 +417,24 @@ func (f *Frontend) navigationCompleted(sender *edge.ICoreWebView2, args *edge.IC
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
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"
|
"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
|
// App contains options for creating the App
|
||||||
type App struct {
|
type App struct {
|
||||||
Title string
|
Title string
|
||||||
@ -39,6 +48,7 @@ type App struct {
|
|||||||
OnDomReady func(ctx context.Context) `json:"-"`
|
OnDomReady func(ctx context.Context) `json:"-"`
|
||||||
OnShutdown func(ctx context.Context) `json:"-"`
|
OnShutdown func(ctx context.Context) `json:"-"`
|
||||||
Bind []interface{}
|
Bind []interface{}
|
||||||
|
WindowStartState WindowStartState
|
||||||
|
|
||||||
//ContextMenus []*menu.ContextMenu
|
//ContextMenus []*menu.ContextMenu
|
||||||
//TrayMenus []*menu.TrayMenu
|
//TrayMenus []*menu.TrayMenu
|
||||||
|
Loading…
Reference in New Issue
Block a user