🛠️ 插件开发指南
插件结构
store/@{作者}/插件名/
├── main.py # 插件入口(必须实现 Plugin 接口)
└── manifest.json # 插件元数据(名称、版本、依赖)
插件接口
from oss.plugin.types import Plugin
class MyPlugin(Plugin):
def init(self, deps: dict = None):
# 初始化逻辑
pass
def start(self):
# 启动逻辑
pass
def stop(self):
# 停止逻辑
pass
@property
def manifest(self):
return {
"name": "my-plugin",
"version": "1.0.0",
"dependencies": [],
"description": "我的插件"
}
关键原则
- 插件通过
from oss.plugin.types import Plugin使用框架定义的接口 - 插件的
main.py被importlib加载到框架的 Python 进程中 - 插件可以直接
from oss.xxx import xxx引用框架模块 - 所有插件通过
config.json配置,不修改源码
依赖声明
// manifest.json
{
"name": "html-render",
"version": "1.0.0",
"dependencies": ["http-api", "plugin-storage"],
"description": "HTML 渲染插件"
}
框架会自动调用 set_http_api() 和 set_plugin_storage() 注入依赖实例。
安装格式
格式为 @{作者名称}/插件名称,例如 @{Falck}/html-render。