mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 20:51:38 +08:00
[windows-x] Support debug flag, prevent devtools, zoom and context menus in prod builds
This commit is contained in:
parent
c383a61036
commit
83baf4c6bb
30
v2/go.mod
30
v2/go.mod
@ -1,6 +1,6 @@
|
||||
module github.com/wailsapp/wails/v2
|
||||
|
||||
go 1.16
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/Masterminds/semver v1.5.0
|
||||
@ -46,6 +46,30 @@ require (
|
||||
nhooyr.io/websocket v1.8.6
|
||||
)
|
||||
|
||||
replace github.com/tadvi/winc v0.0.0-20190405175627-5454f291903d => C:\Users\leaan\GolandProjects\winc
|
||||
require (
|
||||
github.com/Microsoft/go-winio v0.4.16 // indirect
|
||||
github.com/emirpasic/gods v1.12.0 // indirect
|
||||
github.com/go-git/gcfg v1.5.0 // indirect
|
||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||
github.com/google/go-cmp v0.5.5 // indirect
|
||||
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
|
||||
github.com/jchv/go-winloader v0.0.0-20200815041850-dec1ee9a7fd5 // indirect
|
||||
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
|
||||
github.com/logrusorgru/aurora v0.0.0-20181002194514-a7b3b318ed4e // indirect
|
||||
github.com/mattn/go-runewidth v0.0.7 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
|
||||
github.com/sergi/go-diff v1.1.0 // indirect
|
||||
github.com/tidwall/gjson v1.8.0 // indirect
|
||||
github.com/tidwall/match v1.0.3 // indirect
|
||||
github.com/tidwall/pretty v1.1.0 // indirect
|
||||
github.com/wzshiming/winseq v0.0.0-20200112104235-db357dc107ae // indirect
|
||||
github.com/xanzy/ssh-agent v0.3.0 // indirect
|
||||
golang.org/x/image v0.0.0-20201208152932-35266b937fa6 // indirect
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
|
||||
gopkg.in/warnings.v0 v0.1.2 // indirect
|
||||
)
|
||||
|
||||
replace github.com/jchv/go-webview2 v0.0.0-20210720204005-cbb937ae0f7f => C:\Users\leaan\GolandProjects\go-webview2
|
||||
replace github.com/tadvi/winc v0.0.0-20190405175627-5454f291903d => C:\Users\leaan\Documents\wails-v2-beta\winc
|
||||
|
||||
replace github.com/jchv/go-webview2 v0.0.0-20210720204005-cbb937ae0f7f => C:\Users\leaan\Documents\wails-v2-beta\go-webview2
|
||||
|
@ -88,17 +88,8 @@ func CreateApp(appoptions *options.App) (*App, error) {
|
||||
|
||||
result.options = appoptions
|
||||
|
||||
//// Initialise the app
|
||||
//err := result.Init()
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
//
|
||||
//// Preflight Checks
|
||||
//err = result.PreflightChecks(appoptions)
|
||||
//if err != nil {
|
||||
// return nil, err
|
||||
//}
|
||||
result.SetupFlags()
|
||||
result.ctx = context.WithValue(result.ctx, "debug", result.debug)
|
||||
|
||||
return result, nil
|
||||
|
||||
|
8
v2/internal/appng/app_debug.go
Normal file
8
v2/internal/appng/app_debug.go
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build debug
|
||||
// +build debug
|
||||
|
||||
package appng
|
||||
|
||||
func (a *App) SetupFlags() {
|
||||
a.debug = true
|
||||
}
|
8
v2/internal/appng/app_production.go
Normal file
8
v2/internal/appng/app_production.go
Normal file
@ -0,0 +1,8 @@
|
||||
//go:build production
|
||||
// +build production
|
||||
|
||||
package appng
|
||||
|
||||
func (a *App) SetupFlags() {
|
||||
a.debug = false
|
||||
}
|
@ -26,6 +26,7 @@ type Frontend struct {
|
||||
frontendOptions *options.App
|
||||
logger *logger.Logger
|
||||
chromium *edge.Chromium
|
||||
debug bool
|
||||
|
||||
// Assets
|
||||
assets *assetserver.AssetServer
|
||||
@ -42,6 +43,11 @@ func (f *Frontend) Run(ctx context.Context) error {
|
||||
mainWindow := NewWindow(nil, f.frontendOptions)
|
||||
f.mainWindow = mainWindow
|
||||
|
||||
var _debug = ctx.Value("debug")
|
||||
if _debug != nil {
|
||||
f.debug = _debug.(bool)
|
||||
}
|
||||
|
||||
f.WindowCenter()
|
||||
|
||||
if !f.frontendOptions.StartHidden {
|
||||
@ -161,6 +167,22 @@ func (f *Frontend) setupChromium() {
|
||||
chromium.WebResourceRequestedCallback = f.processRequest
|
||||
chromium.Embed(f.mainWindow.Handle())
|
||||
chromium.Resize()
|
||||
settings, err := chromium.GetSettings()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = settings.PutAreDefaultContextMenusEnabled(f.debug)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = settings.PutAreDevToolsEnabled(f.debug)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = settings.PutIsZoomControlEnabled(false)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
chromium.AddWebResourceRequestedFilter("*", edge.COREWEBVIEW2_WEB_RESOURCE_CONTEXT_ALL)
|
||||
chromium.Navigate("file://wails/")
|
||||
f.chromium = chromium
|
||||
|
@ -7,10 +7,9 @@ import (
|
||||
|
||||
// Default options for creating the App
|
||||
var Default = &App{
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
DevTools: false,
|
||||
RGBA: 0xFFFFFFFF,
|
||||
Width: 1024,
|
||||
Height: 768,
|
||||
RGBA: 0xFFFFFFFF,
|
||||
Mac: &mac.Options{
|
||||
TitleBar: mac.TitleBarDefault(),
|
||||
Appearance: mac.DefaultAppearance,
|
||||
|
@ -28,7 +28,6 @@ type App struct {
|
||||
MaxHeight int
|
||||
StartHidden bool
|
||||
HideWindowOnClose bool
|
||||
DevTools bool
|
||||
RGBA int
|
||||
ContextMenus []*menu.ContextMenu
|
||||
TrayMenus []*menu.TrayMenu
|
||||
|
Loading…
Reference in New Issue
Block a user