完成引用材料去重
This commit is contained in:
parent
6ec619ec79
commit
50ea559383
@ -60,21 +60,25 @@ async function renderSources(sourceList, sources, jumpMap) {
|
|||||||
ul.style.listStyle = "disc";
|
ul.style.listStyle = "disc";
|
||||||
ul.style.fontSize = "14px";
|
ul.style.fontSize = "14px";
|
||||||
|
|
||||||
|
// ====== 新增去重处理 ======
|
||||||
|
const seen = new Set();
|
||||||
for (const src of sources) {
|
for (const src of sources) {
|
||||||
const url = jumpMap[src.title];
|
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");
|
const li = document.createElement("li");
|
||||||
li.style.marginBottom = "3px";
|
li.style.marginBottom = "3px";
|
||||||
li.style.lineHeight = "1.7";
|
li.style.lineHeight = "1.7";
|
||||||
|
|
||||||
let scoreText = "";
|
|
||||||
if (typeof src.score === "number") {
|
|
||||||
scoreText = `(相似度:${(src.score * 100).toFixed(2)}%)`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url) {
|
if (url) {
|
||||||
const link = document.createElement("a");
|
const link = document.createElement("a");
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.textContent = src.title || "未命名文档";
|
link.textContent = title;
|
||||||
link.target = "_blank";
|
link.target = "_blank";
|
||||||
link.style.color = "#2560de";
|
link.style.color = "#2560de";
|
||||||
link.style.textDecoration = "none";
|
link.style.textDecoration = "none";
|
||||||
@ -91,15 +95,18 @@ async function renderSources(sourceList, sources, jumpMap) {
|
|||||||
li.appendChild(scoreSpan);
|
li.appendChild(scoreSpan);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
li.textContent = (src.title || "未命名文档") + (scoreText ? " " + scoreText : "");
|
li.textContent = title + (scoreText ? " " + scoreText : "");
|
||||||
li.style.color = "#666";
|
li.style.color = "#666";
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.appendChild(li);
|
ul.appendChild(li);
|
||||||
}
|
}
|
||||||
|
// ====== 去重处理结束 ======
|
||||||
|
|
||||||
sourceList.appendChild(ul);
|
sourceList.appendChild(ul);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// === 复制代码块功能 ===
|
// === 复制代码块功能 ===
|
||||||
function wrapHtmlWithCopyBtn(html) {
|
function wrapHtmlWithCopyBtn(html) {
|
||||||
const wrapper = document.createElement('div');
|
const wrapper = document.createElement('div');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user