diff --git a/xinli-ui/src/views/psychology/report/detail.vue b/xinli-ui/src/views/psychology/report/detail.vue index 1413ca88..ea3b77b8 100644 --- a/xinli-ui/src/views/psychology/report/detail.vue +++ b/xinli-ui/src/views/psychology/report/detail.vue @@ -346,7 +346,7 @@ export default { '1. 提取报告的核心信息和关键指标;', '2. 分析测评结果的含义和可能的影响;', '3. 提供专业、客观、易懂的分析解读(500-800字);', - '4. 使用结构化的格式输出,包含:核心结论、详细分析、建议等部分;', + '4. 使用结构化的格式输出,包含:核心结论、详细分析、建议、总体结论四个部分;', '5. 仅输出分析结果,不添加额外建议、问候语或思考过程;', '6. 使用HTML格式输出,使用

标签作为小标题,

标签作为段落。' ].join('\n'); @@ -380,6 +380,10 @@ export default { .replace(/[\s\S]*?<\/redacted_reasoning>/gi, '') .replace(//gi, '') .replace(//gi, '') + // 移除Markdown代码块标记 + .replace(/```html\s*/gi, '') + .replace(/```\s*/g, '') + .replace(/```[a-z]*\s*/gi, '') .trim(); if (!rawResponse || rawResponse === '无法解析模型输出') { @@ -407,13 +411,19 @@ export default { }, /** 格式化AI分析结果 */ formatAIResult(text) { - // 如果已经是HTML格式,直接返回 - if (text.includes('

') || text.includes('

')) { - return text; - } + // 移除Markdown代码块标记(```html、```等) + let html = text + .replace(/```html\s*/gi, '') + .replace(/```\s*/g, '') + .replace(/```[a-z]*\s*/gi, '') + .trim(); - // 将文本转换为HTML格式 - let html = text; + // 如果已经是HTML格式,清理后返回 + if (html.includes('

') || html.includes('

') || html.includes('

')) { + // 移除可能残留的代码块标记 + html = html.replace(/```html\s*/gi, '').replace(/```\s*/g, ''); + return html; + } // 处理标题(以数字开头或包含"结论"、"分析"、"建议"等关键词的行) html = html.replace(/^(\d+[\.、]?\s*[^\n]+)$/gm, '

$1

'); @@ -433,6 +443,9 @@ export default { return match; }); + // 最后再次清理可能残留的代码块标记 + html = html.replace(/```html\s*/gi, '').replace(/```\s*/g, ''); + return html; } }