feat(mutli-templates): 适配多套排版选择

This commit is contained in:
SXP-Simon
2025-11-25 20:55:33 +08:00
committed by Helian Nuits
parent e385c294a1
commit 150f6c37a9
15 changed files with 1157 additions and 15 deletions
+6
View File
@@ -66,6 +66,12 @@
"default": "image",
"hint": "分析报告的输出格式:image(图片)、text(文本)、pdf(PDF文件)。使用 PDF 需要额外配置,根据文件中的 PDF_功能说明.md 进行配置"
},
"report_template": {
"type": "string",
"description": "报告模板",
"default": "scrapbook",
"hint": "分析报告使用的HTML模板名称,使用 `/设置模板` 查看使用指南"
},
"min_messages_threshold": {
"type": "int",
+41
View File
@@ -320,6 +320,47 @@ class QQGroupDailyAnalysis(Star):
config_manager.set_output_format(format_type)
yield event.plain_result(f"✅ 输出格式已设置为: {format_type}")
@filter.command("设置模板")
@filter.permission_type(PermissionType.ADMIN)
async def set_report_template(
self, event: AiocqhttpMessageEvent, template_name: str = ""
):
"""
设置分析报告模板
用法: /设置模板 [模板名称]
"""
if not isinstance(event, AiocqhttpMessageEvent):
yield event.plain_result("❌ 此功能仅支持QQ群聊")
return
if not template_name:
current_template = config_manager.get_report_template()
# 列出可用的模板
import os
template_dir = os.path.join(os.path.dirname(__file__), "src", "reports", "templates")
available_templates = []
if os.path.exists(template_dir):
available_templates = [d for d in os.listdir(template_dir) if os.path.isdir(os.path.join(template_dir, d)) and not d.startswith("__")]
template_list_str = "\n".join([f"{t}" for t in available_templates])
yield event.plain_result(f"""🎨 当前报告模板: {current_template}
可用模板:
{template_list_str}
用法: /设置模板 [模板名称]""")
return
# 检查模板是否存在
import os
template_dir = os.path.join(os.path.dirname(__file__), "src", "reports", "templates", template_name)
if not os.path.exists(template_dir):
yield event.plain_result(f"❌ 模板 '{template_name}' 不存在")
return
config_manager.set_report_template(template_name)
yield event.plain_result(f"✅ 报告模板已设置为: {template_name}")
@filter.command("安装PDF")
@filter.permission_type(PermissionType.ADMIN)
async def install_pdf_deps(self, event: AiocqhttpMessageEvent):
+9
View File
@@ -311,6 +311,15 @@ class ConfigManager:
self.config["pdf_filename_format"] = format_str
self.config.save_config()
def get_report_template(self) -> str:
"""获取报告模板名称"""
return self.config.get("report_template", "scrapbook")
def set_report_template(self, template_name: str):
"""设置报告模板名称"""
self.config["report_template"] = template_name
self.config.save_config()
def get_enable_user_card(self) -> bool:
"""获取是否使用用户群名片"""
return self.config.get("enable_user_card", False)
+1 -1
View File
@@ -19,7 +19,7 @@ class ReportGenerator:
def __init__(self, config_manager):
self.config_manager = config_manager
self.activity_visualizer = ActivityVisualizer()
self.html_templates = HTMLTemplates() # 实例化HTML模板管理器
self.html_templates = HTMLTemplates(config_manager) # 实例化HTML模板管理器
async def generate_image_report(
self, analysis_result: dict, group_id: str, html_render_func
+36 -14
View File
@@ -11,43 +11,64 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape
class HTMLTemplates:
"""HTML模板管理类"""
def __init__(self):
def __init__(self, config_manager):
"""初始化Jinja2环境"""
# 设置模板目录
template_dir = os.path.join(os.path.dirname(__file__), "templates")
self.config_manager = config_manager
# 设置模板根目录
self.base_dir = os.path.join(os.path.dirname(__file__), "templates")
# 缓存不同模板的Jinja2环境
self._envs = {}
# 创建Jinja2环境
self.jinja_env = Environment(
def _get_env(self) -> Environment:
"""获取当前配置的模板环境"""
template_name = self.config_manager.get_report_template()
# 如果环境已缓存且配置未变(这里简单假设配置变了会重新获取,或者我们可以每次都检查)
# 为了响应配置热更,我们每次都检查一下或者简单地按需创建
if template_name in self._envs:
return self._envs[template_name]
template_dir = os.path.join(self.base_dir, template_name)
if not os.path.exists(template_dir):
logger.warning(f"模板目录不存在: {template_dir},回退到 scrapbook")
template_dir = os.path.join(self.base_dir, "scrapbook")
# 如果 scrapbook 也不存在,那就有大问题了,不过这里假设 scrapbook 一定存在
env = Environment(
loader=FileSystemLoader(template_dir),
autoescape=select_autoescape(["html", "xml"]),
trim_blocks=True,
lstrip_blocks=True,
)
self._envs[template_name] = env
return env
def get_image_template(self) -> str:
"""获取图片报告的HTML模板(返回原始模板字符串)"""
try:
env = self._get_env()
# 获取模板对象
template = self.jinja_env.get_template("image_template.html")
template = env.get_template("image_template.html")
# 读取原始模板文件内容,而不是渲染它
with open(template.filename, encoding="utf-8") as f:
return f.read()
except Exception:
except Exception as e:
# 如果加载失败,返回空字符串让调用者处理
logger.error("加载图片模板失败")
logger.error(f"加载图片模板失败: {e}")
return ""
def get_pdf_template(self) -> str:
"""获取PDF报告的HTML模板(返回原始模板字符串)"""
try:
env = self._get_env()
# 获取模板对象
template = self.jinja_env.get_template("pdf_template.html")
template = env.get_template("pdf_template.html")
# 读取原始模板文件内容,而不是渲染它
with open(template.filename, encoding="utf-8") as f:
return f.read()
except Exception:
except Exception as e:
# 如果加载失败,返回空字符串让调用者处理
logger.error("加载PDF模板失败")
logger.error(f"加载PDF模板失败: {e}")
return ""
def render_template(self, template_name: str, **kwargs) -> str:
@@ -61,8 +82,9 @@ class HTMLTemplates:
渲染后的HTML字符串
"""
try:
template = self.jinja_env.get_template(template_name)
env = self._get_env()
template = env.get_template(template_name)
return template.render(**kwargs)
except Exception:
logger.error(f"渲染模板 {template_name} 失败")
except Exception as e:
logger.error(f"渲染模板 {template_name} 失败: {e}")
return ""
@@ -0,0 +1,584 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>群聊日常分析报告</title>
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap" rel="stylesheet">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Noto Sans SC', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
min-height: 100vh;
padding: 30px;
line-height: 1.6;
color: #1a1a1a;
}
.container {
max-width: 1400px;
margin: 0 auto;
background: #ffffff;
border-radius: 20px;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
overflow: hidden;
}
.header {
background: linear-gradient(135deg, #4299e1 0%, #667eea 100%);
color: #ffffff;
padding: 60px 50px;
text-align: center;
border-radius: 30px 30px 0 0;
}
.header h1 {
font-size: 3.2em;
font-weight: 300;
margin-bottom: 16px;
letter-spacing: -1px;
}
.header .date {
font-size: 1.2em;
opacity: 0.8;
font-weight: 300;
letter-spacing: 0.5px;
}
.content {
padding: 40px;
}
.topics-grid,
.users-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 25px;
align-items: stretch;
}
.section {
margin-bottom: 0;
}
.full-width-section {
grid-column: 1 / -1;
margin-bottom: 40px;
}
.section-title {
font-size: 1.6em;
font-weight: 600;
margin-bottom: 25px;
color: #4a5568;
letter-spacing: -0.3px;
display: flex;
align-items: center;
gap: 10px;
border-bottom: 2px solid #e2e8f0;
padding-bottom: 10px;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 25px;
margin-bottom: 40px;
}
.stat-card {
background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
padding: 40px 30px;
text-align: center;
border-radius: 25px;
border: 1px solid #e2e8f0;
transition: all 0.3s ease;
}
.stat-number {
font-size: 3.2em;
font-weight: 300;
color: #4299e1;
margin-bottom: 10px;
display: block;
letter-spacing: -1px;
}
.stat-label {
font-size: 1em;
color: #666666;
font-weight: 400;
text-transform: uppercase;
letter-spacing: 1px;
}
.active-period {
background: linear-gradient(135deg, #4299e1 0%, #667eea 100%);
color: #ffffff;
padding: 40px;
text-align: center;
margin: 60px 0;
border-radius: 25px;
box-shadow: 0 8px 24px rgba(66, 153, 225, 0.3);
}
.active-period .time {
font-size: 3.2em;
font-weight: 200;
margin-bottom: 10px;
letter-spacing: -1px;
}
.active-period .label {
font-size: 1em;
opacity: 0.8;
font-weight: 300;
text-transform: uppercase;
letter-spacing: 1px;
}
.topic-item {
background: #ffffff;
padding: 25px;
margin-bottom: 0;
border-radius: 15px;
border: 1px solid #e5e5e5;
transition: all 0.3s ease;
display: flex;
flex-direction: column;
height: 100%;
box-sizing: border-box;
}
.topic-header {
display: flex;
align-items: center;
margin-bottom: 20px;
}
.topic-number {
background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
color: #ffffff;
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: 500;
margin-right: 16px;
font-size: 1em;
box-shadow: 0 4px 12px rgba(49, 130, 206, 0.3);
}
.topic-title {
font-weight: 600;
color: #2d3748;
font-size: 1.3em;
letter-spacing: -0.3px;
}
.topic-contributors {
color: #666666;
font-size: 1em;
margin-bottom: 16px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.topic-detail {
color: #333333;
line-height: 1.6;
font-size: 1em;
font-weight: 300;
}
.user-title {
background: #ffffff;
padding: 20px;
margin-bottom: 0;
border-radius: 15px;
border: 1px solid #e5e5e5;
display: flex;
align-items: flex-start;
justify-content: space-between;
transition: all 0.3s ease;
min-height: 100px;
height: 100%;
box-sizing: border-box;
}
.user-info {
display: flex;
align-items: center;
flex: 1;
}
.user-avatar {
width: 50px;
height: 50px;
border-radius: 50%;
margin-right: 20px;
border: 2px solid #f0f0f0;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.user-avatar-placeholder {
width: 50px;
height: 50px;
border-radius: 50%;
background: linear-gradient(135deg, #f0f0f0 0%, #e2e8f0 100%);
display: flex;
align-items: center;
justify-content: center;
margin-right: 20px;
font-size: 1.2em;
color: #999999;
border: 2px solid #e5e5e5;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.user-details {
flex: 1;
}
.user-name {
font-weight: 600;
color: #2d3748;
margin-bottom: 15px;
font-size: 1.2em;
letter-spacing: -0.2px;
}
.user-badges {
display: flex;
align-items: center;
gap: 15px;
flex-wrap: nowrap;
overflow-x: auto;
}
.user-title-badge,
.user-mbti {
white-space: nowrap;
display: inline-flex;
align-items: center;
}
.user-title-badge {
background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
color: #ffffff;
padding: 8px 20px;
border-radius: 25px;
font-size: 0.9em;
font-weight: 500;
text-transform: uppercase;
letter-spacing: 0.5px;
box-shadow: 0 2px 8px rgba(66, 153, 225, 0.3);
}
.user-mbti {
background: linear-gradient(135deg, #667eea 0%, #5a67d8 100%);
color: #ffffff;
padding: 8px 15px;
border-radius: 20px;
font-weight: 500;
font-size: 0.9em;
text-transform: uppercase;
letter-spacing: 1px;
box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}
.user-reason {
color: #666666;
font-size: 1em;
text-align: right;
line-height: 1.4;
font-weight: 300;
margin-left: 20px;
flex: 1;
word-wrap: break-word;
overflow-wrap: break-word;
}
.quote-item {
background: #ffffff;
padding: 16px;
margin-bottom: 16px;
border-radius: 12px;
border: 1px solid #e2e8f0;
position: relative;
transition: all 0.3s ease;
}
.quote-content {
font-size: 1.1em;
color: #2d3748;
font-weight: 500;
line-height: 1.6;
margin-bottom: 12px;
font-style: italic;
letter-spacing: 0.2px;
}
.quote-author {
font-size: 0.9em;
color: #4299e1;
font-weight: 600;
margin-bottom: 8px;
text-align: right;
}
.quote-reason {
font-size: 0.8em;
color: #666666;
font-style: normal;
background: rgba(66, 153, 225, 0.1);
padding: 8px 12px;
border-radius: 12px;
border-left: 3px solid #4299e1;
}
.footer {
background: linear-gradient(135deg, #3182ce 0%, #2c5282 100%);
color: #ffffff;
text-align: center;
padding: 40px;
font-size: 1em;
font-weight: 300;
letter-spacing: 0.5px;
opacity: 0.9;
}
/* 活跃度可视化样式 - 重新设计 */
.activity-section {
background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
padding: 50px;
border-radius: 25px;
margin: 50px 0;
border: 1px solid #e2e8f0;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}
.activity-chart-container {
background: #ffffff;
padding: 40px;
border-radius: 20px;
border: 1px solid #e2e8f0;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
}
.chart-header {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 40px;
padding-bottom: 20px;
border-bottom: 2px solid #f0f2f5;
}
.chart-title {
font-size: 1.6em;
font-weight: 600;
color: #2d3748;
display: flex;
align-items: center;
gap: 15px;
}
.chart-subtitle {
color: #7f8c8d;
font-size: 1.1em;
font-weight: 400;
}
.hour-bar-container {
display: flex;
align-items: center;
margin: 12px 0;
height: 25px;
transition: all 0.2s ease;
}
.hour-label {
width: 65px;
text-align: left;
color: #4a5568;
font-size: 15px;
font-weight: 500;
flex-shrink: 0;
}
.bar-wrapper {
display: flex;
align-items: center;
flex-grow: 1;
gap: 15px;
min-width: 0;
}
.bar {
height: 12px;
background: linear-gradient(90deg, #4299e1 0%, #667eea 100%);
border-radius: 8px;
transition: all 0.3s ease-out;
display: flex;
justify-content: flex-end;
align-items: center;
overflow: hidden;
box-shadow: 0 2px 8px rgba(66, 153, 225, 0.2);
}
.hourly-value-outside {
color: #4a5568;
font-size: 14px;
font-weight: 600;
flex-shrink: 0;
min-width: 35px;
text-align: right;
}
.hourly-value-inside {
color: white;
font-size: 13px;
padding: 0 10px;
font-weight: 600;
white-space: nowrap;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}
@media (min-width: 1400px) {
.container {
max-width: 1600px;
}
.topics-grid {
grid-template-columns: repeat(3, 1fr);
}
.users-grid {
grid-template-columns: repeat(3, 1fr);
}
}
@media (max-width: 768px) {
body {
padding: 15px;
}
.container {
margin: 0;
max-width: 100%;
}
.header {
padding: 30px 25px;
}
.header h1 {
font-size: 2.2em;
}
.content {
padding: 25px;
}
.topics-grid {
grid-template-columns: 1fr;
}
.users-grid {
grid-template-columns: 1fr;
}
.stats-grid {
grid-template-columns: 1fr 1fr;
gap: 15px;
}
.stat-card {
padding: 25px 20px;
}
.topic-item {
padding: 25px;
}
.user-title {
flex-direction: column;
align-items: flex-start;
gap: 15px;
padding: 20px;
min-height: auto;
}
.user-info {
width: 100%;
}
.user-reason {
text-align: left;
max-width: none;
margin-left: 0;
margin-top: 10px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📊 群聊日常分析报告</h1>
<div class="date">{{current_date}}</div>
</div>
<div class="content">
<div class="section full-width-section">
<h2 class="section-title">📈 基础统计</h2>
<div class="stats-grid">
<div class="stat-card"><div class="stat-number">{{message_count}}</div><div class="stat-label">消息总数</div></div>
<div class="stat-card"><div class="stat-number">{{participant_count}}</div><div class="stat-label">参与人数</div></div>
<div class="stat-card"><div class="stat-number">{{total_characters}}</div><div class="stat-label">总字符数</div></div>
<div class="stat-card"><div class="stat-number">{{emoji_count}}</div><div class="stat-label">表情数量</div></div>
</div>
<div class="active-period">
<div class="time">{{most_active_period}}</div>
<div class="label">最活跃时段</div>
</div>
</div>
<!-- 活跃度可视化部分 - 重新设计 -->
<div class="activity-chart-container">
<div class="chart-header">
<div>
<div class="chart-title">⏱️ 24小时活跃度分布</div>
</div>
</div>
{{hourly_chart_html}}
</div>
<div class="section">
<h2 class="section-title">💬 热门话题</h2>
<div class="topics-grid">{{topics_html}}</div>
</div>
<div class="section">
<h2 class="section-title">🏆 群友称号</h2>
<div class="users-grid">{{titles_html}}</div>
</div>
<div class="section">
<h2 class="section-title">💬 群圣经</h2>
{{quotes_html}}
</div>
</div>
<div class="footer">
由 AstrBot QQ群日常分析插件 生成 | {{current_datetime}} | SXP-Simon/astrbot-qq-group-daily-analysis<br>
<small style="opacity: 0.8; font-size: 0.9em;">🤖 AI分析消耗:{{total_tokens}} tokens (输入: {{prompt_tokens}}, 输出: {{completion_tokens}})</small>
</div>
</div>
</body>
</html>
+444
View File
@@ -0,0 +1,444 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>群聊日常分析报告</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Microsoft YaHei', 'SimHei', sans-serif;
background: #ffffff;
color: #1a1a1a;
line-height: 1.6;
font-size: 14px;
}
.container {
max-width: 800px;
margin: 0 auto;
padding: 20px;
}
.header {
background: linear-gradient(135deg, #4299e1 0%, #667eea 100%);
color: #ffffff;
padding: 30px;
text-align: center;
border-radius: 12px;
margin-bottom: 30px;
}
.header h1 {
font-size: 28px;
font-weight: 600;
margin-bottom: 8px;
}
.header .date {
font-size: 16px;
opacity: 0.9;
}
.section {
margin-bottom: 40px;
page-break-inside: avoid;
}
.section-title {
font-size: 20px;
font-weight: 600;
margin-bottom: 20px;
color: #4a5568;
border-bottom: 2px solid #4299e1;
padding-bottom: 8px;
}
.stats-grid {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 15px;
margin-bottom: 30px;
}
.stat-card {
background: #f8f9ff;
padding: 20px;
text-align: center;
border-radius: 8px;
border: 1px solid #e2e8f0;
}
.stat-number {
font-size: 24px;
font-weight: 600;
color: #4299e1;
margin-bottom: 5px;
}
.stat-label {
font-size: 12px;
color: #666666;
text-transform: uppercase;
}
.active-period {
background: linear-gradient(135deg, #4299e1 0%, #667eea 100%);
color: #ffffff;
padding: 25px;
text-align: center;
margin: 30px 0;
border-radius: 8px;
}
.active-period .time {
font-size: 28px;
font-weight: 300;
margin-bottom: 5px;
}
.active-period .label {
font-size: 14px;
opacity: 0.9;
}
.topic-item {
background: #ffffff;
padding: 20px;
margin-bottom: 15px;
border-radius: 8px;
border: 1px solid #e2e8f0;
page-break-inside: avoid;
}
.topic-header {
display: flex;
align-items: center;
margin-bottom: 12px;
}
.topic-number {
background: #4299e1;
color: #ffffff;
width: 24px;
height: 24px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
margin-right: 12px;
font-size: 12px;
}
.topic-title {
font-weight: 600;
color: #2d3748;
font-size: 16px;
}
.topic-contributors {
color: #666666;
font-size: 12px;
margin-bottom: 10px;
}
.topic-detail {
color: #333333;
line-height: 1.6;
font-size: 14px;
}
.user-title {
background: #ffffff;
padding: 20px;
margin-bottom: 15px;
border-radius: 8px;
border: 1px solid #e2e8f0;
display: flex;
align-items: flex-start;
justify-content: space-between;
page-break-inside: avoid;
}
.user-info {
display: flex;
align-items: center;
flex: 1;
}
.user-details {
flex: 1;
}
.user-name {
font-weight: 600;
color: #2d3748;
margin-bottom: 8px;
font-size: 16px;
}
.user-badges {
display: flex;
align-items: center;
gap: 8px;
flex-wrap: wrap;
}
.user-title-badge {
background: #4299e1;
color: #ffffff;
padding: 4px 12px;
border-radius: 12px;
font-size: 12px;
font-weight: 500;
}
.user-mbti {
background: #667eea;
color: #ffffff;
padding: 4px 8px;
border-radius: 8px;
font-weight: 500;
font-size: 12px;
}
.user-reason {
color: #666666;
font-size: 12px;
max-width: 200px;
text-align: right;
line-height: 1.4;
}
.user-avatar {
width: 40px;
height: 40px;
border-radius: 50%;
margin-right: 15px;
border: 2px solid #e2e8f0;
object-fit: cover;
flex-shrink: 0;
}
.user-avatar-placeholder {
width: 40px;
height: 40px;
border-radius: 50%;
background: #f0f0f0;
display: flex;
align-items: center;
justify-content: center;
margin-right: 15px;
font-size: 18px;
color: #666666;
flex-shrink: 0;
}
.quote-item {
background: #faf5ff;
padding: 20px;
margin-bottom: 15px;
border-radius: 8px;
border: 1px solid #e2e8f0;
page-break-inside: avoid;
}
.quote-content {
font-size: 16px;
color: #2d3748;
font-weight: 500;
line-height: 1.6;
margin-bottom: 10px;
font-style: italic;
}
.quote-author {
font-size: 14px;
color: #4299e1;
font-weight: 600;
margin-bottom: 8px;
text-align: right;
}
.quote-reason {
font-size: 12px;
color: #666666;
background: rgba(66, 153, 225, 0.1);
padding: 8px 12px;
border-radius: 6px;
border-left: 3px solid #4299e1;
}
.footer {
background: #f8f9ff;
color: #666666;
text-align: center;
padding: 20px;
font-size: 12px;
border-radius: 8px;
margin-top: 40px;
}
/* PDF活跃度可视化样式 - 集成版本 */
.activity-chart-container {
background: #f8f9ff;
padding: 20px;
border-radius: 8px;
border: 1px solid #e2e8f0;
margin-top: 20px;
page-break-inside: avoid;
}
.chart-header {
margin-bottom: 15px;
padding-bottom: 8px;
border-bottom: 1px solid #e2e8f0;
}
.chart-title {
font-size: 16px;
font-weight: 600;
color: #2d3748;
}
.hour-bar-container {
display: flex;
align-items: center;
margin: 6px 0;
height: 16px;
}
.hour-label {
width: 45px;
text-align: left;
color: #4a5568;
font-size: 11px;
font-weight: 500;
flex-shrink: 0;
}
.bar-wrapper {
display: flex;
align-items: center;
flex-grow: 1;
gap: 8px;
min-width: 0;
}
.bar {
height: 6px;
background-color: #4299e1;
border-radius: 3px;
display: flex;
justify-content: flex-end;
align-items: center;
overflow: hidden;
}
.hourly-value-outside {
color: #4a5568;
font-size: 10px;
font-weight: 600;
flex-shrink: 0;
min-width: 25px;
text-align: right;
}
.hourly-value-inside {
color: white;
font-size: 9px;
padding: 0 4px;
font-weight: 600;
white-space: nowrap;
}
@media print {
body {
font-size: 12px;
}
.container {
padding: 10px;
}
.header {
padding: 20px;
}
.section {
margin-bottom: 30px;
}
.stats-grid {
grid-template-columns: repeat(2, 1fr);
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>📊 群聊日常分析报告</h1>
<div class="date">{{current_date}}</div>
</div>
<div class="section">
<h2 class="section-title">📈 基础统计</h2>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-number">{{message_count}}</div>
<div class="stat-label">消息总数</div>
</div>
<div class="stat-card">
<div class="stat-number">{{participant_count}}</div>
<div class="stat-label">参与人数</div>
</div>
<div class="stat-card">
<div class="stat-number">{{total_characters}}</div>
<div class="stat-label">总字符数</div>
</div>
<div class="stat-card">
<div class="stat-number">{{emoji_count}}</div>
<div class="stat-label">表情数量</div>
</div>
</div>
<div class="active-period">
<div class="time">{{most_active_period}}</div>
<div class="label">最活跃时段</div>
</div>
<!-- 活跃度可视化部分 - 集成到基础统计 -->
<div class="activity-chart-container">
<div class="chart-header">
<div class="chart-title">⏱️ 活跃度分布</div>
</div>
{{hourly_chart_html}}
</div>
</div>
<div class="section">
<h2 class="section-title">💬 热门话题</h2>
{{topics_html}}
</div>
<div class="section">
<h2 class="section-title">🏆 群友称号</h2>
{{titles_html}}
</div>
<div class="section">
<h2 class="section-title">💬 群圣经</h2>
{{quotes_html}}
</div>
<div class="footer">
由 AstrBot QQ群日常分析插件 生成 | {{current_datetime}} | SXP-Simon/astrbot-qq-group-daily-analysis<br>
<small style="opacity: 0.8; font-size: 0.9em;">🤖 AI分析消耗:{{total_tokens}} tokens (输入: {{prompt_tokens}}, 输出:
{{completion_tokens}})</small>
</div>
</div>
</body>
</html>
@@ -0,0 +1,7 @@
{% for quote in quotes %}
<div class="quote-item">
<div class="quote-content">"{{ quote.content }}"</div>
<div class="quote-author">—— {{ quote.sender }}</div>
<div class="quote-reason">{{ quote.reason }}</div>
</div>
{% endfor %}
+10
View File
@@ -0,0 +1,10 @@
{% for topic in topics %}
<div class="topic-item">
<div class="topic-header">
<span class="topic-number">{{ topic.index }}</span>
<span class="topic-title">{{ topic.topic.topic }}</span>
</div>
<div class="topic-contributors">参与者: {{ topic.contributors }}</div>
<div class="topic-detail">{{ topic.topic.detail }}</div>
</div>
{% endfor %}
@@ -0,0 +1,19 @@
{% for title in titles %}
<div class="user-title">
<div class="user-info">
{% if title.avatar_data %}
<img src="{{ title.avatar_data }}" class="user-avatar" alt="头像">
{% else %}
<div class="user-avatar-placeholder">👤</div>
{% endif %}
<div class="user-details">
<div class="user-name">{{ title.name }}</div>
<div class="user-badges">
<div class="user-title-badge">{{ title.title }}</div>
<div class="user-mbti">{{ title.mbti }}</div>
</div>
</div>
</div>
<div class="user-reason">{{ title.reason }}</div>
</div>
{% endfor %}