fix: restore responsive sizing for infographic

This commit is contained in:
fujie
2026-01-07 07:32:59 +08:00
parent 6eb09c3eaa
commit ba7943bd6f
2 changed files with 28 additions and 8 deletions

View File

@@ -981,10 +981,20 @@ class Action:
const defaultWidth = 1100;
const defaultHeight = 500;
// Use fixed dimensions for consistent rendering (avoid title wrapping issues)
const svgWidth = defaultWidth;
const svgHeight = defaultHeight;
console.log("[Infographic Image] Using fixed dimensions:", svgWidth, "x", svgHeight);
// Auto-detect chat container width for responsive sizing
let svgWidth = defaultWidth;
let svgHeight = defaultHeight;
const chatContainer = document.getElementById('chat-container');
if (chatContainer) {{
const containerWidth = chatContainer.clientWidth;
if (containerWidth > 100) {{
// Use container width with padding (80% of container, leaving more space on the right)
svgWidth = Math.floor(containerWidth * 0.8);
// Maintain aspect ratio based on default dimensions
svgHeight = Math.floor(svgWidth * (defaultHeight / defaultWidth));
console.log("[Infographic Image] Auto-detected container width:", containerWidth, "-> SVG:", svgWidth, "x", svgHeight);
}}
}}
console.log("[Infographic Image] Starting render...");
console.log("[Infographic Image] chatId:", chatId, "messageId:", messageId);