5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 23:20:51 +08:00

fix: config errors

This commit is contained in:
Lea Anthony 2019-07-12 10:22:19 +10:00
parent 8aa97f64ef
commit a2af626477
No known key found for this signature in database
GPG Key ID: 33DAF7BB90A58405
3 changed files with 18 additions and 52 deletions

6
app.go
View File

@ -20,7 +20,7 @@ var BuildMode = cmd.BuildModeProd
// App defines the main application struct
type App struct {
config *Config // The Application configuration object
config *AppConfig // The Application configuration object
cli *cmd.Cli // In debug mode, we have a cli
renderer interfaces.Renderer // The renderer is what we will render the app to
logLevel string // The log level of the app
@ -33,8 +33,8 @@ type App struct {
// CreateApp creates the application window with the given configuration
// If none given, the defaults are used
func CreateApp(optionalConfig ...*Config) *App {
var userConfig *Config
func CreateApp(optionalConfig ...*AppConfig) *App {
var userConfig *AppConfig
if len(optionalConfig) > 0 {
userConfig = optionalConfig[0]
}

View File

@ -1,4 +1,4 @@
package cmd
// Version - Wails version
const Version = "v0.17.3-pre"
const Version = "v0.17.4-pre"

View File

@ -1,14 +1,8 @@
package wails
import (
"strings"
"github.com/dchest/htmlmin"
// "github.com/leaanthony/mewn"
)
// Config is the configuration structure used when creating a Wails App object
type Config struct {
// AppConfig is the configuration structure used when creating a Wails App object
type AppConfig struct {
Width, Height int
Title string
defaultHTML string
@ -18,87 +12,60 @@ type Config struct {
Colour string
Resizable bool
DisableInspector bool
// isHTMLFragment bool
}
// GetWidth returns the desired width
func (a *Config) GetWidth() int {
func (a *AppConfig) GetWidth() int {
return a.Width
}
// GetHeight returns the desired height
func (a *Config) GetHeight() int {
func (a *AppConfig) GetHeight() int {
return a.Height
}
// GetTitle returns the desired window title
func (a *Config) GetTitle() string {
func (a *AppConfig) GetTitle() string {
return a.Title
}
// GetDefaultHTML returns the desired window title
func (a *Config) GetDefaultHTML() string {
func (a *AppConfig) GetDefaultHTML() string {
return a.defaultHTML
}
// GetResizable returns true if the window should be resizable
func (a *Config) GetResizable() bool {
func (a *AppConfig) GetResizable() bool {
return a.Resizable
}
// GetDisableInspector returns true if the inspector should be disabled
func (a *Config) GetDisableInspector() bool {
func (a *AppConfig) GetDisableInspector() bool {
return a.DisableInspector
}
// GetColour returns the colour
func (a *Config) GetColour() string {
func (a *AppConfig) GetColour() string {
return a.Colour
}
// GetCSS returns the user CSS
func (a *Config) GetCSS() string {
func (a *AppConfig) GetCSS() string {
return a.CSS
}
// GetJS returns the user Javascript
func (a *Config) GetJS() string {
func (a *AppConfig) GetJS() string {
return a.JS
}
func (a *Config) merge(in *Config) error {
func (a *AppConfig) merge(in *AppConfig) error {
if in.CSS != "" {
a.CSS = in.CSS
}
if in.Title != "" {
a.Title = in.Title
}
// if in.HTML != "" {
// minified, err := htmlmin.Minify([]byte(in.HTML), &htmlmin.Options{
// MinifyScripts: true,
// })
// if err != nil {
// return err
// }
// inlineHTML := string(minified)
// inlineHTML = strings.Replace(inlineHTML, "'", "\\'", -1)
// inlineHTML = strings.Replace(inlineHTML, "\n", " ", -1)
// a.HTML = strings.TrimSpace(inlineHTML)
// // Deduce whether this is a full html page or a fragment
// // The document is determined to be a fragment if an HTML
// // tag exists and is located before the first div tag
// HTMLTagIndex := strings.Index(a.HTML, "<html")
// DivTagIndex := strings.Index(a.HTML, "<div")
// if HTMLTagIndex == -1 {
// a.isHTMLFragment = true
// } else {
// if DivTagIndex < HTMLTagIndex {
// a.isHTMLFragment = true
// }
// }
// }
if in.Colour != "" {
a.Colour = in.Colour
@ -121,14 +88,13 @@ func (a *Config) merge(in *Config) error {
}
// Creates the default configuration
func newConfig(userConfig *Config) (*Config, error) {
result := &Config{
func newConfig(userConfig *AppConfig) (*AppConfig, error) {
result := &AppConfig{
Width: 800,
Height: 600,
Resizable: true,
Title: "My Wails App",
Colour: "#FFF", // White by default
// HTML: mewn.String("./runtime/assets/default.html"),
}
if userConfig != nil {