Files
abot/plugins/douyu/templates/daily_report.html
liuwei f719b10c4a 模板化改造斗鱼日报与群聊总结图片渲染,支持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. 保持原有业务流程与发送逻辑不变,仅改造渲染层,降低后续维护成本。
2026-04-20 13:23:54 +08:00

597 lines
16 KiB
HTML

<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
:root {
--bg-top: #f3efe5;
--bg-bottom: #e6edf5;
--paper: rgba(255, 252, 247, 0.97);
--text: #1f2937;
--muted: #6b7280;
--line: rgba(137, 148, 163, 0.18);
--navy: #14213d;
--blue: #2b59ff;
--cyan: #1fa8a0;
--gold: #c89b3c;
--gold-soft: rgba(200, 155, 60, 0.14);
--red-soft: rgba(210, 84, 61, 0.10);
--shadow: 0 26px 60px rgba(33, 52, 84, 0.14);
}
* { box-sizing: border-box; }
body {
margin: 0;
padding: 34px;
background:
radial-gradient(circle at 0% 0%, rgba(43, 89, 255, 0.08), transparent 24%),
radial-gradient(circle at 100% 0%, rgba(31, 168, 160, 0.10), transparent 20%),
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: 920px;
margin: 0 auto;
background: var(--paper);
border-radius: 34px;
overflow: visible;
box-shadow: var(--shadow);
border: 1px solid rgba(255,255,255,0.6);
}
.hero {
position: relative;
padding: 34px 40px 30px;
border-radius: 34px 34px 0 0;
background:
radial-gradient(circle at 18% 18%, rgba(255,255,255,0.12), transparent 18%),
radial-gradient(circle at 84% 14%, rgba(255,255,255,0.11), transparent 19%),
linear-gradient(135deg, #111827 0%, #1d4ed8 46%, #0f766e 100%);
color: #fff;
}
.hero::after {
content: "";
position: absolute;
right: -52px;
top: -40px;
width: 230px;
height: 230px;
border-radius: 50%;
border: 1px solid rgba(255,255,255,0.14);
box-shadow: 0 0 0 28px rgba(255,255,255,0.04), 0 0 0 60px rgba(255,255,255,0.02);
}
.eyebrow {
display: inline-block;
padding: 7px 14px;
border-radius: 999px;
background: rgba(255,255,255,0.12);
border: 1px solid rgba(255,255,255,0.18);
font-size: 12px;
letter-spacing: .08em;
}
.hero-title {
margin: 18px 0 10px;
font-size: 44px;
font-weight: 800;
line-height: 1.16;
letter-spacing: -0.03em;
}
.hero-subtitle {
color: rgba(240, 246, 255, 0.84);
font-size: 16px;
}
.content {
padding: 28px 30px 34px;
}
.metric-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 14px;
margin-top: -34px;
position: relative;
z-index: 2;
}
.metric-card {
background: rgba(255,255,255,0.9);
backdrop-filter: blur(8px);
border: 1px solid rgba(255,255,255,0.8);
border-radius: 22px;
padding: 18px 18px 16px;
box-shadow: 0 10px 24px rgba(17, 24, 39, 0.08);
}
.metric-label {
color: var(--muted);
font-size: 13px;
margin-bottom: 8px;
}
.metric-value {
font-size: 32px;
font-weight: 800;
color: var(--navy);
line-height: 1;
}
.metric-hint {
color: #8090a7;
font-size: 12px;
margin-top: 8px;
}
.section {
margin-top: 20px;
padding: 24px;
border-radius: 26px;
border: 1px solid var(--line);
background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(248,250,252,0.92));
}
.section.danmu {
background:
linear-gradient(180deg, rgba(255,255,255,0.95), rgba(247, 249, 255, 0.94));
}
.section.ops {
background:
linear-gradient(180deg, rgba(255,251,244,0.96), rgba(255,255,255,0.95));
}
.section-title {
display: flex;
align-items: center;
gap: 10px;
font-size: 27px;
font-weight: 800;
margin-bottom: 16px;
color: var(--navy);
}
.section-title .icon {
width: 14px;
height: 30px;
border-radius: 999px;
background: linear-gradient(180deg, var(--blue), var(--cyan));
box-shadow: 0 6px 16px rgba(43,89,255,0.24);
}
.section.ops .section-title .icon {
background: linear-gradient(180deg, #d6a547, #f59e0b);
box-shadow: 0 6px 16px rgba(200,155,60,0.24);
}
.summary-grid {
display: grid;
grid-template-columns: minmax(0, 1.6fr) minmax(255px, 0.78fr);
gap: 18px;
}
.prose p {
margin: 0 0 12px;
color: #334155;
font-size: 17px;
line-height: 1.84;
}
.lead-panel {
padding: 18px 18px 16px;
border-radius: 20px;
background: linear-gradient(180deg, rgba(242,246,255,0.92), rgba(255,255,255,0.96));
border: 1px solid rgba(125, 145, 186, 0.14);
margin-bottom: 14px;
}
.lead-title {
color: #5e6d87;
font-size: 13px;
letter-spacing: .06em;
margin-bottom: 10px;
}
.lead-text {
color: #24364c;
font-size: 18px;
line-height: 1.9;
font-weight: 500;
}
.insight-grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 12px;
}
.fans-panel {
margin-top: 14px;
padding: 14px 15px 12px;
border-radius: 18px;
background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(245,250,255,0.94));
border: 1px solid rgba(73, 136, 224, 0.18);
}
.fans-title {
color: #1d4ed8;
font-size: 13px;
letter-spacing: .06em;
font-weight: 700;
margin-bottom: 8px;
}
.fans-list {
margin: 0;
padding-left: 18px;
}
.fans-list li {
color: #1e3a5f;
margin: 8px 0;
line-height: 1.65;
font-size: 14px;
}
.insight-card {
padding: 15px 16px;
border-radius: 18px;
background: rgba(255,255,255,0.9);
border: 1px solid rgba(125, 145, 186, 0.14);
min-height: 110px;
}
.insight-card.full-span {
grid-column: 1 / -1;
}
.insight-kicker {
color: #2b59ff;
font-size: 12px;
letter-spacing: .08em;
font-weight: 700;
margin-bottom: 8px;
}
.insight-text {
color: #334155;
font-size: 15px;
line-height: 1.76;
}
.bullet-list {
margin: 0;
padding-left: 22px;
}
.bullet-list li {
color: #334155;
margin: 10px 0;
line-height: 1.72;
font-size: 16px;
}
.aside-card {
padding: 18px;
border-radius: 20px;
background: rgba(245, 248, 255, 0.86);
border: 1px solid rgba(125, 145, 186, 0.16);
}
.aside-card.warm {
background: rgba(255, 248, 234, 0.82);
border: 1px solid rgba(200, 155, 60, 0.18);
}
.aside-title {
font-size: 14px;
letter-spacing: .06em;
color: #68758a;
margin-bottom: 12px;
}
.badge-wall {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 10px;
}
.badge-chip {
padding: 10px 12px;
border-radius: 16px;
background: linear-gradient(180deg, rgba(255,255,255,0.92), rgba(242,246,255,0.92));
border: 1px solid rgba(129, 147, 181, 0.16);
min-width: 0;
}
.badge-name {
display: block;
font-weight: 700;
color: var(--navy);
margin-bottom: 4px;
}
.badge-meta {
display: block;
font-size: 12px;
color: #6b7280;
}
.active-user-grid {
display: grid;
grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 10px;
}
.active-user-card {
padding: 12px 12px 11px;
border-radius: 16px;
background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(244,247,255,0.92));
border: 1px solid rgba(129,147,181,0.18);
box-shadow: 0 10px 24px rgba(25, 38, 66, 0.05);
}
.active-user-top {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 8px;
margin-bottom: 8px;
}
.active-user-name {
font-size: 14px;
font-weight: 700;
color: var(--navy);
line-height: 1.3;
word-break: break-all;
}
.active-user-count {
flex-shrink: 0;
min-width: 44px;
text-align: right;
font-size: 19px;
font-weight: 800;
color: var(--blue);
line-height: 1;
}
.active-user-count span {
margin-left: 2px;
font-size: 11px;
font-weight: 600;
color: #64748b;
}
.active-user-meta {
display: flex;
flex-wrap: wrap;
gap: 6px;
}
.user-chip {
display: inline-flex;
align-items: center;
padding: 4px 8px;
border-radius: 999px;
font-size: 11px;
line-height: 1;
border: 1px solid transparent;
}
.user-chip.fans {
color: #9a6700;
background: rgba(250, 204, 21, 0.14);
border-color: rgba(234, 179, 8, 0.24);
}
.user-chip.room {
color: #1d4ed8;
background: rgba(59, 130, 246, 0.12);
border-color: rgba(59, 130, 246, 0.18);
}
.user-chip.plain {
color: #64748b;
background: rgba(148, 163, 184, 0.12);
border-color: rgba(148, 163, 184, 0.16);
}
.hot-grid {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 12px;
margin-top: 16px;
}
.hot-card {
padding: 16px;
border-radius: 18px;
background: linear-gradient(180deg, rgba(255,255,255,0.94), rgba(241,246,255,0.92));
border: 1px solid rgba(129,147,181,0.16);
}
.hot-time {
font-size: 22px;
font-weight: 800;
color: var(--blue);
margin-bottom: 6px;
}
.hot-count {
font-size: 14px;
color: #334155;
margin-bottom: 8px;
}
.hot-terms {
font-size: 13px;
color: #64748b;
line-height: 1.56;
}
.footer-note {
margin-top: 20px;
text-align: right;
color: #7b8798;
font-size: 12px;
letter-spacing: .04em;
}
.chart-wrap {
padding: 18px 18px 14px;
border-radius: 22px;
background: linear-gradient(180deg, rgba(244,247,255,0.96), rgba(255,255,255,0.96));
border: 1px solid rgba(129,147,181,0.16);
}
.chart-head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 12px;
margin-bottom: 10px;
}
.chart-note {
margin: -2px 0 8px;
color: #7b8798;
font-size: 12px;
line-height: 1.5;
}
.chart-title {
font-size: 17px;
font-weight: 800;
color: var(--navy);
}
.chart-legend {
display: flex;
align-items: center;
gap: 14px;
flex-wrap: wrap;
color: #64748b;
font-size: 12px;
}
.legend-item {
display: inline-flex;
align-items: center;
gap: 6px;
}
.legend-swatch {
width: 18px;
height: 8px;
border-radius: 999px;
display: inline-block;
}
.legend-swatch.vip {
background: linear-gradient(90deg, #2b59ff, #7aa2ff);
}
.legend-swatch.diamond {
background: linear-gradient(90deg, #f59e0b, #ffd166);
}
.legend-meta {
color: #475569;
font-weight: 600;
}
.audience-chart {
width: 100%;
height: auto;
display: block;
}
.chart-bg {
fill: rgba(255,255,255,0.72);
}
.chart-grid {
stroke: rgba(148, 163, 184, 0.20);
stroke-width: 1;
stroke-dasharray: 4 6;
}
.chart-axis {
stroke: rgba(71, 85, 105, 0.38);
stroke-width: 1.2;
}
.chart-axis.soft {
stroke: rgba(148, 163, 184, 0.28);
}
.axis-label {
font-size: 11px;
font-weight: 600;
}
.axis-left {
fill: #3557c8;
}
.axis-right {
fill: #b26a00;
}
.vip-bar {
fill: url(#vipBarGradient);
}
.diamond-line {
fill: none;
stroke: url(#diamondLineGradient);
stroke-width: 3;
stroke-linecap: round;
stroke-linejoin: round;
}
.diamond-dot {
fill: #ffcc66;
stroke: #ffffff;
stroke-width: 1.4;
}
.value-label {
font-size: 11px;
font-weight: 700;
}
.value-label.vip {
fill: #2449ad;
}
.value-label.vip.soft {
fill: #5573c7;
}
.value-label.diamond {
fill: #b26a00;
}
.value-sub-label {
font-size: 10px;
font-weight: 700;
}
.value-sub-label.vip {
fill: #5f7bd0;
}
.value-sub-label.vip.soft {
fill: #7d94d8;
}
.value-sub-label.diamond {
fill: #c27c16;
}
.time-label {
fill: #64748b;
font-size: 11px;
font-weight: 600;
}
.chart-empty {
padding: 26px 24px;
border-radius: 22px;
background: linear-gradient(180deg, rgba(244,247,255,0.96), rgba(255,255,255,0.96));
border: 1px solid rgba(129,147,181,0.16);
}
.chart-empty-title {
font-size: 17px;
font-weight: 800;
color: var(--navy);
margin-bottom: 8px;
}
.chart-empty-desc {
color: #64748b;
font-size: 14px;
line-height: 1.7;
}
@media (max-width: 900px) {
.active-user-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
}
@media (max-width: 640px) {
.active-user-grid {
grid-template-columns: 1fr;
}
}
</style>
</head>
<body>
<div class="sheet">
<div class="hero">
<div class="eyebrow">DOUYU DAILY REPORT</div>
<div class="hero-title">{{ title_name }}</div>
<div class="hero-subtitle">{{ subtitle }}</div>
</div>
<div class="content">
<div class="metric-grid">{{ metrics_html }}</div>
<div class="section danmu">
<div class="section-title"><span class="icon"></span><span>弹幕总结</span></div>
<div class="summary-grid">
<div class="prose">
<div class="lead-panel">
<div class="lead-title">整体观察</div>
<div class="lead-text">{{ lead_summary }}</div>
</div>
<div class="insight-grid">{{ danmu_insights_html }}</div>
<div class="fans-panel">
<div class="fans-title">给粉丝看的弹幕萃取</div>
{{ fans_extract_html }}
</div>
</div>
<div class="aside-card">
<div class="aside-title">高频梗</div>
{{ template_items_html }}
</div>
</div>
<div class="hot-grid">{{ hot_times_html }}</div>
</div>
<div class="section ops">
<div class="section-title"><span class="icon"></span><span>运营数据总结</span></div>
<div style="margin-top: 2px; margin-bottom: 16px;">{{ audience_trend_html }}</div>
<div class="summary-grid">
<div class="prose">{{ operator_summary_html }}</div>
<div class="aside-card warm">
<div class="aside-title">活跃牌子</div>
<div class="badge-wall">{{ badges_html }}</div>
</div>
</div>
<div class="aside-card" style="margin-top: 16px;">
<div class="aside-title">核心发言用户</div>
<div class="active-user-grid">{{ active_users_html }}</div>
</div>
</div>
<div class="footer-note">ABOT · Douyu Report Template</div>
</div>
</div>
</body>
</html>