Init
This commit is contained in:
28
README.md
28
README.md
@@ -54,5 +54,31 @@ just because program not running to the place where argument been referenced
|
|||||||
First import interface and define class
|
First import interface and define class
|
||||||
```python
|
```python
|
||||||
from CoreModules.plugin_interface import PluginInterface, DatabaseModel
|
from CoreModules.plugin_interface import PluginInterface, DatabaseModel
|
||||||
class MyPlugin()
|
|
||||||
|
class MyPlugin(PluginInterface):
|
||||||
|
def generate_router_callback(self):
|
||||||
|
"""生成路由回调函数,必需实现"""
|
||||||
|
async def callback():
|
||||||
|
return {"message": "Hello from MyPlugin"}
|
||||||
|
return callback
|
||||||
|
|
||||||
|
def register_db_model(self):
|
||||||
|
"""注册数据库模型,可选实现"""
|
||||||
|
return DatabaseModel(
|
||||||
|
table_name="my_plugin_table",
|
||||||
|
column_names=["id", "data", "created_at"],
|
||||||
|
column_defs={
|
||||||
|
"id": "INTEGER PRIMARY KEY",
|
||||||
|
"data": "TEXT",
|
||||||
|
"created_at": "INTEGER"
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def dependencies(self):
|
||||||
|
"""定义依赖的插件类,可选实现"""
|
||||||
|
return [] # 返回空列表表示无依赖
|
||||||
|
|
||||||
|
def wake_up(self):
|
||||||
|
"""依赖插件注册完成后调用,可选实现"""
|
||||||
|
pass
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user