From 7ad62c7488acc9fbfa9f8ad891dfd2594f776b4b Mon Sep 17 00:00:00 2001 From: MengStack Dev Date: Sat, 3 Oct 2026 02:09:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=92=E4=BB=B6=E8=87=AA=E6=B3=A8?= =?UTF-8?q?=E5=86=8C=20=E2=80=94=20=E5=9C=A8=E6=9E=84=E9=80=A0=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E4=B8=AD=E6=B3=A8=E5=86=8C=E5=88=B0=E5=85=A8=E5=B1=80?= =?UTF-8?q?=20Registry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fx.Invoke 执行顺序不确定导致插件路由未注册,改为在 New() 中自注册 --- internal/app/app.go | 3 --- internal/modules/example/interfaces/plugin.go | 7 ++++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/internal/app/app.go b/internal/app/app.go index ee7720f..bd8fc74 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -132,9 +132,6 @@ func NewApp() *fx.App { settingsinterfaces.Module, notificationinterfaces.Module, exampleinterfaces.Module, - fx.Invoke(func(p *exampleinterfaces.ExamplePlugin) { - plugin.Register(p) - }), Module, ) } diff --git a/internal/modules/example/interfaces/plugin.go b/internal/modules/example/interfaces/plugin.go index dc1d1c4..6ca86d4 100644 --- a/internal/modules/example/interfaces/plugin.go +++ b/internal/modules/example/interfaces/plugin.go @@ -17,10 +17,11 @@ type ExamplePlugin struct { handler *Handler } -// New creates the example plugin. -// Call this during application bootstrap to register the plugin. +// New creates the example plugin and registers it in the global plugin registry. func New(handler *Handler) *ExamplePlugin { - return &ExamplePlugin{handler: handler} + p := &ExamplePlugin{handler: handler} + plugin.Register(p) + return p } func (p *ExamplePlugin) Metadata() plugin.Metadata {