From e4363c573e55dca2e85a0f778ab36402cfe99a5c Mon Sep 17 00:00:00 2001 From: HibiKier <775757368@qq.com> Date: Wed, 16 Apr 2025 11:05:36 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E6=8F=92=E4=BB=B6=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E8=BF=87=E6=BB=A4=E7=88=B6=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zhenxun/models/plugin_info.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/zhenxun/models/plugin_info.py b/zhenxun/models/plugin_info.py index b6dfd2ce..a311a97f 100644 --- a/zhenxun/models/plugin_info.py +++ b/zhenxun/models/plugin_info.py @@ -60,27 +60,41 @@ class PluginInfo(Model): table_description = "插件基本信息" @classmethod - async def get_plugin(cls, load_status: bool = True, **kwargs) -> Self | None: + async def get_plugin( + cls, load_status: bool = True, filter_parent: bool = True, **kwargs + ) -> Self | None: """获取插件列表 参数: load_status: 加载状态. + filter_parent: 过滤父组件 返回: Self | None: 插件 """ + if filter_parent: + return await cls.get_or_none( + load_status=load_status, parent__isnull=True, **kwargs + ) return await cls.get_or_none(load_status=load_status, **kwargs) @classmethod - async def get_plugins(cls, load_status: bool = True, **kwargs) -> list[Self]: + async def get_plugins( + cls, load_status: bool = True, filter_parent: bool = True, **kwargs + ) -> list[Self]: """获取插件列表 参数: load_status: 加载状态. + filter_parent: 过滤父组件 返回: list[Self]: 插件列表 """ + if filter_parent: + return await cls.filter( + load_status=load_status, parent__isnull=True, **kwargs + ).all() return await cls.filter(load_status=load_status, **kwargs).all() @classmethod