Discover Packages
github.com/TeaWeb/plugin
module
Version:
v0.0.0-...-17a5fe9
Opens a new window with list of versions in this module.
Published: Aug 16, 2020
License: MIT
Opens a new window with license information.
README
README
¶
TeaWeb插件接口
如何实现一个自己的插件
新建一个项目,项目结构为:
demo-plugin/
src/
github.com/
TeaWeb/
plugin/
[https://github.com/TeaWeb/plugin源码]
main/
demo.go - 你的插件源文件
build.sh - 构建脚本
在main/
目录下建一个插件的Go文件,比如命名为demo.go
;
在demo.go
中实现
package main
import (
"github.com/TeaWeb/plugin/loader"
"github.com/TeaWeb/plugin/plugins"
)
func main() {
demoPlugin := plugins.NewPlugin()
demoPlugin.Name = "Demo Plugin"
demoPlugin.Code = "com.example.demo"
demoPlugin.Developer = "Liu xiangchao"
demoPlugin.Version = "1.0.0"
demoPlugin.Date = "2018-10-15"
demoPlugin.Site = "https://github.com/TeaWeb/build"
demoPlugin.Description = "这是一个Demo插件"
loader.Start(demoPlugin)
}
可以修改demoPlugin
,以提供插件的名称、描述等信息,或者实现其他功能;
使用go build -o demo.tea demo.go
编译插件;
将编译成功后的demo.tea
放到TeaWeb
的plugins/
目录下,重启TeaWeb
后生效。
构建脚本
build.sh
#!/usr/bin/env bash
export GOPATH=`pwd`/../../
export CGO_ENABLED=1
# msgpack
if [ ! -d "${GOPATH}/src/github.com/vmihailenco/msgpack" ]
then
go get "github.com/vmihailenco/msgpack"
fi
# TeaWeb
if [ ! -d "${GOPATH}/src/github.com/TeaWeb/plugin" ]
then
go get "github.com/TeaWeb/plugin"
fi
go build -o demo.tea demo.go
代码示例
请见 main/demo.go 。
安装插件
将TeaWeb
插件拷贝到plugins/
目录下,即可完成安装:
bin/
plugins/
demo.tea
...
安装后,请重启TeaWeb
后插件生效,然后在Web界面中的"插件"菜单中可以看到加载成功的插件。
Expand ▾
Collapse ▴
Directories
¶
Click to show internal directories.
Click to hide internal directories.