♻️ refactor: 统一图片渲染架构并引入通用UI组件系统

🎨 **渲染服务重构**
- 统一图片渲染入口,引入主题系统支持
- 优化Jinja2环境管理,支持主题覆盖和插件命名空间
- 新增UI缓存机制和主题重载功能

✨ **通用UI组件系统**
- 新增 zhenxun.ui 模块,提供数据模型和构建器
- 引入BaseBuilder基类,支持链式调用
- 新增多种UI构建器:InfoCard, Markdown, Table, Chart, Layout等
- 新增通用组件:Divider, Badge, ProgressBar, UserInfoBlock

🔄 **插件迁移**
- 迁移9个内置插件至新渲染系统
- 移除各插件中分散的图片生成工具
- 优化数据处理和渲染逻辑

💥 **Breaking Changes**
- 移除旧的图片渲染接口和模板路径
- TEMPLATE_PATH 更名为 THEMES_PATH
- 插件需适配新的RendererService和zhenxun.ui模块
This commit is contained in:
webjoin111
2025-08-12 21:03:51 +08:00
parent 977f0b13b3
commit 689505294c
77 changed files with 3125 additions and 2116 deletions
+4 -3
View File
@@ -6,7 +6,7 @@ from pydantic import BaseModel
from tortoise.expressions import Q
from zhenxun.configs.config import BotConfig
from zhenxun.configs.path_config import TEMPLATE_PATH
from zhenxun.configs.path_config import THEMES_PATH
from zhenxun.models.goods_info import GoodsInfo
from zhenxun.utils._build_image import BuildImage
@@ -77,13 +77,14 @@ async def html_image() -> bytes:
GoodsItem(goods_list=value, partition=partition)
for partition, value in partition_dict.items()
]
template_dir = THEMES_PATH / "default" / "templates" / "shop"
return await template_to_pic(
template_path=str((TEMPLATE_PATH / "shop").absolute()),
template_path=str(template_dir.absolute()),
template_name="main.html",
templates={"name": BotConfig.self_nickname, "data_list": data_list},
pages={
"viewport": {"width": 850, "height": 1024},
"base_url": f"file://{TEMPLATE_PATH}",
"base_url": f"file://{THEMES_PATH.parent.absolute()}",
},
wait=2,
)