Refactor menu functions and streamline devtools toggle across systems

This update adds implementation to several menu item functions, replacing their previous 'not implemented' state. This includes actions for close, reload, forcing reload, toggling of fullscreen, reset zoom, and others. The update also includes modifications for the handling of developer tools toggle under different build configurations. This refactoring is aimed to standardize devtools configuration across different operating systems.
This commit is contained in:
Lea Anthony
2024-01-21 20:52:32 +11:00
parent c82facd6ff
commit 6522657893
27 changed files with 326 additions and 165 deletions
+7 -17
View File
@@ -3,6 +3,7 @@ package assetserver
import (
"fmt"
"html"
"net"
"net/http"
"net/http/httptest"
"net/http/httputil"
@@ -144,20 +145,6 @@ func (a *AssetServer) serveError(rw http.ResponseWriter, err error, msg string,
rw.WriteHeader(http.StatusInternalServerError)
}
func (a *AssetServer) LogDetails() {
if a.options.IsDebug {
var info = []any{
"assetsFS", a.options.Assets != nil,
"middleware", a.options.Middleware != nil,
"handler", a.options.Handler != nil,
}
if a.devServerURL != "" {
info = append(info, "devServerURL", a.devServerURL)
}
a.options.Logger.Info("AssetServer Info:", info...)
}
}
func (a *AssetServer) AddPluginScript(pluginName string, script string) {
if a.pluginScripts == nil {
a.pluginScripts = make(map[string]string)
@@ -170,6 +157,7 @@ func (a *AssetServer) AddPluginScript(pluginName string, script string) {
func GetStartURL(userURL string) (string, error) {
devServerURL := GetDevServerURL()
startURL := baseURL.String()
if devServerURL != "" {
// Parse the port
parsedURL, err := url.Parse(devServerURL)
@@ -178,7 +166,8 @@ func GetStartURL(userURL string) (string, error) {
}
port := parsedURL.Port()
if port != "" {
startURL += ":" + port
baseURL.Host = net.JoinHostPort(baseURL.Host, port)
startURL = baseURL.String()
}
} else {
if userURL != "" {
@@ -188,9 +177,10 @@ func GetStartURL(userURL string) (string, error) {
return "", fmt.Errorf("Error parsing URL: " + err.Error())
}
if parsedURL.Scheme == "" {
startURL = path.Join(startURL, userURL)
baseURL.Path = path.Join(baseURL.Path, userURL)
startURL = baseURL.String()
// if the original URL had a trailing slash, add it back
if strings.HasSuffix(userURL, "/") {
if strings.HasSuffix(userURL, "/") && !strings.HasSuffix(startURL, "/") {
startURL = startURL + "/"
}
} else {
@@ -0,0 +1,8 @@
package assetserver
import "net/url"
var baseURL = url.URL{
Scheme: "wails",
Host: "localhost",
}
@@ -0,0 +1,15 @@
//go:build !production
package assetserver
func (a *AssetServer) LogDetails() {
var info = []any{
"assetsFS", a.options.Assets != nil,
"middleware", a.options.Middleware != nil,
"handler", a.options.Handler != nil,
}
if a.devServerURL != "" {
info = append(info, "devServerURL", a.devServerURL)
}
a.options.Logger.Info("AssetServer Info:", info...)
}
@@ -0,0 +1,5 @@
//go:build production
package assetserver
func (a *AssetServer) LogDetails() {}
@@ -1,3 +1,8 @@
package assetserver
var startURL = "http://wails.localhost"
import "net/url"
var baseURL = url.URL{
Scheme: "http",
Host: "wails.localhost",
}
-3
View File
@@ -46,9 +46,6 @@ type Options struct {
// GetFlags returns the application flags
GetFlags func() []byte
// IsDebug is true if the server is running in debug mode
IsDebug bool
}
// Validate the options