From b8bbd7228f815a670a659360199d52d804fcbf03 Mon Sep 17 00:00:00 2001 From: minecraft1024a Date: Fri, 5 Dec 2025 19:15:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(plugin):=20=E8=B0=83=E6=95=B4=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E8=B7=AF=E7=94=B1=E5=89=8D=E7=BC=80=E4=BB=A5=E9=81=BF?= =?UTF-8?q?=E5=85=8D=E7=BB=84=E4=BB=B6=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将插件组件的路由前缀从 `/plugins/{plugin_name}` 修改为 `/plugins/{plugin_name}/{component_name}`。 此项更改旨在解决单个插件注册多个路由组件时可能出现的路径冲突问题,确保每个组件都拥有唯一的 API 端点。 此外,为了支持新的前端开发环境,已将端口 11451 和 3001 添加到 CORS 允许源列表中。 BREAKING CHANGE: 插件 API 的 URL 结构已发生变更。所有对插件接口的调用都需要更新为新的 `/plugins/{plugin_name}/{component_name}` 格式。 --- src/common/server.py | 6 +++++- src/plugin_system/core/component_registry.py | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/server.py b/src/common/server.py index 15f5de16a..6feb72731 100644 --- a/src/common/server.py +++ b/src/common/server.py @@ -54,8 +54,12 @@ class Server: # 配置 CORS origins = [ - "http://localhost:3000", # 允许的前端源 + "http://localhost:3000", "http://127.0.0.1:3000", + "http://localhost:11451", + "http://127.0.0.1:11451", + "http://localhost:3001", + "http://127.0.0.1:3001", # 在生产环境中,您应该添加实际的前端域名 ] diff --git a/src/plugin_system/core/component_registry.py b/src/plugin_system/core/component_registry.py index 2218a4fb1..b6715515c 100644 --- a/src/plugin_system/core/component_registry.py +++ b/src/plugin_system/core/component_registry.py @@ -560,7 +560,7 @@ class ComponentRegistry: component_instance = router_class() server = get_global_server() # 生成唯一的 URL 前缀,格式为 /plugins/{plugin_name} - prefix = f"/plugins/{info.plugin_name}" + prefix = f"/plugins/{info.plugin_name}/{info.name}" # 将插件的路由包含到主应用中 server.app.include_router(component_instance.router, prefix=prefix, tags=[info.plugin_name])