Files
zhenxun_bot/zhenxun/ui/models/presets/plugin_menu.py
T
0f91ce03e4 ♻️ refactor(plugin_switch): 重构功能开关与帮助系统并优化 UI 报表渲染 (#2111)
* ♻️ refactor(plugin_switch): 重构功能开关与帮助系统并优化 UI 报表渲染

- 引入策略模式 (Strategy Pattern) 统一插件与被动任务的开关逻辑
- 新增超级用户强制管控功能,支持系统级禁用且群管无法自行开启
- 新增全服群组活跃状态报表与功能全局覆盖率可视化统计图表
- 优化指令解析系统,支持多功能批量开关及更智能的快捷词映射
- 重构帮助系统,支持在帮助页区分展示管理员与超级用户指令
- 细化插件列表状态显示,区分群控、系统管控与全局禁用状态
- UI 组件 UserInfoBlock 新增 extra 扩展插槽支持
- 更新 resources.spec 资源版本要求至 1.1.1

* 🚨 auto fix by pre-commit hooks

---------

Co-authored-by: webjoin111 <455457521@qq.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2026-03-19 16:08:13 +08:00

57 lines
1.4 KiB
Python

from pydantic import BaseModel, Field
from ..core.base import RenderableComponent
__all__ = [
"PluginMenuCategory",
"PluginMenuData",
"PluginMenuItem",
]
class PluginMenuItem(BaseModel):
"""插件菜单中的单个插件项"""
id: str
"""插件的唯一ID"""
name: str
"""插件名称"""
status: int
"""插件状态码: 0:开启, 1:群关, 2:系统关, 3:全局关"""
has_superuser_help: bool
"""插件是否有超级用户专属帮助"""
commands: list[str] = Field(default_factory=list, description="插件的主要命令列表")
"""插件的主要命令列表"""
class PluginMenuCategory(BaseModel):
"""插件菜单中的一个分类"""
name: str
"""插件分类名称"""
items: list[PluginMenuItem] = Field(..., description="该分类下的插件项列表")
"""该分类下的插件项列表"""
class PluginMenuData(RenderableComponent):
"""通用插件帮助菜单的数据模型"""
style_name: str | None = None
"""页面样式名称"""
bot_name: str
"""机器人名称"""
bot_avatar_url: str
"""机器人头像URL"""
is_detail: bool
"""是否为详细菜单模式"""
plugin_count: int
"""总插件数量"""
active_count: int
"""已启用插件数量"""
categories: list[PluginMenuCategory]
"""插件分类列表"""
@property
def template_name(self) -> str:
return "pages/core/plugin_menu"