From e63dce28086339d305582d458479f754bb0a0213 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=94=A1=E6=B5=A9=E6=B6=B5?= Date: Sun, 11 Jan 2026 14:34:33 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=A7=BB=E9=99=A4=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E8=AF=A6=E6=83=85=E9=A1=B5=E7=9A=84=E5=9B=BE=E7=89=87?= =?UTF-8?q?/=E8=A7=86=E9=A2=91=E6=98=BE=E7=A4=BA=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 由于 source 字段语义不清且容易产生 CSP 错误,暂时移除 图片和视频的显示功能,待后续设计更完善的图片管理方案 --- src/components/project/ProjectDetail.tsx | 62 ------------------------ 1 file changed, 62 deletions(-) diff --git a/src/components/project/ProjectDetail.tsx b/src/components/project/ProjectDetail.tsx index 1de0670..299c781 100644 --- a/src/components/project/ProjectDetail.tsx +++ b/src/components/project/ProjectDetail.tsx @@ -48,48 +48,6 @@ function formatDate(date: Date | string, locale: string): string { } } -// Helper function to check if URL is an image -function isImageUrl(url: string): boolean { - const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.webp', '.svg', '.bmp'] - const lowerUrl = url.toLowerCase() - return imageExtensions.some(ext => lowerUrl.includes(ext)) -} - -// Helper function to check if URL can be embedded in iframe -// Many sites like GitHub, Google, etc. block iframe embedding via CSP -function isEmbeddableUrl(url: string): boolean { - const hostname = new URL(url).hostname.toLowerCase() - - // Whitelist of domains that allow iframe embedding - const embeddableDomains = [ - 'youtube.com', - 'youtu.be', - 'vimeo.com', - 'player.vimeo.com', - 'drive.google.com', - 'docs.google.com', - 'www.figma.com', - 'codepen.io', - 'jsfiddle.net', - 'codesandbox.io', - 'stackblitz.com', - 'replit.com', - 'loom.com', - 'wistia.com', - 'brightcove.com', - 'dailymotion.com', - 'twitch.tv', - 'soundcloud.com', - 'spotify.com', - 'canva.com', - 'notion.so', - 'typeform.com', - ] - - // Check if hostname matches any embeddable domain - return embeddableDomains.some((domain) => hostname === domain || hostname.endsWith('.' + domain)) -} - export async function ProjectDetail({ project, locale }: ProjectDetailProps) { const t = await getTranslations('project') @@ -149,26 +107,6 @@ export async function ProjectDetail({ project, locale }: ProjectDetailProps) { ))} - - {/* Featured Image/Video Placeholder - only show if source exists */} - {project.source && ( -
- {isImageUrl(project.source) ? ( - {`${displayName} - ) : isEmbeddableUrl(project.source) ? ( -