diff --git a/config.go b/config.go index 57f27461..f900a9a1 100644 --- a/config.go +++ b/config.go @@ -1,6 +1,10 @@ package wails import ( + "fmt" + "net/url" + "strings" + "github.com/leaanthony/mewn" "github.com/wailsapp/wails/runtime" ) @@ -9,7 +13,6 @@ import ( type AppConfig struct { Width, Height int Title string - defaultHTML string HTML string JS string CSS string @@ -33,9 +36,13 @@ func (a *AppConfig) GetTitle() string { return a.Title } -// GetDefaultHTML returns the default HTML -func (a *AppConfig) GetDefaultHTML() string { - return a.defaultHTML +// GetHTML returns the default HTML +func (a *AppConfig) GetHTML() string { + if len(a.HTML) > 0 { + var temp = url.QueryEscape(a.HTML) + a.HTML = "data:text/html," + strings.ReplaceAll(temp, "+", "%20") + } + return a.HTML } // GetResizable returns true if the window should be resizable @@ -79,6 +86,10 @@ func (a *AppConfig) merge(in *AppConfig) error { a.JS = in.JS } + if in.HTML != "" { + a.HTML = in.HTML + } + if in.Width != 0 { a.Width = in.Width } @@ -109,5 +120,9 @@ func newConfig(userConfig *AppConfig) (*AppConfig, error) { } } + println("****************************************************") + fmt.Printf("%+v\n", result) + println("****************************************************") + return result, nil } diff --git a/lib/interfaces/appconfig.go b/lib/interfaces/appconfig.go index 6946c918..6e063b4d 100644 --- a/lib/interfaces/appconfig.go +++ b/lib/interfaces/appconfig.go @@ -6,9 +6,9 @@ type AppConfig interface { GetHeight() int GetTitle() string GetResizable() bool - GetDefaultHTML() string + GetHTML() string GetDisableInspector() bool GetColour() string GetCSS() string GetJS() string -} \ No newline at end of file +} diff --git a/lib/renderer/webview.go b/lib/renderer/webview.go index 0b19ac55..c51e76bc 100644 --- a/lib/renderer/webview.go +++ b/lib/renderer/webview.go @@ -58,7 +58,7 @@ func (w *WebView) Initialise(config interfaces.AppConfig, ipc interfaces.IPCMana Height: config.GetHeight(), Title: config.GetTitle(), Resizable: config.GetResizable(), - URL: config.GetDefaultHTML(), + URL: config.GetHTML(), Debug: !config.GetDisableInspector(), ExternalInvokeCallback: func(_ wv.WebView, message string) { w.ipc.Dispatch(message, w.callback)