From d2e29d953703d08263f1a8254ab941bac820e458 Mon Sep 17 00:00:00 2001 From: xiao12feng Date: Thu, 20 Nov 2025 11:51:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DAI=E5=88=86=E6=9E=90=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E4=B8=AD=E6=98=BE=E7=A4=BA=E5=A4=9A=E4=BD=99=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E5=9D=97=E6=A0=87=E8=AE=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/psychology/report/detail.vue | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) 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; } }