mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
Radical JS runtime overhaul. New @wailsio/runtime package
This commit is contained in:
@@ -41,26 +41,26 @@ func (m *MessageProcessor) httpError(rw http.ResponseWriter, message string, arg
|
||||
rw.Write([]byte(fmt.Sprintf(message, args...)))
|
||||
}
|
||||
|
||||
func (m *MessageProcessor) getTargetWindow(r *http.Request) Window {
|
||||
func (m *MessageProcessor) getTargetWindow(r *http.Request) (Window, string) {
|
||||
windowName := r.Header.Get(webViewRequestHeaderWindowName)
|
||||
if windowName != "" {
|
||||
return globalApplication.GetWindowByName(windowName)
|
||||
return globalApplication.GetWindowByName(windowName), windowName
|
||||
}
|
||||
windowID := r.Header.Get(webViewRequestHeaderWindowId)
|
||||
if windowID == "" {
|
||||
return nil
|
||||
return nil, windowID
|
||||
}
|
||||
wID, err := strconv.ParseUint(windowID, 10, 64)
|
||||
if err != nil {
|
||||
m.Error("Window ID '%s' not parsable: %s", windowID, err)
|
||||
return nil
|
||||
return nil, windowID
|
||||
}
|
||||
targetWindow := globalApplication.getWindowForID(uint(wID))
|
||||
if targetWindow == nil {
|
||||
m.Error("Window ID %d not found", wID)
|
||||
return nil
|
||||
return nil, windowID
|
||||
}
|
||||
return targetWindow
|
||||
return targetWindow, windowID
|
||||
}
|
||||
|
||||
func (m *MessageProcessor) HandleRuntimeCall(rw http.ResponseWriter, r *http.Request) {
|
||||
@@ -115,9 +115,9 @@ func (m *MessageProcessor) HandleRuntimeCallWithIDs(rw http.ResponseWriter, r *h
|
||||
}
|
||||
params := QueryParams(r.URL.Query())
|
||||
|
||||
targetWindow := m.getTargetWindow(r)
|
||||
targetWindow, nameOrID := m.getTargetWindow(r)
|
||||
if targetWindow == nil {
|
||||
m.httpError(rw, "No valid window found")
|
||||
m.httpError(rw, fmt.Sprintf("Window '%s' not found", nameOrID))
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user