收敛summary模板渲染并对齐gemini-code版式

- main.py 新增模板命名模块提取:Shared Resources/Marketplace/Unresolved/Core Points/Top Contributors\n- 新增贡献者昵称抽取与文本长度控制,提升模板数据稳定性\n- gemini_summary_card.html 重构为接近 gemini-code 的模块顺序与样式语言\n- 恢复 Key Discussions -> Resources -> Marketplace/Unresolved -> Core Points -> Contributors 的版式节奏\n- 保持模板为纯展示层,使用 main.py 结构化数据喂给模板,减少样式与内容错位
This commit is contained in:
liuwei
2026-04-23 10:49:17 +08:00
parent 56aa532aa1
commit 9072e7d60b
2 changed files with 510 additions and 368 deletions

View File

@@ -5,478 +5,501 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }}</title>
<style>
/* 说明:由后端动态注入本地字体 @font-facefonts 目录),避免外网字体依赖。 */
{{ local_font_css }}
:root {
--bg: #f8fafc;
--surface: #ffffff;
--line: #eef2f7;
--text: #334155;
--text-soft: #64748b;
--text-faint: #94a3b8;
--title: #0f172a;
--brand: #2563eb;
--brand-soft: #dbeafe;
--ok-soft: #f0fdf4;
--ok-line: #22c55e;
--quote-bg: #f8fafc;
--quote-line: #cbd5e1;
--code-bg: #0f172a;
--code-text: #e2e8f0;
--shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.08);
--slate-50: #f8fafc;
--slate-100: #f1f5f9;
--slate-200: #e2e8f0;
--slate-300: #cbd5e1;
--slate-400: #94a3b8;
--slate-500: #64748b;
--slate-600: #475569;
--slate-700: #334155;
--slate-900: #0f172a;
--blue-50: #eff6ff;
--blue-100: #dbeafe;
--blue-600: #2563eb;
--indigo-50: #eef2ff;
--indigo-600: #4f46e5;
--emerald-50: #ecfdf5;
--emerald-100: #d1fae5;
--emerald-600: #059669;
--emerald-800: #065f46;
--shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}
* { box-sizing: border-box; }
body {
margin: 0;
/* 说明:减少上下留白,避免截图后出现“背景很大、内容很小”的视觉问题。 */
padding: 10px 0 12px;
background: var(--bg);
color: var(--text);
/* 说明:优先使用本地字体变量,未命中时回退系统字体。 */
font-family: var(--abot-font-sans, "PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif);
padding: 22px 0;
background-color: var(--slate-50);
color: var(--slate-700);
font-family: var(--abot-font-sans, 'Inter', 'PingFang SC', -apple-system, sans-serif);
-webkit-font-smoothing: antialiased;
}
.report-container {
/* 说明:使用与截图视口更匹配的宽度,显著提升内容占比。 */
width: min(720px, calc(100vw - 20px));
width: min(720px, calc(100vw - 14px));
margin: 0 auto;
background: var(--surface);
background: #ffffff;
box-shadow: var(--shadow);
border: 1px solid #e2e8f0;
border: 1px solid var(--slate-200);
}
.label-tiny {
font-size: 9px;
font-weight: 800;
text-transform: uppercase;
letter-spacing: .08em;
color: var(--text-faint);
color: var(--slate-400);
margin-bottom: 2px;
display: block;
}
.mono { font-family: var(--abot-font-code, 'JetBrains Mono', monospace); }
.header {
/* 说明:同步放大内边距与字号节奏,避免在更宽卡片里内容显得过小。 */
padding: 20px 20px 16px;
border-bottom: 1px solid var(--line);
padding: 20px;
border-bottom: 1px solid var(--slate-100);
}
.header-row {
display: flex;
justify-content: space-between;
align-items: flex-start;
margin-bottom: 12px;
gap: 10px;
margin-bottom: 13px;
}
.header-title {
margin: 0;
font-size: 16px;
font-weight: 900;
color: var(--title);
letter-spacing: -.02em;
line-height: 1.35;
}
.header-title .accent {
color: var(--brand);
font-weight: 600;
letter-spacing: -0.02em;
color: var(--slate-900);
}
.header-title .accent { color: var(--blue-600); font-weight: 600; }
.header-id {
margin-top: 4px;
font-size: 11px;
color: var(--text-faint);
margin: 4px 0 0;
font-size: 10px;
color: var(--slate-400);
font-weight: 600;
letter-spacing: .03em;
}
.header-tag {
padding: 5px 9px;
background: #f1f5f9;
padding: 4px 8px;
background: var(--slate-100);
border-radius: 4px;
font-size: 10px;
font-weight: 800;
color: #64748b;
font-size: 9px;
font-weight: 700;
color: var(--slate-500);
text-transform: uppercase;
white-space: nowrap;
border: 1px solid #e2e8f0;
}
.meta-grid {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
gap: 8px;
text-align: center;
}
.meta-item {
background: #f8fafc;
border: 1px solid #f1f5f9;
background: var(--slate-50);
border-radius: 4px;
padding: 9px 5px 7px;
padding: 8px 6px;
}
.meta-value {
font-size: 12px;
font-weight: 800;
color: #475569;
color: var(--slate-700);
}
.meta-value.brand {
color: var(--brand);
.meta-value.is-blue { color: var(--blue-600); }
.meta-value.is-indigo { color: var(--indigo-600); }
.meta-value.is-emerald { color: var(--emerald-600); }
.radar {
padding: 0 20px 16px;
border-bottom: 1px solid var(--slate-100);
}
.topic-radar {
margin-top: 12px;
}
.topic-tags {
margin-top: 6px;
.radar-tags {
margin-top: 8px;
display: flex;
flex-wrap: wrap;
gap: 6px;
gap: 8px;
}
.topic-tag {
padding: 3px 8px;
border-radius: 999px;
.radar-tag {
font-size: 10px;
padding: 2px 8px;
border-radius: 6px;
font-weight: 700;
color: #334155;
background: #f8fafc;
border: 1px solid #e2e8f0;
border: 1px solid transparent;
}
.summary-body {
padding: 18px 20px 20px;
.radar-tag.tone-blue { background: var(--blue-50); color: var(--blue-600); border-color: var(--blue-100); font-style: italic; }
.radar-tag.tone-indigo { background: var(--indigo-50); color: var(--indigo-600); border-color: #dbeafe; font-style: italic; }
.radar-tag.tone-emerald { background: var(--emerald-50); color: var(--emerald-600); border-color: var(--emerald-100); font-style: italic; }
.radar-tag.tone-slate { background: var(--slate-100); color: var(--slate-500); }
.content { padding: 20px; }
.lead {
margin: 0 0 14px;
background-color: #f0fdf4;
border-left: 2px solid #22c55e;
padding: 8px;
border-radius: 0 4px 4px 0;
font-size: 11px;
color: var(--emerald-800);
line-height: 1.7;
font-weight: 700;
}
.lead-callout {
margin-top: 10px;
padding: 10px 12px;
background: var(--ok-soft);
border-left: 2px solid var(--ok-line);
border-radius: 0 6px 6px 0;
font-size: 13px;
line-height: 1.78;
color: #166534;
}
.topics {
margin-top: 12px;
.topic-list {
display: flex;
flex-direction: column;
gap: 10px;
gap: 14px;
}
.topic-card {
border: 1px solid #e5eaf1;
background: #ffffff;
border: 1px solid var(--slate-200);
border-radius: 8px;
padding: 10px 11px;
padding: 10px;
background: #fff;
}
.topic-title-row {
display: flex;
align-items: center;
gap: 8px;
margin-bottom: 8px;
}
.topic-title {
margin: 0 0 8px;
font-size: 14px;
margin: 0;
font-size: 12px;
font-weight: 800;
color: var(--title);
letter-spacing: -.01em;
color: var(--slate-900);
}
.topic-divider {
height: 1px;
flex: 1;
background: var(--slate-100);
}
.topic-meta {
margin: 0 0 8px;
padding: 8px 9px;
border-radius: 6px;
background: #f8fafc;
border: 1px dashed #dbe4f2;
padding: 8px;
border-radius: 4px;
background: var(--slate-50);
border: 1px dashed var(--slate-200);
font-size: 11px;
line-height: 1.65;
color: #5b6b84;
color: var(--slate-600);
line-height: 1.6;
}
.topic-block {
display: flex;
flex-direction: column;
gap: 6px;
}
.topic-subtitle {
.topic-block { margin-bottom: 8px; }
.topic-block:last-child { margin-bottom: 0; }
.topic-text {
margin: 0;
font-size: 10px;
text-transform: uppercase;
letter-spacing: .08em;
color: #94a3b8;
font-weight: 800;
font-size: 11px;
color: var(--slate-600);
line-height: 1.7;
}
.item-paragraph {
margin: 0;
font-size: 13px;
line-height: 1.82;
color: var(--text);
}
.item-bullet {
.topic-bullets {
margin: 0;
padding-left: 14px;
position: relative;
font-size: 13px;
line-height: 1.78;
color: var(--text);
}
.item-bullet::before {
content: "•";
position: absolute;
left: 0;
top: 0;
color: var(--brand);
font-weight: 900;
}
.item-quote {
margin: 0;
padding: 8px 10px;
border-left: 3px solid var(--quote-line);
background: var(--quote-bg);
color: #475569;
border-radius: 0 4px 4px 0;
font-size: 12px;
line-height: 1.75;
}
.item-code {
margin: 0;
padding: 10px 11px;
border-radius: 6px;
background: var(--code-bg);
color: var(--code-text);
border: 1px solid #1e293b;
/* 说明:代码字体优先使用本地/系统等宽字体栈,保证服务端离线场景可读。 */
font-family: var(--abot-font-code, "Cascadia Mono", "Consolas", "SFMono-Regular", Menlo, monospace);
font-size: 12px;
line-height: 1.7;
white-space: pre-wrap;
word-break: break-word;
}
.summary-footer {
margin-top: 14px;
padding-top: 10px;
border-top: 1px dashed #e2e8f0;
font-size: 10px;
color: var(--text-faint);
display: flex;
justify-content: space-between;
align-items: center;
gap: 10px;
}
.summary-footer .right {
font-size: 9px;
color: #94a3b8;
letter-spacing: .04em;
text-transform: uppercase;
white-space: nowrap;
}
.safe-callout {
margin-top: 10px;
padding: 8px 10px;
background: var(--ok-soft);
border-left: 2px solid var(--ok-line);
border-radius: 0 4px 4px 0;
font-size: 12px;
color: #166534;
}
.fallback-text {
margin-top: 10px;
font-size: 12px;
line-height: 1.76;
color: #475569;
white-space: pre-wrap;
}
.summary-grid {
display: grid;
grid-template-columns: 1.45fr 1fr;
gap: 10px;
margin-top: 12px;
}
.aux-sections {
margin-top: 12px;
display: flex;
flex-direction: column;
gap: 8px;
}
.aux-card {
border: 1px solid #e8edf5;
border-radius: 7px;
padding: 9px 10px;
background: #fff;
}
.aux-title {
margin: 0 0 6px;
font-size: 12px;
font-weight: 800;
color: #334155;
}
.aux-item {
margin: 0;
font-size: 12px;
color: var(--slate-600);
font-size: 11px;
line-height: 1.68;
color: #475569;
}
.mini-card {
border: 1px solid #e5eaf1;
border-radius: 8px;
padding: 10px 11px;
background: #fff;
.topic-bullets li { margin: 2px 0; }
.conclusion-area {
background-color: #f0fdf4;
border-left: 2px solid #22c55e;
padding: 8px;
border-radius: 0 4px 4px 0;
}
.mini-title {
margin: 0 0 8px;
font-size: 10px;
text-transform: uppercase;
letter-spacing: .08em;
color: #94a3b8;
font-weight: 800;
.conclusion-text {
margin: 0;
font-size: 11px;
font-weight: 700;
color: var(--emerald-800);
line-height: 1.6;
font-style: italic;
}
.mini-list {
display: flex;
flex-direction: column;
gap: 5px;
.resource-wrap {
margin-top: 14px;
padding: 14px 0;
border-top: 1px solid var(--slate-100);
border-bottom: 1px solid var(--slate-100);
background: rgba(248,250,252,0.5);
}
.mini-row {
display: flex;
justify-content: space-between;
align-items: center;
gap: 8px;
font-size: 12px;
color: #475569;
}
.mini-row .value {
font-weight: 800;
color: #1e293b;
font-family: var(--abot-font-code, "Cascadia Mono", "Consolas", monospace);
}
.highlight-list {
.resource-list {
display: flex;
flex-direction: column;
gap: 6px;
padding: 0 10px;
}
.highlight-item {
margin: 0;
font-size: 12px;
line-height: 1.72;
color: #334155;
padding-left: 12px;
position: relative;
.resource-item {
border: 1px solid var(--slate-100);
border-radius: 4px;
padding: 7px 8px;
font-size: 10px;
color: var(--slate-600);
line-height: 1.6;
background: #fff;
}
.highlight-item::before {
content: "";
position: absolute;
left: 0;
top: 7px;
width: 5px;
height: 5px;
.market-grid {
margin-top: 14px;
display: grid;
grid-template-columns: repeat(2, minmax(0,1fr));
gap: 12px;
}
.market-card {
border: 1px solid var(--slate-100);
border-radius: 6px;
padding: 8px;
background: #fff;
}
.market-item {
margin: 0 0 6px;
font-size: 10px;
color: var(--slate-600);
line-height: 1.6;
}
.market-item:last-child { margin-bottom: 0; }
.core-wrap { margin-top: 14px; }
.core-card {
border-radius: 6px;
background: #0f172a;
color: #e2e8f0;
padding: 10px;
border: 1px solid #1e293b;
}
.core-item {
margin: 0 0 6px;
font-size: 10px;
line-height: 1.65;
color: #cbd5e1;
}
.core-item:last-child { margin-bottom: 0; }
.footer-main {
margin-top: 14px;
padding: 12px 10px;
background: var(--slate-50);
border-top: 1px solid var(--slate-100);
display: flex;
justify-content: space-between;
align-items: center;
gap: 12px;
}
.avatar-list { display: flex; margin-left: auto; }
.avatar {
width: 24px;
height: 24px;
border-radius: 50%;
background: #2563eb;
border: 2px solid #fff;
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 9px;
font-weight: 700;
margin-left: -6px;
}
@media (max-width: 640px) {
.summary-grid {
grid-template-columns: 1fr;
}
.meta-grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.avatar:nth-child(1) { background: var(--blue-100); color: var(--blue-600); }
.avatar:nth-child(2) { background: #e0e7ff; color: var(--indigo-600); }
.avatar:nth-child(3) { background: #e2e8f0; color: var(--slate-500); }
.footer-note {
text-align: center;
margin-top: 10px;
font-size: 9px;
color: var(--slate-400);
letter-spacing: .03em;
text-transform: uppercase;
}
@media (max-width: 760px) {
.meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.market-grid { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<div class="report-container">
<header class="header">
<div class="header-row">
<div>
<div class="header-title">CHAT INSIGHTS <span class="accent">SUMMARY</span></div>
<div class="header-id">{{ generated_at }}</div>
</div>
<div class="header-tag">{{ summary_metrics.activity_badge or "Daily Archive" }}</div>
<div class="report-container">
<header class="header">
<div class="header-row">
<div>
<h1 class="header-title">CHAT INSIGHTS <span class="accent">REPORT</span></h1>
<p class="header-id mono">ID: {{ generated_at }}</p>
</div>
<div class="meta-grid">
{% for card in summary_metrics.kpi_cards %}
<div class="meta-item">
<span class="label-tiny">{{ card.label }}</span>
<div class="meta-value {% if card.tone == 'blue' %}brand{% endif %}">{{ card.value }}</div>
</div>
{% endfor %}
</div>
<div class="topic-radar">
<span class="label-tiny"># Personal Interest Radar</span>
<div class="topic-tags">
{% for tag in summary_metrics.topic_tags %}
<span class="topic-tag">{{ tag }}</span>
{% endfor %}
{% if not summary_metrics.topic_tags %}
<span class="topic-tag">暂无热点标签</span>
{% endif %}
</div>
</div>
</header>
<div class="header-tag">{{ summary_metrics.activity_badge or "Daily Archive" }}</div>
</div>
<section class="summary-body">
<span class="label-tiny"># {{ summary_doc_title or title }}</span>
<div class="lead-callout">
{{ summary_lead or "暂无总结内容。" }}
<div class="meta-grid">
{% for card in summary_metrics.kpi_cards|default([]) %}
<div class="meta-item">
<span class="label-tiny">{{ card.label }}</span>
<span class="meta-value {% if card.tone == 'blue' %}is-blue{% elif card.tone == 'violet' %}is-indigo{% elif card.tone == 'emerald' %}is-emerald{% endif %}">{{ card.value }}</span>
</div>
<div class="topics">
{% for topic in summary_topics %}
<article class="topic-card">
<h3 class="topic-title">{{ loop.index }}. {{ topic["title"] }}</h3>
<div class="topic-meta">
{% if topic["time_range"] %}<div>🕒 {{ topic["time_range"] }}</div>{% endif %}
{% if topic["participants"] %}<div>👥 {{ topic["participants"] }}</div>{% endif %}
</div>
{% if topic["overview_points"] %}
<div class="topic-block">
<p class="topic-subtitle">核心观点</p>
{% endfor %}
</div>
</header>
<section class="radar">
<span class="label-tiny"># Personal Interest Radar</span>
<div class="radar-tags">
{% for tag in summary_metrics.topic_tags|default([]) %}
<span class="radar-tag {% if loop.index0 % 4 == 0 %}tone-blue{% elif loop.index0 % 4 == 1 %}tone-indigo{% elif loop.index0 % 4 == 2 %}tone-emerald{% else %}tone-slate{% endif %}">{{ tag }}</span>
{% endfor %}
{% if not (summary_metrics.topic_tags|default([])) %}
<span class="radar-tag tone-slate">暂无热点标签</span>
{% endif %}
</div>
</section>
<section class="content">
<span class="label-tiny"># {{ summary_doc_title or title }}</span>
<p class="lead">{{ summary_lead or "暂无总结内容。" }}</p>
<span class="label-tiny"># Key Discussions</span>
<div class="topic-list">
{% for topic in summary_topics|default([]) %}
<article class="topic-card">
<div class="topic-title-row">
<h3 class="topic-title">{{ "%02d"|format(loop.index) }}. {{ topic["title"] }}</h3>
<div class="topic-divider"></div>
</div>
{% if topic["time_range"] or topic["participants"] %}
<div class="topic-meta">
{% if topic["time_range"] %}<div>时段:{{ topic["time_range"] }}</div>{% endif %}
{% if topic["participants"] %}<div>参与人数:{{ topic["participants"] }}</div>{% endif %}
</div>
{% endif %}
{% if topic["analysis_points"]|default([]) %}
<div class="topic-block">
<span class="label-tiny">Background</span>
<p class="topic-text">{{ topic["analysis_points"][0] }}</p>
</div>
{% endif %}
{% if topic["overview_points"]|default([]) %}
<div class="topic-block">
<span class="label-tiny">Key Points</span>
<ul class="topic-bullets">
{% for line in topic["overview_points"] %}
<p class="item-bullet">{{ line }}</p>
<li>{{ line }}</li>
{% endfor %}
</div>
{% endif %}
{% if topic["analysis_points"] %}
<div class="topic-block">
<p class="topic-subtitle">客观分析</p>
{% for line in topic["analysis_points"] %}
<p class="item-paragraph">{{ line }}</p>
{% endfor %}
</div>
{% endif %}
{% if topic["quote_text"] %}
<div class="topic-block">
<p class="topic-subtitle">亮点瞬间</p>
<blockquote class="item-quote">{{ topic["quote_text"] }}</blockquote>
</div>
{% endif %}
</article>
{% endfor %}
</div>
{% if not summary_topics %}
<div class="fallback-text">{{ summary_fallback_text }}</div>
{% endif %}
{% if summary_aux_sections %}
<div class="aux-sections">
{% for block in summary_aux_sections %}
<article class="aux-card">
<h4 class="aux-title">{{ block["title"] }}</h4>
{% for line in block["items"] %}
<p class="aux-item">• {{ line }}</p>
{% endfor %}
</article>
{% endfor %}
</div>
{% endif %}
<div class="summary-grid">
<div class="mini-card">
<h4 class="mini-title"># Deep Stats</h4>
<div class="mini-list">
{% for item in summary_metrics.mini_stats %}
<div class="mini-row">
<span>{{ item.label }}</span>
<span class="value">{{ item.value }}</span>
</div>
{% endfor %}
</div>
</ul>
</div>
<div class="mini-card">
<h4 class="mini-title"># Core Highlights</h4>
<div class="highlight-list">
{% for text in summary_metrics.highlights %}
<p class="highlight-item">{{ text }}</p>
{% endfor %}
{% if not summary_metrics.highlights %}
<p class="highlight-item">暂无可提取的核心看点</p>
{% endif %}
</div>
{% endif %}
{% if topic["quote_text"] %}
<div class="conclusion-area">
<span class="label-tiny" style="color:#16a34a;">Conclusion</span>
<p class="conclusion-text">{{ topic["quote_text"] }}</p>
</div>
</div>
<div class="safe-callout">内容已按结构化规则重排渲染,不再直接内嵌原始 HTML。</div>
<div class="summary-footer">
<span>ABOT · Message Summary Gemini Style</span>
<span class="right">Tokens: {{ summary_metrics.token_total }} · Latency: {{ summary_metrics.latency_text }}</span>
{% endif %}
</article>
{% endfor %}
</div>
{% if not (summary_topics|default([])) %}
<p class="topic-text">{{ summary_fallback_text }}</p>
{% endif %}
{% if summary_shared_resources|default([]) %}
<section class="resource-wrap">
<span class="label-tiny" style="padding:0 10px 6px;"># Shared Resources</span>
<div class="resource-list">
{% for line in summary_shared_resources %}
<p class="resource-item">{{ line }}</p>
{% endfor %}
</div>
</section>
</div>
{% endif %}
<section class="market-grid">
<article class="market-card">
<span class="label-tiny"># Marketplace</span>
{% for line in summary_marketplace|default([]) %}
<p class="market-item">{{ line }}</p>
{% endfor %}
{% if not (summary_marketplace|default([])) %}
<p class="market-item">暂无交易信息</p>
{% endif %}
</article>
<article class="market-card">
<span class="label-tiny"># Unresolved Pool</span>
{% for line in summary_unresolved_pool|default([]) %}
<p class="market-item">{{ line }}</p>
{% endfor %}
{% if not (summary_unresolved_pool|default([])) %}
<p class="market-item">暂无待解问题</p>
{% endif %}
</article>
</section>
<section class="core-wrap">
<div class="core-card">
<span class="label-tiny" style="color:#64748b;"># Core Knowledge Points</span>
{% for line in summary_core_points|default([]) %}
<p class="core-item">{{ line }}</p>
{% endfor %}
{% if not (summary_core_points|default([])) %}
<p class="core-item">暂无核心知识点</p>
{% endif %}
</div>
</section>
<footer class="footer-main">
<span class="label-tiny" style="margin:0;">Top Contributors</span>
<div class="avatar-list">
{% for name in summary_top_contributors|default([]) %}
<span class="avatar">{{ name[:1] }}</span>
{% endfor %}
{% if not (summary_top_contributors|default([])) %}
<span class="avatar">A</span><span class="avatar">B</span><span class="avatar">C</span>
{% endif %}
</div>
</footer>
<div class="footer-note">Engine: Playwright · Tokens: {{ summary_metrics.token_total }} · Latency: {{ summary_metrics.latency_text }}</div>
</section>
</div>
</body>
</html>