diff --git a/astrbot/dashboard/routes/plugin.py b/astrbot/dashboard/routes/plugin.py index 9f76e2a71..af2d897c2 100644 --- a/astrbot/dashboard/routes/plugin.py +++ b/astrbot/dashboard/routes/plugin.py @@ -102,7 +102,10 @@ class PluginRoute(Route): async def get_plugins(self): _plugin_resp = [] + plugin_name = request.args.get("name") for plugin in self.plugin_manager.context.get_all_stars(): + if plugin_name and plugin.name != plugin_name: + continue _t = { "name": plugin.name, "repo": "" if plugin.repo is None else plugin.repo, diff --git a/astrbot/dashboard/server.py b/astrbot/dashboard/server.py index a34606d31..1a54b8411 100644 --- a/astrbot/dashboard/server.py +++ b/astrbot/dashboard/server.py @@ -54,15 +54,24 @@ class AstrBotDashboard: self.conversation_route = ConversationRoute(self.context, db, core_lifecycle) self.file_route = FileRoute(self.context) - if self.core_lifecycle.star_context.registered_web_apis: - for api in self.core_lifecycle.star_context.registered_web_apis: - route, view_handler, methods, _ = api - self.app.add_url_rule( - f"/api/plug{route}", view_func=view_handler, methods=methods - ) + self.app.add_url_rule( + "/api/plug/", + view_func=self.srv_plug_route, + methods=["GET", "POST"], + ) self.shutdown_event = shutdown_event + async def srv_plug_route(self, subpath, *args, **kwargs): + """ + 插件路由 + """ + registered_web_apis = self.core_lifecycle.star_context.registered_web_apis + for api in registered_web_apis: + route, view_handler, methods, _ = api + if route == f"/{subpath}" and request.method in methods: + return await view_handler(*args, **kwargs) + async def auth_middleware(self): if not request.path.startswith("/api"): return