mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 03:20:09 +08:00
Support named windows
Remove debug info
This commit is contained in:
parent
f94e798c50
commit
00ee79ecdc
@ -92,10 +92,8 @@ type App struct {
|
||||
applicationEventListenersLock sync.RWMutex
|
||||
|
||||
// Windows
|
||||
windows map[uint]*WebviewWindow
|
||||
windowsLock sync.Mutex
|
||||
windowAliases map[string]uint
|
||||
windowAliasesLock sync.Mutex
|
||||
windows map[uint]*WebviewWindow
|
||||
windowsLock sync.Mutex
|
||||
|
||||
// System Trays
|
||||
systemTrays map[uint]*SystemTray
|
||||
@ -196,14 +194,6 @@ func (a *App) NewWebviewWindowWithOptions(windowOptions *options.WebviewWindow)
|
||||
a.windows[id] = newWindow
|
||||
a.windowsLock.Unlock()
|
||||
|
||||
if windowOptions.Alias != "" {
|
||||
if a.windowAliases == nil {
|
||||
a.windowAliases = make(map[string]uint)
|
||||
}
|
||||
a.windowAliasesLock.Lock()
|
||||
a.windowAliases[windowOptions.Alias] = id
|
||||
a.windowAliasesLock.Unlock()
|
||||
}
|
||||
if a.running {
|
||||
newWindow.run()
|
||||
}
|
||||
@ -245,7 +235,10 @@ func (a *App) Run() error {
|
||||
for {
|
||||
event := <-webviewRequests
|
||||
a.handleWebViewRequest(event)
|
||||
event.request.Release()
|
||||
err := event.request.Release()
|
||||
if err != nil {
|
||||
a.error("Failed to release webview request: %s", err.Error())
|
||||
}
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
|
@ -1,11 +1,10 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func (m *MessageProcessor) processEventsMethod(method string, rw http.ResponseWriter, r *http.Request, window *WebviewWindow, params QueryParams) {
|
||||
func (m *MessageProcessor) processEventsMethod(method string, rw http.ResponseWriter, _ *http.Request, window *WebviewWindow, params QueryParams) {
|
||||
|
||||
switch method {
|
||||
case "Emit":
|
||||
@ -19,7 +18,7 @@ func (m *MessageProcessor) processEventsMethod(method string, rw http.ResponseWr
|
||||
m.httpError(rw, "Event name must be specified")
|
||||
return
|
||||
}
|
||||
event.Sender = fmt.Sprintf("%d", window.id)
|
||||
event.Sender = window.Name()
|
||||
globalApplication.Events.Emit(&event)
|
||||
m.ok(rw)
|
||||
default:
|
||||
|
@ -1,7 +1,6 @@
|
||||
package application
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/wailsapp/wails/v3/pkg/logger"
|
||||
@ -16,7 +15,7 @@ func (m *MessageProcessor) processLogMethod(method string, rw http.ResponseWrite
|
||||
m.httpError(rw, "error parsing log message: %s", err.Error())
|
||||
return
|
||||
}
|
||||
msg.Sender = fmt.Sprintf("%d", window.id)
|
||||
msg.Sender = window.Name()
|
||||
globalApplication.Log(&msg)
|
||||
m.ok(rw)
|
||||
default:
|
||||
|
@ -131,6 +131,13 @@ func (w *WebviewWindow) SetTitle(title string) *WebviewWindow {
|
||||
return w
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) Name() string {
|
||||
if w.options.Name != "" {
|
||||
return w.options.Name
|
||||
}
|
||||
return fmt.Sprintf("Window %d", w.id)
|
||||
}
|
||||
|
||||
func (w *WebviewWindow) SetSize(width, height int) *WebviewWindow {
|
||||
// Don't set size if fullscreen
|
||||
if w.IsFullscreen() {
|
||||
@ -630,7 +637,7 @@ func (w *WebviewWindow) info(message string, args ...any) {
|
||||
Level: "INFO",
|
||||
Message: message,
|
||||
Data: args,
|
||||
Sender: fmt.Sprintf("window %d", w.id),
|
||||
Sender: w.Name(),
|
||||
Time: time.Now(),
|
||||
})
|
||||
}
|
||||
|
@ -1105,7 +1105,6 @@ func (w *macosWebviewWindow) run() {
|
||||
if w.parent.options.Hidden == false {
|
||||
C.windowShow(w.nsWindow)
|
||||
}
|
||||
C.printWindowStyle(w.nsWindow)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -15,8 +15,7 @@ const (
|
||||
)
|
||||
|
||||
type WebviewWindow struct {
|
||||
// Alias is a human-readable name for the window. This can be used to reference the window in the frontend.
|
||||
Alias string
|
||||
Name string
|
||||
Title string
|
||||
Width, Height int
|
||||
AlwaysOnTop bool
|
||||
|
Loading…
Reference in New Issue
Block a user