fix(pdf): 优化 PDF 模板生成情况

This commit is contained in:
SXP-Simon
2026-03-25 16:09:54 +08:00
parent 58615d2752
commit 72ead04182
12 changed files with 811 additions and 716 deletions
@@ -9,6 +9,11 @@
href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&family=Inter:wght@300;400;500;600&display=swap"
rel="stylesheet">
<style>
@page {
size: A4;
margin: 0;
}
:root {
--bg-body: #f2f2f2;
--bg-card: #ffffff;
@@ -31,18 +36,19 @@
background-color: var(--bg-body);
color: var(--text-main);
line-height: 1.6;
padding: 20px;
padding: 20mm;
-webkit-font-smoothing: antialiased;
}
.container {
width: 100%;
max-width: none;
max-width: 170mm;
margin: 0 auto;
background: var(--bg-card);
border-radius: var(--radius);
box-shadow: var(--shadow);
overflow: hidden;
min-height: 250mm;
}
/* Header - Editorial Style */
@@ -437,6 +443,14 @@
padding: 30px;
font-size: 0.8em;
border-top: 1px solid var(--border);
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.footer a {
color: var(--text-main);
text-decoration: underline;
}
/* Responsive */
@@ -521,11 +535,27 @@
{{topics_html | safe}}
{{titles_html | safe}}
{{quotes_html | safe}}
{% if chat_quality_html %}
<div class="section full-width-section">
<h2 class="section-title">智睿洞察 // Chat Quality</h2>
<div style="margin-top: 20px;">
{{ chat_quality_html | safe }}
</div>
</div>
{% endif %}
</div>
<div class="footer">
由 AstrBot QQ群日常分析插件 生成 | {{current_datetime}} | SXP-Simon/astrbot_plugin_qq_group_daily_analysis<br>
<small style="opacity: 0.8; font-size: 0.9em; margin-top: 8px; display: block;">AI分析消耗:{{total_tokens}}
tokens (输入: {{prompt_tokens}}, 输出: {{completion_tokens}})</small>
<div style="text-align: left;">
<strong>Generated by SXP-Simon</strong><br>
<a href="https://github.com/SXP-Simon/astrbot_plugin_qq_group_daily_analysis" target="_blank">
GitHub Repository
</a>
</div>
<div style="text-align: right;">
{{current_datetime}}<br>
Tokens: {{total_tokens}} (P:{{prompt_tokens}} / C:{{completion_tokens}})
</div>
</div>
</div>
</body>
@@ -3,7 +3,7 @@
<div class="activity-col">
<span class="activity-val-top">{{ item.count }}</span>
<div class="activity-bar-v" style="--h:{{ "%.2f"|format(item.percentage) }}%;"></div>
<span class="activity-tick">{{ "%02d"|format(item.hour) }}:00</span>
<span class="activity-tick">{{ "%02d"|format(item.hour) }}</span>
</div>
{% endfor %}
{% else %}
@@ -53,9 +53,11 @@
}
.layout {
max-width: 1000px;
width: 100%;
max-width: 190mm;
margin: 0 auto;
padding: 40px;
padding: 10mm;
min-height: 297mm;
}
.main-container {
@@ -145,10 +147,10 @@
}
h1 {
font-size: 3.5rem;
font-size: 2.8rem;
font-weight: 800;
margin: 0 0 15px;
letter-spacing: -1.5px;
letter-spacing: -1px;
line-height: 1;
color: #fff;
}
@@ -202,10 +204,49 @@
.chart-container {
height: 220px;
position: relative;
padding: 20px 5px;
padding: 30px 5px 40px;
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 2px;
}
.activity-col {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
justify-content: flex-end;
min-width: 0;
}
.activity-bar-v {
width: 80%;
max-width: 10px;
background: var(--accent-orange);
height: var(--h, 0%);
border-radius: 1px 1px 0 0;
box-shadow: 0 0 8px rgba(255, 153, 0, 0.3);
position: relative;
}
.activity-tick {
font-family: var(--font-mono);
font-size: 0.5rem;
color: var(--text-secondary);
margin-top: 8px;
transform: rotate(-60deg);
transform-origin: top center;
white-space: nowrap;
}
.activity-val-top {
font-family: var(--font-mono);
font-size: 0.5rem;
color: var(--text-primary);
margin-bottom: 4px;
opacity: 0.6;
}
.topic-list,
@@ -308,16 +349,22 @@
}
footer {
margin-top: 60px;
margin-top: 40px;
padding-top: 20px;
border-top: 1px solid var(--border-color);
display: flex;
justify-content: space-between;
align-items: flex-end;
font-family: var(--font-mono);
font-size: 0.75rem;
font-size: 0.7rem;
color: var(--text-secondary);
}
.footer-repo a {
color: var(--accent-orange);
text-decoration: underline;
}
.avoid-break {
page-break-inside: avoid;
}
@@ -345,12 +392,19 @@
</div>
</div>
<div class="avoid-break">
<div>
<div class="section-header"><span class="prompt">$</span> ls ./topics</div>
<div class="topic-list">
{{topics_html | safe}}
</div>
</div>
{% if chat_quality_html %}
<div style="margin-top: 30px;" class="avoid-break">
<div class="section-header"><span class="prompt">$</span> analyze quality</div>
{{ chat_quality_html | safe }}
</div>
{% endif %}
</div>
<!-- Right Column: Chart & People -->
@@ -368,25 +422,33 @@
</div>
</div>
<div class="avoid-break">
<div class="section-header"><span class="prompt">$</span> cat users</div>
<div class="user-grid">
{{titles_html | safe}}
</div>
</div>
<div class="avoid-break">
<div class="section-header"><span class="prompt">$</span> grep golden</div>
<div class="quote-grid">
{{quotes_html | safe}}
<div style="margin-top: 30px;">
<div class="section-header"><span class="prompt">$</span> grep golden</div>
<div class="quote-grid">
{{quotes_html | safe}}
</div>
</div>
</div>
</div>
</div>
</div>
<footer>
<div>SYSTEM_REPORT // {{current_datetime}}</div>
<div style="color: var(--accent-orange);">AstrBotDevs/AstrBot 群分析</div>
<div class="footer-repo">
<div class="comment">// SXP-Simon</div>
<a href="https://github.com/SXP-Simon/astrbot_plugin_qq_group_daily_analysis" target="_blank">
github.com/SXP-Simon/astrbot_plugin_qq_group_daily_analysis
</a>
</div>
<div style="text-align: right;">
<div class="comment">// {{current_datetime}}</div>
<div>Tokens: {{total_tokens}} [P:{{prompt_tokens}} C:{{completion_tokens}}]</div>
</div>
</footer>
</div>
</body>
@@ -4,7 +4,7 @@
<div class="activity-col">
<span class="activity-col-count">{{ item.count }}</span>
<div class="activity-bar-vertical" style="--h: {{ "%.2f"|format(item.percentage) }}%;"></div>
<span class="activity-label-hour">{{ "%02d"|format(item.hour) }}:00</span>
<span class="activity-label-hour">{{ "%02d"|format(item.hour) }}</span>
</div>
{% endfor %}
</div>
File diff suppressed because it is too large Load Diff
@@ -964,6 +964,13 @@
{{quotes_html | safe}}
<div class="quality-section">
<div class="section-title">
<svg class="doodle" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18z" />
<path d="M12 8v4l3 3" />
</svg>
智睿洞察 // Chat Quality
</div>
{{ chat_quality_html | safe }}
</div>
</div>
@@ -5,51 +5,105 @@
<meta charset="UTF-8">
<title>Simple Report</title>
<style>
@page {
size: A4;
margin: 0;
}
body {
font-family: sans-serif;
font-family: 'Noto Sans SC', sans-serif;
background: #fafafa;
margin: 0;
padding: 20mm;
color: #333;
}
.container {
max-width: 170mm;
margin: 0 auto;
background: #fff;
padding: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.05);
min-height: 250mm;
}
.section {
margin-bottom: 20px;
border: 1px solid #ccc;
padding: 10px;
margin-bottom: 25px;
border-bottom: 1px solid #eee;
padding-bottom: 15px;
}
h1,
h2 {
color: #333;
h1 { color: #2c3e50; border-left: 5px solid #3498db; padding-left: 15px; }
h2 { color: #34495e; font-size: 1.2rem; }
.footer {
margin-top: 40px;
padding-top: 20px;
border-top: 2px solid #eee;
color: #7f8c8d;
font-size: 0.85rem;
display: flex;
justify-content: space-between;
align-items: flex-end;
}
.footer a { color: #3498db; text-decoration: none; }
</style>
</head>
<body>
<h1>群聊日报 - {{current_date}}</h1>
<div class="container">
<h1>群聊日报 - {{current_date}}</h1>
<div class="section">
<h2>基础统计</h2>
<p>消息数: {{message_count}}</p>
<p>参与人数: {{participant_count}}</p>
<p>总字符数: {{total_characters}}</p>
<p>表情数: {{emoji_count}}</p>
<p>最活跃时段: {{most_active_period}}</p>
</div>
<div class="section">
<h2>基础统计</h2>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;">
<p>消息数: <strong>{{message_count}}</strong></p>
<p>参与人数: <strong>{{participant_count}}</strong></p>
<p>总字符数: <strong>{{total_characters}}</strong></p>
<p>表情数: <strong>{{emoji_count}}</strong></p>
<p>最活跃时段: <strong>{{most_active_period}}</strong></p>
</div>
</div>
<div class="section">
<h2>活跃度图表</h2>
{{hourly_chart_html | safe}}
</div>
{{topics_html | safe}}
{{titles_html | safe}}
{{quotes_html | safe}}
<div class="section">
<h2>活跃度图表</h2>
<div style="background: #f9f9f9; padding: 10px; border-radius: 4px;">
{{hourly_chart_html | safe}}
</div>
</div>
<div class="footer">
Generated by AstrBot | {{current_datetime}}
<br>
<small>Token Usage: {{total_tokens}} (Prompt: {{prompt_tokens}}, Completion: {{completion_tokens}})</small>
<div class="section">
{{topics_html | safe}}
</div>
<div class="section">
{{titles_html | safe}}
</div>
<div class="section" style="border: none;">
{{quotes_html | safe}}
</div>
{% if chat_quality_html %}
<div class="section">
<h2>Chat Quality</h2>
{{ chat_quality_html | safe }}
</div>
{% endif %}
<div class="footer">
<div>
<strong>Generated by SXP-Simon</strong><br>
<a href="https://github.com/SXP-Simon/astrbot_plugin_qq_group_daily_analysis" target="_blank">
GitHub Repository
</a>
</div>
<div style="text-align: right;">
{{current_datetime}}<br>
Tokens: {{total_tokens}} (P:{{prompt_tokens}} / C:{{completion_tokens}})
</div>
</div>
</div>
</body>
@@ -31,7 +31,7 @@
transform: rotate(-45deg);
font-weight: bold;
">
{{ "%02d"|format(item.hour) }}:00
{{ "%02d"|format(item.hour) }}
</div>
</div>
{% endfor %}
@@ -42,11 +42,12 @@
}
.layout {
max-width: 900px;
width: 100%;
max-width: 190mm;
margin: 0 auto;
padding: 40px;
border: 10px solid var(--red-festive);
min-height: 100vh;
padding: 10mm;
border: 10mm solid var(--red-festive);
min-height: 297mm;
position: relative;
}
@@ -266,6 +267,14 @@
padding-top: 20px;
font-size: 0.8rem;
color: var(--red-festive);
display: flex;
flex-direction: column;
gap: 8px;
}
.footer-repo a {
color: var(--red-festive);
text-decoration: underline;
}
.avoid-break {
@@ -317,12 +326,25 @@
{{titles_html | safe}}
</div>
</div>
{% if chat_quality_html %}
<div class="sf-section-title">智睿点评 // Chat Quality</div>
{{ chat_quality_html | safe }}
{% endif %}
<div class="sf-section-title">每日金句回响</div>
{{quotes_html | safe}}
<footer>
<div>Generated by SXP-Simon / astrbot_plugin_qq_group_daily_analysis // {{current_datetime}}</div>
<div class="footer-repo">
<a href="https://github.com/SXP-Simon/astrbot_plugin_qq_group_daily_analysis" target="_blank">
github.com/SXP-Simon/astrbot_plugin_qq_group_daily_analysis
</a>
</div>
<div>Generated by SXP-Simon // {{current_datetime}}</div>
<div style="font-size: 0.75rem; opacity: 0.8;">
Tokens: {{total_tokens}} (P: {{prompt_tokens}} / C: {{completion_tokens}})
</div>
</footer>
</div>
</body>