From e490f1bceaef0d66a2787616f5a5b9d0031a0083 Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Fri, 28 Mar 2025 10:38:46 +0800 Subject: [PATCH] fix(video-embed): refactor URL generation and prevent Bilibili autoplay --- src/components/content/video-embed.tsx | 30 +++++++++++--------------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/components/content/video-embed.tsx b/src/components/content/video-embed.tsx index 09dedc9..472d5f0 100644 --- a/src/components/content/video-embed.tsx +++ b/src/components/content/video-embed.tsx @@ -3,25 +3,19 @@ interface VideoEmbedProps { id: string; } -const platformSrcMap: Record = { - youtube: "https://www.youtube.com/embed/", - bilibili: "https://player.bilibili.com/player.html?bvid=", -}; - -export function VideoEmbed({ - platform, - id, -}: VideoEmbedProps) { - const src = platformSrcMap[platform] + id; +const platformSrcMap = { + youtube: (id: string) => `https://www.youtube.com/embed/${id}`, + bilibili: (id: string) => + `https://player.bilibili.com/player.html?bvid=${id}&autoplay=0`, +} as const; +export function VideoEmbed({ platform, id }: VideoEmbedProps) { return ( -
-