mirror of
https://github.com/xuthus83/LittlePaimon.git
synced 2024-12-16 13:40:53 +08:00
🎉 Web UI
修改插件信息后清除缓存了的帮助图,更新|重启
按钮放到首页中以防移动端看不见
This commit is contained in:
parent
977a05a0f2
commit
01a3143d04
@ -5,7 +5,7 @@ from fastapi.responses import JSONResponse
|
|||||||
from fastapi import APIRouter
|
from fastapi import APIRouter
|
||||||
|
|
||||||
from LittlePaimon.database.models import PluginPermission
|
from LittlePaimon.database.models import PluginPermission
|
||||||
from LittlePaimon.manager.plugin_manager import plugin_manager
|
from LittlePaimon.manager.plugin_manager import plugin_manager, cache_help
|
||||||
from LittlePaimon.manager.plugin_manager.model import PluginInfo, Config
|
from LittlePaimon.manager.plugin_manager.model import PluginInfo, Config
|
||||||
|
|
||||||
from .utils import authentication
|
from .utils import authentication
|
||||||
@ -30,6 +30,7 @@ async def get_plugins():
|
|||||||
async def set_plugin_status(data: dict):
|
async def set_plugin_status(data: dict):
|
||||||
module_name = data.get('plugin')
|
module_name = data.get('plugin')
|
||||||
status = data.get('status')
|
status = data.get('status')
|
||||||
|
cache_help.clear()
|
||||||
await PluginPermission.filter(name=module_name).update(status=status)
|
await PluginPermission.filter(name=module_name).update(status=status)
|
||||||
return {'status': 0, 'msg': f'成功设置{module_name}插件状态为{status}'}
|
return {'status': 0, 'msg': f'成功设置{module_name}插件状态为{status}'}
|
||||||
|
|
||||||
@ -73,6 +74,7 @@ async def set_plugin_bans(data: dict):
|
|||||||
status=False)
|
status=False)
|
||||||
else:
|
else:
|
||||||
await PluginPermission.filter(name=name, session_type='user', session_id=int(ban)).update(status=False)
|
await PluginPermission.filter(name=name, session_type='user', session_id=int(ban)).update(status=False)
|
||||||
|
cache_help.clear()
|
||||||
return {
|
return {
|
||||||
'status': 0,
|
'status': 0,
|
||||||
'msg': '插件权限设置成功'
|
'msg': '插件权限设置成功'
|
||||||
@ -83,6 +85,7 @@ async def set_plugin_bans(data: dict):
|
|||||||
async def set_plugin_detail(plugin_info: PluginInfo):
|
async def set_plugin_detail(plugin_info: PluginInfo):
|
||||||
plugin_manager.data[plugin_info.module_name] = plugin_info
|
plugin_manager.data[plugin_info.module_name] = plugin_info
|
||||||
plugin_manager.save()
|
plugin_manager.save()
|
||||||
|
cache_help.clear()
|
||||||
return {
|
return {
|
||||||
'status': 0,
|
'status': 0,
|
||||||
'msg': '插件信息设置成功'
|
'msg': '插件信息设置成功'
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from amis import Page, PageSchema, Html, Property, Service
|
from amis import Page, PageSchema, Html, Property, Service, Flex, ActionType, LevelEnum, Divider
|
||||||
from LittlePaimon import __version__
|
from LittlePaimon import __version__
|
||||||
|
|
||||||
logo = Html(html=f'''
|
logo = Html(html=f'''
|
||||||
@ -16,9 +16,23 @@ logo = Html(html=f'''
|
|||||||
target="_blank">文档</a>
|
target="_blank">文档</a>
|
||||||
</div>
|
</div>
|
||||||
<br>
|
<br>
|
||||||
<br>
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
|
operation_button = Flex(justify='center', items=[
|
||||||
|
ActionType.Ajax(
|
||||||
|
label='更新',
|
||||||
|
api='/LittlePaimon/api/bot_update',
|
||||||
|
confirmText='该操作将会对Bot进行检查并尝试更新,请在更新完成后重启Bot使更新生效',
|
||||||
|
level=LevelEnum.info
|
||||||
|
),
|
||||||
|
ActionType.Ajax(
|
||||||
|
label='重启',
|
||||||
|
api='/LittlePaimon/api/bot_restart',
|
||||||
|
confirmText='该操作将会使Bot重启,在完成重启之前,该页面也将无法访问(也可能会弹出报错,可无视),请耐心等待重启',
|
||||||
|
level=LevelEnum.danger
|
||||||
|
)
|
||||||
|
])
|
||||||
|
|
||||||
status = Service(
|
status = Service(
|
||||||
api='/LittlePaimon/api/status',
|
api='/LittlePaimon/api/status',
|
||||||
body=Property(
|
body=Property(
|
||||||
@ -86,5 +100,5 @@ status = Service(
|
|||||||
# page_detail = Page(title='主页',
|
# page_detail = Page(title='主页',
|
||||||
# initApi='/LittlePaimon/api/status',
|
# initApi='/LittlePaimon/api/status',
|
||||||
# body=[text, log_button])
|
# body=[text, log_button])
|
||||||
page_detail = Page(title='', body=[logo, status])
|
page_detail = Page(title='', body=[logo, operation_button, Divider(), status])
|
||||||
page = PageSchema(url='/home', label='首页', icon='fa fa-home', isDefaultPage=True, schema=page_detail)
|
page = PageSchema(url='/home', label='首页', icon='fa fa-home', isDefaultPage=True, schema=page_detail)
|
||||||
|
@ -18,25 +18,9 @@ from .config_manage import page as config_page
|
|||||||
# ]
|
# ]
|
||||||
# )
|
# )
|
||||||
|
|
||||||
action_button = DropDownButton(
|
|
||||||
label='操作',
|
|
||||||
trigger='hover',
|
|
||||||
buttons=[
|
|
||||||
ActionType.Ajax(
|
|
||||||
label='更新',
|
|
||||||
api='/LittlePaimon/api/bot_update',
|
|
||||||
confirmText='该操作将会对Bot进行检查并尝试更新,请在更新完成后重启Bot使更新生效',
|
|
||||||
),
|
|
||||||
ActionType.Ajax(
|
|
||||||
label='重启',
|
|
||||||
api='/LittlePaimon/api/bot_restart',
|
|
||||||
confirmText='该操作将会使Bot重启,在完成重启之前,该页面也将无法访问,请耐心等待重启',
|
|
||||||
)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
github_logo = Tpl(className='w-full',
|
github_logo = Tpl(className='w-full',
|
||||||
tpl='<div class="flex justify-between"><div></div><div><a href="https://github.com/CMHopeSunshine/LittlePaimon" target="_blank" title="Copyright"><i class="fa fa-github fa-2x"></i></a></div></div>')
|
tpl='<div class="flex justify-between"><div></div><div><a href="https://github.com/CMHopeSunshine/LittlePaimon" target="_blank" title="Copyright"><i class="fa fa-github fa-2x"></i></a></div></div>')
|
||||||
header = Flex(className='w-full', justify='flex-end', alignItems='flex-end', items=[action_button, github_logo])
|
header = Flex(className='w-full', justify='flex-end', alignItems='flex-end', items=[github_logo])
|
||||||
|
|
||||||
|
|
||||||
admin_app = App(brandName='LittlePaimon',
|
admin_app = App(brandName='LittlePaimon',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user