模板化改造斗鱼日报与群聊总结图片渲染,支持HTML模板独立维护
变更项:\n1. 将 plugins/douyu/report_template.py 从内联HTML重构为模板渲染,新增 plugins/douyu/templates/daily_report.html 承载完整样式与结构,Python侧仅保留数据组装与安全注入。\n2. 修复斗鱼日报模板迁移后的样式缺失问题,补齐 metric-card、insight-card、badge-wall、active-user-grid、chart 等所有关键类样式,确保视觉与旧版一致。\n3. 在 plugins/message_summary/main.py 新增模板化图片渲染链路:优先使用 HtmlTemplateRenderer + html_to_image 生成总结图片,模板异常时自动回退 convert_md_str_to_image,保证稳定性。\n4. 新增 plugins/message_summary/templates/summary_card.html 作为群聊总结卡片模板,后续可仅改模板文件完成UI迭代。\n5. 扩展 plugins/message_summary/config.toml 输出配置,增加 summary_image_mode 与 summary_image_template_path,支持模板模式与回退模式按配置切换。\n6. 保持原有业务流程与发送逻辑不变,仅改造渲染层,降低后续维护成本。
This commit is contained in:
118
plugins/message_summary/templates/summary_card.html
Normal file
118
plugins/message_summary/templates/summary_card.html
Normal file
@@ -0,0 +1,118 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
:root {
|
||||
--bg-top: #eef3fb;
|
||||
--bg-bottom: #e5edf7;
|
||||
--card: rgba(255, 255, 255, 0.96);
|
||||
--title: #0f172a;
|
||||
--text: #334155;
|
||||
--muted: #64748b;
|
||||
--line: rgba(148, 163, 184, 0.22);
|
||||
--blue: #2563eb;
|
||||
--cyan: #0f766e;
|
||||
--shadow: 0 20px 48px rgba(15, 23, 42, 0.12);
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 26px;
|
||||
background:
|
||||
radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.12), transparent 30%),
|
||||
radial-gradient(circle at 90% 0%, rgba(15, 118, 110, 0.12), transparent 26%),
|
||||
linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
|
||||
font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
|
||||
color: var(--text);
|
||||
}
|
||||
.sheet {
|
||||
width: 820px;
|
||||
margin: 0 auto;
|
||||
background: var(--card);
|
||||
border-radius: 24px;
|
||||
border: 1px solid rgba(255, 255, 255, 0.7);
|
||||
box-shadow: var(--shadow);
|
||||
overflow: hidden;
|
||||
}
|
||||
.hero {
|
||||
padding: 24px 28px 20px;
|
||||
background:
|
||||
radial-gradient(circle at 18% 18%, rgba(255,255,255,0.12), transparent 18%),
|
||||
linear-gradient(135deg, #111827 0%, #1d4ed8 52%, #0f766e 100%);
|
||||
color: #ffffff;
|
||||
}
|
||||
.hero-badge {
|
||||
display: inline-block;
|
||||
padding: 6px 12px;
|
||||
border-radius: 999px;
|
||||
font-size: 12px;
|
||||
letter-spacing: .05em;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
border: 1px solid rgba(255, 255, 255, 0.2);
|
||||
}
|
||||
.hero-title {
|
||||
margin: 14px 0 8px;
|
||||
font-size: 30px;
|
||||
font-weight: 800;
|
||||
line-height: 1.25;
|
||||
}
|
||||
.hero-time {
|
||||
font-size: 13px;
|
||||
color: rgba(240, 246, 255, 0.86);
|
||||
}
|
||||
.content {
|
||||
padding: 24px 26px 26px;
|
||||
}
|
||||
h2 {
|
||||
margin: 20px 0 10px;
|
||||
font-size: 20px;
|
||||
font-weight: 800;
|
||||
color: var(--title);
|
||||
}
|
||||
h3 {
|
||||
margin: 14px 0 8px;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
color: #1e293b;
|
||||
}
|
||||
p {
|
||||
margin: 8px 0;
|
||||
font-size: 15px;
|
||||
line-height: 1.78;
|
||||
color: var(--text);
|
||||
}
|
||||
ul {
|
||||
margin: 8px 0 12px;
|
||||
padding-left: 22px;
|
||||
}
|
||||
li {
|
||||
margin: 6px 0;
|
||||
line-height: 1.72;
|
||||
font-size: 14px;
|
||||
color: var(--text);
|
||||
}
|
||||
.footer {
|
||||
margin-top: 20px;
|
||||
padding-top: 12px;
|
||||
border-top: 1px dashed var(--line);
|
||||
text-align: right;
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="sheet">
|
||||
<div class="hero">
|
||||
<div class="hero-badge">群聊总结</div>
|
||||
<div class="hero-title">{{ title }}</div>
|
||||
<div class="hero-time">生成时间:{{ generated_at }}</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
{{ summary_html }}
|
||||
<div class="footer">ABOT · Message Summary Template</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user