feat:插件仪表板API

This commit is contained in:
jxxghp
2024-05-08 20:58:28 +08:00
parent cce2e13e21
commit 5c9039e6d0
5 changed files with 133 additions and 31 deletions

View File

@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from pathlib import Path
from typing import Any, List, Dict, Tuple
from typing import Any, List, Dict, Tuple, Optional
from app.chain import ChainBase
from app.core.config import settings
@ -55,6 +55,13 @@ class _PluginBase(metaclass=ABCMeta):
"""
pass
@abstractmethod
def get_state(self) -> bool:
"""
获取插件运行状态
"""
pass
@staticmethod
@abstractmethod
def get_command() -> List[Dict[str, Any]]:
@ -84,19 +91,6 @@ class _PluginBase(metaclass=ABCMeta):
"""
pass
def get_service(self) -> List[Dict[str, Any]]:
"""
注册插件公共服务
[{
"id": "服务ID",
"name": "服务名称",
"trigger": "触发器cron/interval/date/CronTrigger.from_crontab()",
"func": self.xxx,
"kwargs": {} # 定时器参数
}]
"""
pass
@abstractmethod
def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
"""
@ -113,10 +107,31 @@ class _PluginBase(metaclass=ABCMeta):
"""
pass
@abstractmethod
def get_state(self) -> bool:
def get_service(self) -> List[Dict[str, Any]]:
"""
获取插件运行状态
注册插件公共服务
[{
"id": "服务ID",
"name": "服务名称",
"trigger": "触发器cron/interval/date/CronTrigger.from_crontab()",
"func": self.xxx,
"kwargs": {} # 定时器参数
}]
"""
pass
def get_dashboard(self) -> Optional[Tuple[Dict[str, Any], Dict[str, Any], List[dict]]]:
"""
获取插件仪表盘页面需要返回1、仪表板col配置字典2、全局配置自动刷新等3、仪表板页面元素配置json含数据
1、col配置参考
{
"cols": 12, "md": 6
}
2、全局配置参考
{
"refresh": 10 // 自动刷新时间,单位秒
}
3、页面配置使用Vuetify组件拼装参考https://vuetifyjs.com/
"""
pass