fix(ai): 修复分析结果 JSON 嵌套 bug
- replay_cached 直接回放纯文本,不再包装 JSON 壳 - complete_analysis 跳过已完成的记录,防止缓存命中时覆写 - 前端 AnalysisContent 增加 extractPlainText 递归解析 JSON
This commit is contained in:
@@ -60,9 +60,23 @@ const SUGGESTION_STATUS_CONFIG: Record<string, { color: string; text: string }>
|
||||
// 分析结果渲染(Markdown 风格)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** 递归提取 JSON 嵌套中的实际文本内容 */
|
||||
function extractPlainText(raw: string): string {
|
||||
try {
|
||||
const parsed = JSON.parse(raw);
|
||||
if (typeof parsed === 'object' && parsed !== null && typeof parsed.content === 'string') {
|
||||
return extractPlainText(parsed.content);
|
||||
}
|
||||
return raw;
|
||||
} catch {
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
||||
function AnalysisContent({ content, isDark }: { content: string; isDark: boolean }) {
|
||||
const text = extractPlainText(content);
|
||||
// 简单的 Markdown 风格渲染
|
||||
const lines = content.split('\n');
|
||||
const lines = text.split('\n');
|
||||
const rendered = lines.map((line, i) => {
|
||||
// 标题行
|
||||
if (line.startsWith('### ')) {
|
||||
|
||||
Reference in New Issue
Block a user