diff --git a/css/style.css b/css/style.css
index 5cce7a8..f0726b0 100644
--- a/css/style.css
+++ b/css/style.css
@@ -39,6 +39,111 @@ body {
box-shadow: 2px 2px 0 rgba(16, 185, 129, 0.3);
}
+/* Markdown样式 */
+.chat-bubble-ai h1 {
+ font-size: 1.5em;
+ font-weight: bold;
+ margin: 0.5em 0;
+ color: #1f2937;
+}
+
+.chat-bubble-ai h2 {
+ font-size: 1.3em;
+ font-weight: bold;
+ margin: 0.5em 0;
+ color: #1f2937;
+}
+
+.chat-bubble-ai h3 {
+ font-size: 1.1em;
+ font-weight: bold;
+ margin: 0.5em 0;
+ color: #1f2937;
+}
+
+.chat-bubble-ai p {
+ margin: 0.5em 0;
+ line-height: 1.5;
+}
+
+.chat-bubble-ai ul, .chat-bubble-ai ol {
+ margin: 0.5em 0;
+ padding-left: 1.5em;
+}
+
+.chat-bubble-ai li {
+ margin: 0.25em 0;
+ line-height: 1.4;
+}
+
+.chat-bubble-ai code {
+ background: #f3f4f6;
+ padding: 0.2em 0.4em;
+ border-radius: 3px;
+ font-family: 'Courier New', monospace;
+ font-size: 0.9em;
+ color: #e11d48;
+}
+
+.chat-bubble-ai pre {
+ background: #f9fafb;
+ border: 1px solid #e5e7eb;
+ border-radius: 4px;
+ padding: 0.75em;
+ overflow-x: auto;
+ margin: 0.5em 0;
+}
+
+.chat-bubble-ai pre code {
+ background: none;
+ padding: 0;
+ color: #1f2937;
+}
+
+.chat-bubble-ai blockquote {
+ border-left: 4px solid #d1d5db;
+ padding-left: 1em;
+ margin: 0.5em 0;
+ color: #6b7280;
+ font-style: italic;
+}
+
+.chat-bubble-ai strong {
+ font-weight: bold;
+ color: #1f2937;
+}
+
+.chat-bubble-ai em {
+ font-style: italic;
+ color: #4b5563;
+}
+
+.chat-bubble-ai a {
+ color: #3b82f6;
+ text-decoration: underline;
+}
+
+.chat-bubble-ai a:hover {
+ color: #1d4ed8;
+}
+
+.chat-bubble-ai table {
+ border-collapse: collapse;
+ width: 100%;
+ margin: 0.5em 0;
+}
+
+.chat-bubble-ai th, .chat-bubble-ai td {
+ border: 1px solid #e5e7eb;
+ padding: 0.5em;
+ text-align: left;
+}
+
+.chat-bubble-ai th {
+ background: #f9fafb;
+ font-weight: bold;
+}
+
/* SVG占位符样式 - 块级换行 + 新配色 */
.svg-placeholder-block {
display: block;
diff --git a/index.html b/index.html
index 1859cda..22c6bcf 100644
--- a/index.html
+++ b/index.html
@@ -6,6 +6,7 @@
- ${Utils.escapeHtml(beforeText)}
+ ${parsedBeforeText}
🎨 正在绘制${this.currentMode === 'canvas' ? '产品画布' : 'SWOT分析'}...
@@ -375,14 +395,18 @@ class ProductCanvasApp {
// 更新SVG后的消息内容
updateStreamingMessageAfterSVG(container, beforeText, svgId, afterText) {
+ // 使用Markdown解析文本
+ const parsedBeforeText = typeof marked !== 'undefined' ? marked.parse(beforeText) : Utils.escapeHtml(beforeText);
+ const parsedAfterText = typeof marked !== 'undefined' ? marked.parse(afterText) : Utils.escapeHtml(afterText);
+
container.innerHTML = `
- ${Utils.escapeHtml(beforeText)}
+ ${parsedBeforeText}
📊 点击查看${this.currentMode === 'canvas' ? '产品画布' : 'SWOT分析'} SVG
-
${Utils.escapeHtml(afterText)}
+
${parsedAfterText}
`;
@@ -412,14 +436,18 @@ class ProductCanvasApp {
afterText = fullContent.substring(svgEndIndex);
}
+ // 使用Markdown解析文本
+ const parsedBeforeText = typeof marked !== 'undefined' ? marked.parse(beforeText) : Utils.escapeHtml(beforeText);
+ const parsedAfterText = typeof marked !== 'undefined' ? marked.parse(afterText) : Utils.escapeHtml(afterText);
+
// 更新容器内容为包含SVG的消息
container.innerHTML = `
- ${Utils.escapeHtml(beforeText)}
+ ${parsedBeforeText}
📊 点击查看 ${this.currentMode === 'canvas' ? '产品画布' : 'SWOT分析'} SVG
- ${Utils.escapeHtml(afterText)}
+ ${parsedAfterText}
@@ -449,14 +477,18 @@ class ProductCanvasApp {
this.viewSVG(newSvgId);
+ // 使用Markdown解析文本
+ const parsedBeforeText = typeof marked !== 'undefined' ? marked.parse(parsed.beforeText) : Utils.escapeHtml(parsed.beforeText);
+ const parsedAfterText = typeof marked !== 'undefined' ? marked.parse(parsed.afterText) : Utils.escapeHtml(parsed.afterText);
+
// 更新容器内容为包含SVG的消息
container.innerHTML = `
- ${Utils.escapeHtml(parsed.beforeText)}
+ ${parsedBeforeText}
📊 点击查看 ${this.currentMode === 'canvas' ? '产品画布' : 'SWOT分析'} SVG
- ${Utils.escapeHtml(parsed.afterText)}
+ ${parsedAfterText}
@@ -471,10 +503,13 @@ class ProductCanvasApp {
`;
} else {
+ // 使用Markdown解析内容
+ const parsedContent = typeof marked !== 'undefined' ? marked.parse(fullContent) : Utils.escapeHtml(fullContent);
+
// 更新容器内容为普通消息
container.innerHTML = `
- ${Utils.escapeHtml(fullContent)}
+ ${parsedContent}
@@ -629,7 +664,7 @@ class ProductCanvasApp {
messageDiv.innerHTML = `
- ${Utils.escapeHtml(message.content)}
+ ${typeof marked !== 'undefined' ? marked.parse(message.content) : Utils.escapeHtml(message.content)}
@@ -656,11 +691,11 @@ class ProductCanvasApp {
messageDiv.innerHTML = `
- ${Utils.escapeHtml(parsed.beforeText)}
+ ${typeof marked !== 'undefined' ? marked.parse(parsed.beforeText) : Utils.escapeHtml(parsed.beforeText)}
📊 点击查看 ${this.currentMode === 'canvas' ? '产品画布' : 'SWOT分析'} SVG
- ${Utils.escapeHtml(parsed.afterText)}
+ ${typeof marked !== 'undefined' ? marked.parse(parsed.afterText) : Utils.escapeHtml(parsed.afterText)}