mirror of
https://github.com/thsrite/MoviePilot-Plugins.git
synced 2026-06-03 07:26:47 +00:00
fix 自定义命令增加历史
This commit is contained in:
@@ -29,5 +29,5 @@ MoviePilot三方插件市场:https://github.com/thsrite/MoviePilot-Plugins/
|
||||
- [源文件恢复 1.2](docs%2FLinkToSrc.md)
|
||||
- [微信消息转发 1.3](docs%2FWeChatForward.md)
|
||||
- [订阅下载统计 1.5](docs%2FSubscribeStatistic.md)
|
||||
- [自定义命令 1.1](docs%2FCustomCommand.md)
|
||||
- [自定义命令 1.2](docs%2FCustomCommand.md)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
### 更新记录
|
||||
|
||||
- 1.2 增加执行历史
|
||||
- 1.1 打印命令日志
|
||||
- 1.0 自定义执行周期执行命令并推送结果
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
"CustomCommand": {
|
||||
"name": "自定义命令",
|
||||
"description": "自定义执行周期执行命令并推送结果。",
|
||||
"version": "1.1",
|
||||
"version": "1.2",
|
||||
"icon": "Ntfy_A.png",
|
||||
"author": "thsrite",
|
||||
"level": 1
|
||||
|
||||
@@ -22,7 +22,7 @@ class CustomCommand(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "Ntfy_A.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.1"
|
||||
plugin_version = "1.2"
|
||||
# 插件作者
|
||||
plugin_author = "thsrite"
|
||||
# 作者主页
|
||||
@@ -129,6 +129,18 @@ class CustomCommand(_PluginBase):
|
||||
logger.info(
|
||||
f"执行命令:{command} {'成功' if result.returncode == 0 else '失败'} 返回值:{last_output if last_output else last_error}")
|
||||
|
||||
# 读取历史记录
|
||||
history = self.get_data('history') or []
|
||||
|
||||
history.append({
|
||||
"name": name,
|
||||
"command": command,
|
||||
"result": last_output if last_output else last_error,
|
||||
"time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
|
||||
})
|
||||
# 保存历史
|
||||
self.save_data(key="history", value=history)
|
||||
|
||||
if self._notify and self._msgtype:
|
||||
# 发送通知
|
||||
mtype = NotificationType.Manual
|
||||
@@ -321,7 +333,106 @@ class CustomCommand(_PluginBase):
|
||||
}
|
||||
|
||||
def get_page(self) -> List[dict]:
|
||||
pass
|
||||
# 查询同步详情
|
||||
historys = self.get_data('history')
|
||||
if not historys:
|
||||
return [
|
||||
{
|
||||
'component': 'div',
|
||||
'text': '暂无数据',
|
||||
'props': {
|
||||
'class': 'text-center',
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
if not isinstance(historys, list):
|
||||
historys = [historys]
|
||||
|
||||
# 按照签到时间倒序
|
||||
historys = sorted(historys, key=lambda x: x.get("time") or 0, reverse=True)
|
||||
|
||||
# 签到消息
|
||||
sign_msgs = [
|
||||
{
|
||||
'component': 'tr',
|
||||
'props': {
|
||||
'class': 'text-sm'
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'td',
|
||||
'props': {
|
||||
'class': 'whitespace-nowrap break-keep text-high-emphasis'
|
||||
},
|
||||
'text': history.get("time")
|
||||
},
|
||||
{
|
||||
'component': 'td',
|
||||
'text': history.get("name")
|
||||
},
|
||||
{
|
||||
'component': 'td',
|
||||
'text': history.get("result")
|
||||
}
|
||||
]
|
||||
} for history in historys
|
||||
]
|
||||
|
||||
# 拼装页面
|
||||
return [
|
||||
{
|
||||
'component': 'VRow',
|
||||
'content': [
|
||||
{
|
||||
'component': 'VCol',
|
||||
'props': {
|
||||
'cols': 12,
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'VTable',
|
||||
'props': {
|
||||
'hover': True
|
||||
},
|
||||
'content': [
|
||||
{
|
||||
'component': 'thead',
|
||||
'content': [
|
||||
{
|
||||
'component': 'th',
|
||||
'props': {
|
||||
'class': 'text-start ps-4'
|
||||
},
|
||||
'text': '执行时间'
|
||||
},
|
||||
{
|
||||
'component': 'th',
|
||||
'props': {
|
||||
'class': 'text-start ps-4'
|
||||
},
|
||||
'text': '命令名称'
|
||||
},
|
||||
{
|
||||
'component': 'th',
|
||||
'props': {
|
||||
'class': 'text-start ps-4'
|
||||
},
|
||||
'text': '执行结果'
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
'component': 'tbody',
|
||||
'content': sign_msgs
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
def stop_service(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user