From 50ea5593832e2e0d962619bbe0fa3b21ffd2a024 Mon Sep 17 00:00:00 2001 From: "Luke.Ye" Date: Mon, 14 Jul 2025 06:14:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=BC=95=E7=94=A8=E6=9D=90?= =?UTF-8?q?=E6=96=99=E5=8E=BB=E9=87=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/llm.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/scripts/llm.js b/scripts/llm.js index c4baa79..bb2e33b 100644 --- a/scripts/llm.js +++ b/scripts/llm.js @@ -60,21 +60,25 @@ async function renderSources(sourceList, sources, jumpMap) { ul.style.listStyle = "disc"; ul.style.fontSize = "14px"; + // ====== 新增去重处理 ====== + const seen = new Set(); for (const src of sources) { const url = jumpMap[src.title]; + const title = src.title || "未命名文档"; + const scoreText = (typeof src.score === "number") ? `(相似度:${(src.score * 100).toFixed(2)}%)` : ""; + + const key = title + "|" + (url || ""); + if (seen.has(key)) continue; // 跳过重复 + seen.add(key); + const li = document.createElement("li"); li.style.marginBottom = "3px"; li.style.lineHeight = "1.7"; - let scoreText = ""; - if (typeof src.score === "number") { - scoreText = `(相似度:${(src.score * 100).toFixed(2)}%)`; - } - if (url) { const link = document.createElement("a"); link.href = url; - link.textContent = src.title || "未命名文档"; + link.textContent = title; link.target = "_blank"; link.style.color = "#2560de"; link.style.textDecoration = "none"; @@ -91,15 +95,18 @@ async function renderSources(sourceList, sources, jumpMap) { li.appendChild(scoreSpan); } } else { - li.textContent = (src.title || "未命名文档") + (scoreText ? " " + scoreText : ""); + li.textContent = title + (scoreText ? " " + scoreText : ""); li.style.color = "#666"; } ul.appendChild(li); } + // ====== 去重处理结束 ====== + sourceList.appendChild(ul); } + // === 复制代码块功能 === function wrapHtmlWithCopyBtn(html) { const wrapper = document.createElement('div');