mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-03 04:42:00 +08:00
Revert "Allow use of custom HTML (#545)"
This reverts commit dc605c1683
.
This commit is contained in:
parent
e2599c0f76
commit
f97341abbe
File diff suppressed because one or more lines are too long
30
config.go
30
config.go
@ -1,8 +1,7 @@
|
||||
package wails
|
||||
|
||||
import (
|
||||
b64 "encoding/base64"
|
||||
|
||||
"github.com/leaanthony/mewn"
|
||||
"github.com/wailsapp/wails/runtime"
|
||||
)
|
||||
|
||||
@ -10,6 +9,7 @@ import (
|
||||
type AppConfig struct {
|
||||
Width, Height int
|
||||
Title string
|
||||
defaultHTML string
|
||||
HTML string
|
||||
JS string
|
||||
CSS string
|
||||
@ -33,9 +33,9 @@ func (a *AppConfig) GetTitle() string {
|
||||
return a.Title
|
||||
}
|
||||
|
||||
// GetHTML returns the HTML for the app
|
||||
func (a *AppConfig) GetHTML() string {
|
||||
return "data:text/html;base64," + b64.URLEncoding.EncodeToString([]byte(a.HTML))
|
||||
// GetDefaultHTML returns the default HTML
|
||||
func (a *AppConfig) GetDefaultHTML() string {
|
||||
return a.defaultHTML
|
||||
}
|
||||
|
||||
// GetResizable returns true if the window should be resizable
|
||||
@ -75,10 +75,6 @@ func (a *AppConfig) merge(in *AppConfig) error {
|
||||
a.Colour = in.Colour
|
||||
}
|
||||
|
||||
if in.HTML != "" {
|
||||
a.HTML = in.HTML
|
||||
}
|
||||
|
||||
if in.JS != "" {
|
||||
a.JS = in.JS
|
||||
}
|
||||
@ -103,7 +99,7 @@ func newConfig(userConfig *AppConfig) (*AppConfig, error) {
|
||||
Resizable: true,
|
||||
Title: "My Wails App",
|
||||
Colour: "#FFF", // White by default
|
||||
HTML: defaultHTML,
|
||||
HTML: mewn.String("./runtime/assets/default.html"),
|
||||
}
|
||||
|
||||
if userConfig != nil {
|
||||
@ -115,17 +111,3 @@ func newConfig(userConfig *AppConfig) (*AppConfig, error) {
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
var defaultHTML = `<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
</body>
|
||||
|
||||
</html>`
|
||||
|
@ -6,7 +6,7 @@ type AppConfig interface {
|
||||
GetHeight() int
|
||||
GetTitle() string
|
||||
GetResizable() bool
|
||||
GetHTML() string
|
||||
GetDefaultHTML() string
|
||||
GetDisableInspector() bool
|
||||
GetColour() string
|
||||
GetCSS() string
|
||||
|
File diff suppressed because one or more lines are too long
@ -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.GetHTML(),
|
||||
URL: config.GetDefaultHTML(),
|
||||
Debug: !config.GetDisableInspector(),
|
||||
ExternalInvokeCallback: func(_ wv.WebView, message string) {
|
||||
w.ipc.Dispatch(message, w.callback)
|
||||
|
18
runtime/assets/default.html
Normal file
18
runtime/assets/default.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="text/javascript">function AddScript(js, callbackID) {
|
||||
var script = document.createElement('script');
|
||||
script.text = js;
|
||||
document.body.appendChild(script);
|
||||
}</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user