mirror of
https://github.com/wailsapp/wails.git
synced 2025-05-02 18:10:48 +08:00
26 lines
718 B
Go
26 lines
718 B
Go
package wails
|
|
|
|
import "github.com/pkg/browser"
|
|
|
|
// GlobalRuntimeBrowser is the global instance of the RuntimeBrowser object
|
|
// Why? Because we need to use it in both the runtime and from the frontend
|
|
var GlobalRuntimeBrowser = newRuntimeBrowser()
|
|
|
|
// RuntimeBrowser exposes browser methods to the runtime
|
|
type RuntimeBrowser struct {
|
|
}
|
|
|
|
func newRuntimeBrowser() *RuntimeBrowser {
|
|
return &RuntimeBrowser{}
|
|
}
|
|
|
|
// OpenURL opens the given url in the system's default browser
|
|
func (r *RuntimeBrowser) OpenURL(url string) error {
|
|
return browser.OpenURL(url)
|
|
}
|
|
|
|
// OpenFile opens the given file in the system's default browser
|
|
func (r *RuntimeBrowser) OpenFile(filePath string) error {
|
|
return browser.OpenFile(filePath)
|
|
}
|