PagerMaid-Pyro/pagermaid/web/pages/plugin_local_manage.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
2.3 KiB
Python
Raw Permalink Normal View History

2023-01-31 16:24:56 +00:00
from amis import InputText, Switch, Card, CardsCRUD, PageSchema, Page
card = Card(
header=Card.Header(
2023-03-12 03:56:01 +00:00
title="$name", avatarText="$name", avatarTextClassName="overflow-hidden"
2023-01-31 16:24:56 +00:00
),
actions=[],
toolbar=[
Switch(
2023-03-12 03:56:01 +00:00
name="enable",
value="${status}",
onText="启用",
offText="禁用",
2023-01-31 16:24:56 +00:00
onEvent={
2023-03-12 03:56:01 +00:00
"change": {
"actions": [
2023-01-31 16:24:56 +00:00
{
2023-03-12 03:56:01 +00:00
"actionType": "ajax",
"args": {
"api": {
"url": "/pagermaid/api/set_local_plugin_status",
"method": "post",
"dataType": "json",
"data": {
"plugin": "${name}",
"status": "${IF(event.data.value, 1, 0)}",
},
2023-01-31 16:24:56 +00:00
},
"onSuccess": {
"type": "tpl",
"tpl": "${payload.msg}", # 使用返回的 msg 字段作为成功消息
},
"onError": {
"type": "tpl",
"tpl": "操作失败",
2023-01-31 16:24:56 +00:00
},
2023-03-12 03:56:01 +00:00
"status": "${event.data.value}",
"plugin": "${name}",
},
2023-01-31 16:24:56 +00:00
},
]
}
2023-03-12 03:56:01 +00:00
},
2023-01-31 16:24:56 +00:00
)
2023-03-12 03:56:01 +00:00
],
2023-01-31 16:24:56 +00:00
)
cards_curd = CardsCRUD(
2023-03-12 03:56:01 +00:00
mode="cards",
title="",
2023-01-31 16:24:56 +00:00
syncLocation=False,
2023-03-12 03:56:01 +00:00
api="/pagermaid/api/get_local_plugins",
2023-01-31 16:24:56 +00:00
loadDataOnce=True,
2023-03-12 03:56:01 +00:00
source="${rows | filter:name:match:keywords_name}",
filter={"body": [InputText(name="keywords_name", label="插件名")]},
2023-01-31 16:24:56 +00:00
perPage=12,
autoJumpToTopOnPagerChange=True,
2023-03-12 03:56:01 +00:00
placeholder="暂无插件信息",
footerToolbar=["switch-per-page", "pagination"],
2023-01-31 16:24:56 +00:00
columnsCount=3,
2023-03-12 03:56:01 +00:00
card=card,
2023-01-31 16:24:56 +00:00
)
page = PageSchema(
2023-03-12 03:56:01 +00:00
url="/plugins/local",
icon="fa fa-database",
label="本地插件管理",
schema=Page(title="本地插件管理", body=cards_curd),
2023-01-31 16:24:56 +00:00
)