mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2026-09-29 00:32:06 +08:00
* ♻️ refactor(ui): 重构 UI 渲染系统并优化资源管理 - 【重构】重构 `RendererService` 架构,解耦模板引擎、主题管理与截图引擎 - 【重构】重构 `ui` 模块,采用组件注册机制与数据模型驱动,移除旧版 `builders` - 【功能】新增 UI 热重载模式,支持在不重启的情况下实时预览 HTML/CSS 修改 - 【功能】增强启动项资源检查,支持基于 `resources.spec` 的版本校验与自动更新 - 【优化】统一内置插件的 UI 渲染逻辑,迁移至新的 `ui.table`、`ui.markdown` 等工厂接口 - 【优化】优化日志脱敏工具,支持自动折叠调试输出中冗长的样式标签 - 【优化】引入 `AssetResolutionService`,完善皮肤、组件、主题间的多级资源回退机制 - 【优化】新增组件生命周期钩子 `prepare`,支持渲染前的异步数据预处理 * 🚨 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>
71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
from typing import Literal
|
|
|
|
from pydantic import Field
|
|
|
|
from ...registry import component
|
|
from ..core.base import RenderableComponent
|
|
|
|
__all__ = ["Alert", "Badge", "ProgressBar"]
|
|
|
|
|
|
@component(name="alert", namespace="core")
|
|
class Alert(RenderableComponent):
|
|
"""一个带样式的提示框组件,用于显示重要信息。"""
|
|
|
|
component_type: Literal["alert"] = "alert"
|
|
"""组件类型"""
|
|
type: Literal["info", "success", "warning", "error"] = Field(
|
|
default="info", description="提示框的类型,决定了颜色和图标"
|
|
)
|
|
"""提示框的类型,决定了颜色和图标"""
|
|
title: str = Field(..., description="提示框的标题")
|
|
"""提示框的标题"""
|
|
content: str = Field(..., description="提示框的主要内容")
|
|
"""提示框的主要内容"""
|
|
show_icon: bool = Field(default=True, description="是否显示与类型匹配的图标")
|
|
"""是否显示与类型匹配的图标"""
|
|
|
|
@property
|
|
def template_name(self) -> str:
|
|
return "components/widgets/alert"
|
|
|
|
|
|
class Badge(RenderableComponent):
|
|
"""一个简单的徽章组件,用于显示状态或标签。"""
|
|
|
|
component_type: Literal["badge"] = "badge"
|
|
"""组件类型"""
|
|
text: str = Field(..., description="徽章上显示的文本")
|
|
"""徽章上显示的文本"""
|
|
color_scheme: Literal["primary", "success", "warning", "error", "info"] = Field(
|
|
default="info",
|
|
description="预设的颜色方案",
|
|
)
|
|
"""预设的颜色方案"""
|
|
|
|
@property
|
|
def template_name(self) -> str:
|
|
return "components/widgets/badge"
|
|
|
|
|
|
class ProgressBar(RenderableComponent):
|
|
"""一个进度条组件。"""
|
|
|
|
component_type: Literal["progress_bar"] = "progress_bar"
|
|
"""组件类型"""
|
|
progress: float = Field(..., ge=0, le=100, description="进度百分比 (0-100)")
|
|
"""进度百分比 (0-100)"""
|
|
label: str | None = Field(default=None, description="显示在进度条上的可选文本")
|
|
"""显示在进度条上的可选文本"""
|
|
color_scheme: Literal["primary", "success", "warning", "error", "info"] = Field(
|
|
default="primary",
|
|
description="预设的颜色方案",
|
|
)
|
|
"""预设的颜色方案"""
|
|
animated: bool = Field(default=False, description="是否显示动画效果")
|
|
"""是否显示动画效果"""
|
|
|
|
@property
|
|
def template_name(self) -> str:
|
|
return "components/widgets/progress_bar"
|