mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 05:31:52 +00:00
fix(ATRI): 将镜像地址配置注入到子模板渲染上下文中,解决子模板中变量未定义导致的问题
This commit is contained in:
+11
-4
@@ -125,8 +125,8 @@ class MockConfigManager:
|
||||
def get_html_base_url(self) -> str:
|
||||
return ""
|
||||
|
||||
def get_t2i_font_source(self) -> str:
|
||||
return "Overseas"
|
||||
def get_t2i_atri_font_mirror(self) -> str:
|
||||
return "https://tc.ciallo.ccwu.cc"
|
||||
|
||||
def get_t2i_google_fonts_mirror(self) -> str:
|
||||
return "https://fonts.googleapis.com"
|
||||
@@ -134,8 +134,8 @@ class MockConfigManager:
|
||||
def get_t2i_gstatic_mirror(self) -> str:
|
||||
return "https://fonts.gstatic.com"
|
||||
|
||||
def get_t2i_atri_font_mirror(self) -> str:
|
||||
return "https://tc.ciallo.ccwu.cc"
|
||||
def get_t2i_font_source(self) -> str:
|
||||
return "Overseas"
|
||||
|
||||
def get_t2i_rendering_strategies(self) -> list:
|
||||
return []
|
||||
@@ -325,6 +325,13 @@ async def debug_render(
|
||||
"image_template.html", **render_payload
|
||||
)
|
||||
|
||||
# 复用最终 HTML 中所有内联头像资源,并注入复用样式
|
||||
final_html = generator._reuse_avatars_in_final_html(
|
||||
final_html,
|
||||
render_payload.get("avatar_reuse_registry", {}),
|
||||
render_payload.get("avatar_reuse_aliases", {}),
|
||||
)
|
||||
|
||||
# 6. Save to file
|
||||
output_path = Path(output_file)
|
||||
output_path.write_text(final_html, encoding="utf-8")
|
||||
|
||||
@@ -730,8 +730,16 @@ class ReportGenerator(IReportGenerator):
|
||||
}
|
||||
)
|
||||
|
||||
# 通用模板上下文,包含可能被子模板引用的全局配置
|
||||
common_context = {
|
||||
"t2i_font_source": self.config_manager.get_t2i_font_source(),
|
||||
"t2i_google_fonts_mirror": self.config_manager.get_t2i_google_fonts_mirror(),
|
||||
"t2i_gstatic_mirror": self.config_manager.get_t2i_gstatic_mirror(),
|
||||
"t2i_atri_font_mirror": self.config_manager.get_t2i_atri_font_mirror(),
|
||||
}
|
||||
|
||||
topics_html = self.html_templates.render_template(
|
||||
"topic_item.html", topics=topics_list
|
||||
"topic_item.html", topics=topics_list, **common_context
|
||||
)
|
||||
logger.info(f"话题HTML生成完成,长度: {len(topics_html)}")
|
||||
|
||||
@@ -766,7 +774,7 @@ class ReportGenerator(IReportGenerator):
|
||||
titles_list.append(title_data)
|
||||
|
||||
titles_html = self.html_templates.render_template(
|
||||
"user_title_item.html", titles=titles_list
|
||||
"user_title_item.html", titles=titles_list, **common_context
|
||||
)
|
||||
logger.info(f"用户称号HTML生成完成,长度: {len(titles_html)}")
|
||||
|
||||
@@ -813,7 +821,7 @@ class ReportGenerator(IReportGenerator):
|
||||
)
|
||||
|
||||
quotes_html = self.html_templates.render_template(
|
||||
"quote_item.html", quotes=quotes_list
|
||||
"quote_item.html", quotes=quotes_list, **common_context
|
||||
)
|
||||
logger.info(f"金句HTML生成完成,长度: {len(quotes_html)}")
|
||||
|
||||
@@ -822,7 +830,7 @@ class ReportGenerator(IReportGenerator):
|
||||
activity_viz.hourly_activity
|
||||
)
|
||||
hourly_chart_html = self.html_templates.render_template(
|
||||
chart_template, chart_data=chart_data
|
||||
chart_template, chart_data=chart_data, **common_context
|
||||
)
|
||||
logger.info(f"活跃度图表HTML生成完成,长度: {len(hourly_chart_html)}")
|
||||
|
||||
@@ -853,7 +861,7 @@ class ReportGenerator(IReportGenerator):
|
||||
review_data = chat_quality_review
|
||||
|
||||
chat_quality_html = self.html_templates.render_template(
|
||||
"chat_quality_item.html", **review_data
|
||||
"chat_quality_item.html", **review_data, **common_context
|
||||
)
|
||||
logger.info(f"聊天质量锐评HTML生成完成,长度: {len(chat_quality_html)}")
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{% set quote_emojis = [
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132814629_1774881270686_爱心.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132815504_1774881268554_可爱.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132809943_1774881264350_睡觉.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775175892953_1774881267664_舔屏幕.gif'
|
||||
{% set quote_emojis = [
|
||||
t2i_atri_font_mirror ~ '/file/1775132814629_1774881270686_爱心.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132815504_1774881268554_可爱.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132809943_1774881264350_睡觉.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775175892953_1774881267664_舔屏幕.gif'
|
||||
] %}
|
||||
{% for quote in quotes %}
|
||||
<div class="quote-wrapper">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{% set topic_emojis = [
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132804506_1774881263342_观察.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132805081_1774881262835_疑惑.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132815504_1774881268554_可爱.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132817115_1774881269400_可爱-1.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132805485_1774881263748_可爱-3.gif'
|
||||
{% set topic_emojis = [
|
||||
t2i_atri_font_mirror ~ '/file/1775132804506_1774881263342_观察.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132805081_1774881262835_疑惑.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132815504_1774881268554_可爱.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132817115_1774881269400_可爱-1.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132805485_1774881263748_可爱-3.gif'
|
||||
] %}
|
||||
{% set topic_rank_colors = [
|
||||
{'bg': 'linear-gradient(135deg, #a9d8ff 0%, #8fc5ff 48%, #8aaeff 100%)', 'text': '#ffffff', 'shadow': 'rgba(126, 177,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{% set title_emojis = [
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132813334_1774881267181_得意.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132808652_1774881267385_得意-1.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132804506_1774881263342_观察.gif',
|
||||
'{{ t2i_atri_font_mirror }}/file/1775132811492_1774881264336_不要.gif'
|
||||
{% set title_emojis = [
|
||||
t2i_atri_font_mirror ~ '/file/1775132813334_1774881267181_得意.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132808652_1774881267385_得意-1.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132804506_1774881263342_观察.gif',
|
||||
t2i_atri_font_mirror ~ '/file/1775132811492_1774881264336_不要.gif'
|
||||
] %}
|
||||
{% set title_badge_colors = [
|
||||
{'bg': 'linear-gradient(135deg, #ffcadf 0%, #ffc1cc 45%, #ffd9b8 100%)', 'text': '#b85c7b', 'shadow': 'rgba(255, 177, 203, 0.28)', 'border': 'rgba(255, 184, 210, 0.72)'},
|
||||
|
||||
Reference in New Issue
Block a user