From 40d64f129313f26133e427c3707101c91c95bb82 Mon Sep 17 00:00:00 2001 From: TerryM Date: Sat, 30 May 2026 15:43:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=93=BE=E6=8E=A5=E9=A2=84=E8=A7=88?= =?UTF-8?q?=E5=BC=BA=E8=B0=83=E8=89=B2=E6=8C=89=E5=9F=9F=E5=90=8D=E5=85=9C?= =?UTF-8?q?=E5=BA=95,=E8=85=BE=E8=AE=AF=E4=BC=9A=E8=AE=AE=E4=B8=8D?= =?UTF-8?q?=E5=86=8D=E7=94=A8=E9=BB=91=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 部分站点(如 meeting.tencent.com)返回 themeColor=#000000,在深色气泡上看不见。 按域名覆盖为品牌金色,其余仍优先用 themeColor。 Co-Authored-By: Claude Opus 4.8 (1M context) --- .../messageStream/LinkPreviewCard.tsx | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/components/messageStream/LinkPreviewCard.tsx b/src/components/messageStream/LinkPreviewCard.tsx index 3858464..d10a5a1 100644 --- a/src/components/messageStream/LinkPreviewCard.tsx +++ b/src/components/messageStream/LinkPreviewCard.tsx @@ -1,5 +1,27 @@ import type { LinkPreview } from "../../types/post"; +const LINK_ACCENT = "#eeb726"; + +const DOMAIN_ACCENT_OVERRIDES: Array<[string, string]> = [ + // Tencent Meeting returns themeColor="#000000", which disappears on the + // dark bubble surface. Keep it consistent with inline link color instead. + ["meeting.tencent.com", LINK_ACCENT], +]; + +function linkPreviewAccent(preview: LinkPreview): string { + const url = preview.canonicalUrl || preview.url; + try { + const host = new URL(url).hostname.replace(/^www\./, ""); + const match = DOMAIN_ACCENT_OVERRIDES.find( + ([domain]) => host === domain || host.endsWith(`.${domain}`), + ); + if (match) return match[1]; + } catch { + // Ignore malformed preview URLs and fall back below. + } + return preview.themeColor || LINK_ACCENT; +} + /** * Telegram-style rich preview card for a single URL embedded in a post. * @@ -8,7 +30,7 @@ import type { LinkPreview } from "../../types/post"; * that opens `canonicalUrl` in a new tab. */ export function LinkPreviewCard({ preview }: { preview: LinkPreview }) { - const accent = preview.themeColor || "#EEB726"; + const accent = linkPreviewAccent(preview); const hasUsefulText = preview.title.length > 0 || preview.description.length > 0; if (!hasUsefulText && !preview.imageUrl) return null;