Remove Browser plugin. Update plugin example

This commit is contained in:
Lea Anthony 2023-10-12 08:41:18 +11:00
commit 0577fefd75
No known key found for this signature in database
GPG key ID: 33DAF7BB90A58405
5 changed files with 3 additions and 139 deletions

View file

@ -6,10 +6,9 @@ import (
"plugin_demo/plugins/hashes"
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/plugins/browser"
"github.com/wailsapp/wails/v3/plugins/experimental/server"
"github.com/wailsapp/wails/v3/plugins/kvstore"
"github.com/wailsapp/wails/v3/plugins/log"
"github.com/wailsapp/wails/v3/plugins/server"
"github.com/wailsapp/wails/v3/plugins/single_instance"
"github.com/wailsapp/wails/v3/plugins/sqlite"
"github.com/wailsapp/wails/v3/plugins/start_at_login"
@ -27,9 +26,8 @@ func main() {
ApplicationShouldTerminateAfterLastWindowClosed: true,
},
Plugins: map[string]application.Plugin{
"hashes": hashes.NewPlugin(),
"browser": browser.NewPlugin(),
"log": log.NewPlugin(),
"hashes": hashes.NewPlugin(),
"log": log.NewPlugin(),
"sqlite": sqlite.NewPlugin(&sqlite.Config{
DBFile: "test.db",
}),

View file

@ -1,51 +0,0 @@
# Browser Plugin
This plugin provides the ability to open a URL or local file in the default browser.
## Installation
Add the plugin to the `Plugins` option in the Applications options:
```go
package main
import (
"github.com/wailsapp/wails/v3/pkg/application"
"github.com/wailsapp/wails/v3/plugins/browser"
)
func main() {
browserPlugin := browser.NewPlugin()
app := application.New(application.Options{
// ...
Plugins: map[string]application.Plugin{
"browser": browserPlugin,
},
})
```
## Usage
### Go
You can call the methods exported by the plugin directly:
```go
browserPlugin.OpenURL("https://www.google.com")
// or
browserPlugin.OpenFile("/path/to/file")
```
### Javascript
You can call the methods from the frontend using the Plugin method:
```js
wails.Plugin("browser","OpenURL","https://www.google.com")
// or
wails.Plugin("browser","OpenFile","/path/to/file")
```
## Support
If you find a bug in this plugin, please raise a ticket on the Wails [Issue Tracker](https://github.com/wailsapp/wails/issues).

View file

@ -1,47 +0,0 @@
package browser
import (
"github.com/pkg/browser"
)
// ---------------- 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() 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)
}

View file

@ -1,25 +0,0 @@
/**
* Opens the given URL in the default browser.
* @param url {string} - The URL to open.
* @returns {Promise<void>}
*/
function OpenURL(url) {
return wails.CallByID(3188315539, url);
}
/**
* Opens the given filename in the default browser.
* @param filename {string} - The file to open.
* @returns {Promise<void>}
*/
function OpenFile(filename) {
return wails.CallByID(3105408620, filename);
}
export default {
Browser: {
OpenURL,
OpenFile,
}
};

View file

@ -1,11 +0,0 @@
# This is the plugin definition file for the "browser" plugin.
---
Name: browser
Description: Opens URLs and files in the default browser.
Author: Lea Anthony
Version: v1.0.0
Website: https://wails.io
Repository: https://github.com/wailsapp/wails/v3/plugins/browser
License: MIT