fix: add functions to handle and strip Deep Seek link icon nodes
Frontend CI / Frontend (push) Successful in 2m50s

This commit is contained in:
2026-06-30 16:23:33 +08:00
parent ced0c4ec0f
commit eb4d870081
@@ -647,6 +647,35 @@ function shouldStripDeepSeekOrphanAnchor(anchor: HTMLAnchorElement): boolean {
)
}
function isDeepSeekLinkIconSvg(svg: SVGElement): boolean {
const viewBox = svg.getAttribute('viewBox')?.trim() ?? ''
const width = svg.getAttribute('width')?.trim() ?? ''
const height = svg.getAttribute('height')?.trim() ?? ''
const paths = Array.from(svg.querySelectorAll('path'))
return (
viewBox === '0 0 14 14' &&
width === '14' &&
height === '14' &&
paths.length === 2 &&
paths.every((path) => path.getAttribute('fill') === 'currentColor')
)
}
function stripDeepSeekLinkIconNodes(root: HTMLElement): void {
for (const svg of Array.from(root.querySelectorAll<SVGElement>('svg'))) {
if (!isDeepSeekLinkIconSvg(svg)) {
continue
}
const parent = svg.parentElement
const parentText = parent?.textContent?.trim() ?? ''
if (parent && parent !== root && parent.children.length === 1 && parentText === '') {
parent.remove()
continue
}
svg.remove()
}
}
function collectDeepSeekCitationReferenceLabels(
platform: MonitoringQuestionDetailPlatform | null,
): string[][] {
@@ -970,6 +999,8 @@ function renderDeepSeekAnswerContent(
const fallbackLabels = new Map<string, string>()
const fallbackState = { nextIndex: 1 }
stripDeepSeekLinkIconNodes(root)
for (const anchor of Array.from(root.querySelectorAll<HTMLAnchorElement>('a[href], a'))) {
const rawHref = anchor.hasAttribute('href')
? anchor.getAttribute('href') || anchor.href || ''