mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-04 23:11:53 +08:00

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.
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
//go:build !production
|
|
|
|
package application
|
|
|
|
import (
|
|
"github.com/wailsapp/wails/v3/internal/assetserver"
|
|
"net/http"
|
|
"time"
|
|
)
|
|
|
|
var devMode = false
|
|
|
|
func (a *App) preRun() error {
|
|
// Check for frontend server url
|
|
frontendURL := assetserver.GetDevServerURL()
|
|
if frontendURL != "" {
|
|
devMode = true
|
|
// We want to check if the frontend server is running by trying to http get the url
|
|
// and if it is not, we wait 500ms and try again for a maximum of 10 times. If it is
|
|
// still not available, we return an error.
|
|
// This is to allow the frontend server to start up before the backend server.
|
|
client := http.Client{}
|
|
a.Logger.Info("Waiting for frontend dev server to start...", "url", frontendURL)
|
|
for i := 0; i < 10; i++ {
|
|
_, err := client.Get(frontendURL)
|
|
if err == nil {
|
|
a.Logger.Info("Connected to frontend dev server!")
|
|
return nil
|
|
}
|
|
// Wait 500ms
|
|
time.Sleep(500 * time.Millisecond)
|
|
if i%2 == 0 {
|
|
a.Logger.Info("Retrying...")
|
|
}
|
|
}
|
|
a.fatal("unable to connect to frontend server. Please check it is running", "FRONTEND_DEVSERVER_URL", frontendURL)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (a *App) postQuit() {
|
|
if devMode {
|
|
a.Logger.Info("The application has terminated, but the watcher is still running.")
|
|
a.Logger.Info("To terminate the watcher, press CTRL+C")
|
|
}
|
|
}
|
|
|
|
func (a *App) enableDevTools() {
|
|
|
|
}
|