mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-15 15:15:51 +01:00
* custom transport initial * transport codecs * runtime set transport * events transport * clauded example * bundled runtime * wip: transport * rework transports * rework dialog responses * cleanup * cleanup * improve error handling in HTTPTransport * cleanup * cleanup * cleanup * cleanup * review changes * review changes * review changes * review changes * review changes * review changes * review changes * move documentation to website docs * update doc * update changelog * introduce JSClient method for transport for embedding JS part in transport --------- Co-authored-by: Atterpac <Capretta.Michael@gmail.com> Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
39 lines
912 B
Go
39 lines
912 B
Go
package application
|
|
|
|
import (
|
|
"github.com/pkg/browser"
|
|
"github.com/wailsapp/wails/v3/pkg/errs"
|
|
)
|
|
|
|
const (
|
|
BrowserOpenURL = 0
|
|
)
|
|
|
|
var browserMethodNames = map[int]string{
|
|
BrowserOpenURL: "OpenURL",
|
|
}
|
|
|
|
func (m *MessageProcessor) processBrowserMethod(req *RuntimeRequest) (any, error) {
|
|
switch req.Method {
|
|
case BrowserOpenURL:
|
|
url := req.Args.AsMap().String("url")
|
|
if url == nil {
|
|
return nil, errs.NewInvalidBrowserCallErrorf("missing argument 'url'")
|
|
}
|
|
|
|
sanitizedURL, err := ValidateAndSanitizeURL(*url)
|
|
if err != nil {
|
|
return nil, errs.WrapInvalidBrowserCallErrorf(err, "invalid URL")
|
|
}
|
|
|
|
err = browser.OpenURL(sanitizedURL)
|
|
if err != nil {
|
|
m.Error("OpenURL: invalid URL - %s", err.Error())
|
|
return nil, errs.WrapInvalidBrowserCallErrorf(err, "OpenURL failed")
|
|
}
|
|
|
|
return unit, nil
|
|
default:
|
|
return nil, errs.NewInvalidBrowserCallErrorf("unknown method: %d", req.Method)
|
|
}
|
|
}
|