Skip to content

Commit

Permalink
✨ 插件配置新增is_show控制是否显示在菜单中 (#1749)
Browse files Browse the repository at this point in the history
  • Loading branch information
HibiKier authored Nov 29, 2024
1 parent d00412e commit c7c759f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions zhenxun/builtin_plugins/help/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
author="HibiKier",
version="0.1",
plugin_type=PluginType.DEPENDANT,
is_show=False,
configs=[
RegisterConfig(
key="type",
Expand Down
1 change: 1 addition & 0 deletions zhenxun/builtin_plugins/help/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ async def sort_type() -> dict[str, list[PluginInfo]]:
menu_type__not="",
load_status=True,
plugin_type__in=[PluginType.NORMAL, PluginType.DEPENDANT],
is_show=True,
)
sort_data = {}
for plugin in data:
Expand Down
1 change: 1 addition & 0 deletions zhenxun/builtin_plugins/init/init_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ async def _():
"version",
"admin_level",
"plugin_type",
"is_show",
]
)
update_list.append(plugin)
Expand Down
2 changes: 2 additions & 0 deletions zhenxun/configs/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ class PluginExtraData(BaseModel):
"""额外名称"""
sql_list: list[str] | None = None
"""常用sql"""
is_show: bool = True
"""是否显示在菜单中"""


class NoSuchConfig(Exception):
Expand Down
3 changes: 3 additions & 0 deletions zhenxun/models/plugin_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class PluginInfo(Model):
"""是否删除"""
parent = fields.CharField(max_length=255, null=True, description="父插件")
"""父插件"""
is_show = fields.BooleanField(default=True, description="是否显示在帮助中")
"""是否显示在帮助中"""

class Meta: # type: ignore
table = "plugin_info"
Expand Down Expand Up @@ -81,4 +83,5 @@ async def get_plugins(cls, load_status: bool = True, **kwargs) -> list[Self]:
async def _run_script(cls):
return [
"ALTER TABLE plugin_info ADD COLUMN parent character varying(255);",
"ALTER TABLE plugin_info ADD COLUMN is_show boolean DEFAULT true;",
]

0 comments on commit c7c759f

Please sign in to comment.