mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-10 07:46:02 +00:00
feat: 插件优先级更改功能
This commit is contained in:
@@ -29,3 +29,9 @@ class PluginsRouterGroup(group.RouterGroup):
|
||||
target_enabled = data.get('target_enabled')
|
||||
await self.ap.plugin_mgr.update_plugin_status(plugin_name, target_enabled)
|
||||
return self.success()
|
||||
|
||||
@self.route('/reorder', methods=['PUT'])
|
||||
async def _() -> str:
|
||||
data = await quart.request.json
|
||||
await self.ap.plugin_mgr.reorder_plugins(data.get('plugins'))
|
||||
return self.success()
|
||||
|
||||
@@ -203,3 +203,18 @@ class PluginManager:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
async def reorder_plugins(self, plugins: list[dict]):
|
||||
|
||||
for plugin in plugins:
|
||||
plugin_name = plugin.get('name')
|
||||
plugin_priority = plugin.get('priority')
|
||||
|
||||
for plugin in self.plugins:
|
||||
if plugin.plugin_name == plugin_name:
|
||||
plugin.priority = plugin_priority
|
||||
break
|
||||
|
||||
self.plugins.sort(key=lambda x: x.priority, reverse=True)
|
||||
|
||||
await self.setting.dump_container_setting(self.plugins)
|
||||
|
||||
Reference in New Issue
Block a user