From d8b1df6c26af61f0f830693160a314d37ab75276 Mon Sep 17 00:00:00 2001 From: GeorgeDong32 Date: Wed, 17 Dec 2025 23:57:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=99=BE=E5=BA=A6?= =?UTF-8?q?=E4=BA=91=E5=BC=95=E7=94=A8=E6=A0=BC=E5=BC=8F=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复百度云千帆模型返回消息中^[x]^引用格式的转换问题。修正正则表达式,正确解析方括号内的数字组合,并转换为标准[cite:N]格式。 相关Issue: cherry-studio/issues/11958 --- src/renderer/src/utils/citation.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/renderer/src/utils/citation.ts b/src/renderer/src/utils/citation.ts index c4231c72c..7d4f0737a 100644 --- a/src/renderer/src/utils/citation.ts +++ b/src/renderer/src/utils/citation.ts @@ -156,13 +156,15 @@ export function normalizeCitationMarks( break } case WebSearchSource.BAIDU_CLOUD: { - // 百度云格式: ^[1][4]^ → [cite:1], [cite:4] - applyReplacements(/\^\[(\d+(?:\]\[?\d+)*)\]\^/g, (match) => { - const citationNums = match[1] - .replace(/^\[/, '') - .replace(/\]$/g, '') + // 百度云格式: ^[1][4]^ → [cite:1][cite:4] + applyReplacements(/\^\[([^\]]+)\]\^/g, (match) => { + // match[1]包含方括号内的内容,如 "1][4" + const content = match[1] + // 解析方括号内的数字,如 "1][4" -> ['1', '4'] + const citationNums = content .split('][') .map((num) => parseInt(num, 10)) + .filter((num) => !isNaN(num)) const citations = citationNums .filter((num) => citationMap.has(num))