5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 15:11:53 +08:00
wails/v3/plugins/browser/plugin.go
2023-03-21 08:55:55 +11:00

45 lines
935 B
Go

package browser
import (
"github.com/pkg/browser"
"github.com/wailsapp/wails/v3/pkg/application"
)
// ---------------- Plugin Setup ----------------
// This is the main plugin struct. It can be named anything you like.
// It must implement the application.Plugin interface.
// Both the Init() and Shutdown() methods are called synchronously when the app starts and stops.
type Plugin struct{}
func NewPlugin() *Plugin {
return &Plugin{}
}
func (p *Plugin) Shutdown() {}
func (p *Plugin) Name() string {
return "github.com/wailsapp/wails/v3/plugins/browser"
}
func (p *Plugin) Init(_ *application.App) error {
return nil
}
func (p *Plugin) Exported() []string {
return []string{
"OpenURL",
"OpenFile",
}
}
// ---------------- Plugin Methods ----------------
func (p *Plugin) OpenURL(url string) error {
return browser.OpenURL(url)
}
func (p *Plugin) OpenFile(path string) error {
return browser.OpenFile(path)
}