From 4200631f175a077d040faff3f40301453011a76b Mon Sep 17 00:00:00 2001 From: SXP-Simon Date: Sat, 28 Mar 2026 21:18:50 +0800 Subject: [PATCH] =?UTF-8?q?fix(HatsuneMiku):=20=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 + README.md | 14 +- _conf_schema.json | 1 + scripts/debug_all_pdf_themes.py | 1 + scripts/mock_pdf_gen.py | 2 +- .../templates/HatsuneMiku/activity_chart.html | 34 +- .../HatsuneMiku/chat_quality_item.html | 27 +- .../templates/HatsuneMiku/image_template.html | 541 ++++++++++++++---- .../templates/HatsuneMiku/pdf_template.html | 69 ++- .../templates/HatsuneMiku/quote_item.html | 13 +- .../templates/HatsuneMiku/topic_item.html | 171 +----- .../HatsuneMiku/user_title_item.html | 46 +- 12 files changed, 579 insertions(+), 343 deletions(-) diff --git a/.gitignore b/.gitignore index b360f37..a032166 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ scripts/output_all/debug_scrapbook_test_group_*.pdf scripts/output_all/debug_simple_test_group_*.pdf scripts/output_all/debug_spring_festival_test_group_*.pdf scripts/data/avatar/cache.db +debug_miku.html +scripts/output_all/debug_HatsuneMiku_test_group_*.pdf +scripts/output/mock_report_test_group_mock_*.pdf diff --git a/README.md b/README.md index 75d72cf..e49ff90 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ Telegram Group + + QQ群 + Telegram群 + @@ -365,10 +369,11 @@ src/infrastructure/reporting/templates/your_theme_name/ PDF 调试模板命令: ```bash -# docker -docker exec -it astrbot python data/plugins/astrbot_plugin_qq_group_daily_analysis/scripts/mock_pdf_gen.py -# uv -uv run --with playwright --with diskcache data\plugins\astrbot_plugin_qq_group_daily_analysis\scripts\mock_pdf_gen.py +# 生成所有主题的 PDF (推荐) +uv run --with playwright --with diskcache scripts\debug_all_pdf_themes.py + +# 生成指定主题的 PDF (例如:HatsuneMiku ,可以修改内部代码占位解决) +uv run --with playwright --with diskcache scripts\mock_pdf_gen.py ``` Image 模板调试: @@ -401,6 +406,7 @@ uv run scripts\debug_render.py -t retro_futurism -o debug_retro.html uv run scripts\debug_render.py -t format -o debug_format.html uv run scripts\debug_render.py -t simple -o debug_simple.html uv run scripts\debug_render.py -t spring_festival -o debug_spring.html +uv run scripts\debug_render.py -t HatsuneMiku -o debug_miku.html ``` diff --git a/_conf_schema.json b/_conf_schema.json index 268e455..3201af2 100644 --- a/_conf_schema.json +++ b/_conf_schema.json @@ -69,6 +69,7 @@ "options": [ "scrapbook", "retro_futurism", + "HatsuneMiku", "hack", "spring_festival", "simple", diff --git a/scripts/debug_all_pdf_themes.py b/scripts/debug_all_pdf_themes.py index 641a2e3..da66707 100644 --- a/scripts/debug_all_pdf_themes.py +++ b/scripts/debug_all_pdf_themes.py @@ -226,6 +226,7 @@ async def main(): "simple", "spring_festival", "format", + "HatsuneMiku", ] for theme in themes: await generate_theme(theme) diff --git a/scripts/mock_pdf_gen.py b/scripts/mock_pdf_gen.py index d46ec71..6684423 100644 --- a/scripts/mock_pdf_gen.py +++ b/scripts/mock_pdf_gen.py @@ -87,7 +87,7 @@ class MockConfigManager: return 5 def get_report_template(self): - return "scrapbook" + return "HatsuneMiku" def get_enable_user_card(self): return True diff --git a/src/infrastructure/reporting/templates/HatsuneMiku/activity_chart.html b/src/infrastructure/reporting/templates/HatsuneMiku/activity_chart.html index 95ee5a8..fb28b98 100644 --- a/src/infrastructure/reporting/templates/HatsuneMiku/activity_chart.html +++ b/src/infrastructure/reporting/templates/HatsuneMiku/activity_chart.html @@ -1,6 +1,6 @@ -
-
- {# 定义一个从 葱绿 -> 薄荷 -> 鹅黄 -> 蜜桃粉 的完美过渡色板 #} +
+ {# 柱状图主体层:确保底部对齐 #} +
{% set chart_colors = [ '#66D1C7', '#6FD3C6', '#79D5C4', '#85D8C3', '#93DAC1', '#A3DDBF', '#B4E0BD', '#C7E2BA', '#DBE5B8', '#EFE8B5', '#FFEAB3', '#FFDF9E', @@ -10,10 +10,7 @@ {% for item in chart_data %} {% set h = item.percentage | float %} - - {# 使用 loop.index0 从色板中依次取色,形成从左到右的全局渐变 #} {% set bar_color = chart_colors[loop.index0 % 24] %} - {% set bar_opacity = '1' %} {% if item.count == 0 %} {% set h = '4' %} @@ -21,22 +18,27 @@ {% set bar_color = 'var(--miku-blue)' %} {% endif %} -
+
{% if item.count > 0 %} - {# 数字去掉背景框,颜色与柱子保持一致,视觉更通透 #} - {{ item.count }} + {{ item.count }} {% endif %} - {# 柱状体 #}
- - {# X轴标签 #} - {{ "%02d"|format(item.hour) }}时 + opacity: {{ bar_opacity }}; + transition: height 0.3s ease;">
+
+ {% endfor %} +
+ + {# X轴标签层:独立容器确保水平对齐且不换行 #} +
+ {% for item in chart_data %} +
+ + {{ "%02d"|format(item.hour) }}{% if loop.index0 % 4 == 0 or loop.last %}时{% endif %} +
{% endfor %}
diff --git a/src/infrastructure/reporting/templates/HatsuneMiku/chat_quality_item.html b/src/infrastructure/reporting/templates/HatsuneMiku/chat_quality_item.html index 1d18ff3..6d40625 100644 --- a/src/infrastructure/reporting/templates/HatsuneMiku/chat_quality_item.html +++ b/src/infrastructure/reporting/templates/HatsuneMiku/chat_quality_item.html @@ -1,9 +1,4 @@ -
-
-
-
聊天质量分析
-
-
+
{{ title }}
{{ subtitle }}
@@ -28,12 +23,20 @@ {% endfor %}
-
-
- 🎤 - Miku 综合点评 +
+
+
+ + + + + Miku 综合点评 +
+
{{ summary }}
+
+
+ + Quality Deco
-
{{ summary }}
-
diff --git a/src/infrastructure/reporting/templates/HatsuneMiku/image_template.html b/src/infrastructure/reporting/templates/HatsuneMiku/image_template.html index 3d7721b..7375230 100644 --- a/src/infrastructure/reporting/templates/HatsuneMiku/image_template.html +++ b/src/infrastructure/reporting/templates/HatsuneMiku/image_template.html @@ -5,40 +5,48 @@ 群聊日常分析看板 · {{current_date}} - + + @@ -246,7 +477,7 @@
39
[ SYSTEM_VOCALOID_INITIALIZED ]
HATSUNE MIKU v4X
- +

群聊日常分析看板

@@ -254,29 +485,29 @@
-
-
+
+
今日消息数
{{message_count}}
-
-
+
+
活跃成员数
{{participant_count}}
-
-
+
+
表情互动
{{emoji_count}}
-
-
+
+
今日字数累计
{{total_characters}}
@@ -285,42 +516,122 @@
-
峰值活跃时间段
+
+ + 峰值活跃时间段 +
{{most_active_period}}
- +
- Peak Activity Visualization + Peak Activity Visualization
-
+ + {% if hourly_chart_html %} +
-
24小时活动图段
+
+ + 24小时活动 +
+
+
+ {{hourly_chart_html | safe}}
- {{hourly_chart_html | safe}}
+ {% endif %} - {{topics_html | safe}} - {{titles_html | safe}} - {{quotes_html | safe}} - {{chat_quality_html | safe}} + + {% if topics_html %} +
+
+
+
+ + 话题总结 +
+
+ {{topics_html | safe}} +
+ {% endif %} + + + {% if titles_html %} +
+
+
+
+ + 群友画像 +
+
+ {{titles_html | safe}} +
+ {% endif %} + + + {% if quotes_html %} +
+
+
+
+ + 今日圣经 +
+
+ {{quotes_html | safe}} +
+ {% endif %} + + + {% if chat_quality_html %} +
+
+
+
+ + 群聊锐评 +
+
+ {{chat_quality_html | safe}} +
+ {% endif %}
+ + \ No newline at end of file diff --git a/src/infrastructure/reporting/templates/HatsuneMiku/pdf_template.html b/src/infrastructure/reporting/templates/HatsuneMiku/pdf_template.html index b058c10..20540e5 100644 --- a/src/infrastructure/reporting/templates/HatsuneMiku/pdf_template.html +++ b/src/infrastructure/reporting/templates/HatsuneMiku/pdf_template.html @@ -5,7 +5,8 @@ 群聊日常分析看板 · {{current_date}} - + +