5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-03 05:50:08 +08:00
wails/v3/plugins/browser/plugin.go
Lea Anthony 5949e305ea
Reorder startup sequence
Add plugin scripts to asset server
Add InjectJS support in plugins
2023-03-24 08:43:00 +11:00

49 lines
990 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) CallableByJS() []string {
return []string{
"OpenURL",
"OpenFile",
}
}
func (p *Plugin) InjectJS() string {
return ""
}
// ---------------- Plugin Methods ----------------
func (p *Plugin) OpenURL(url string) error {
return browser.OpenURL(url)
}
func (p *Plugin) OpenFile(path string) error {
return browser.OpenFile(path)
}