diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 96ac487..9aa328e 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -40,6 +40,10 @@ export async function generateMetadata(): Promise { title: siteName, description: '影视聚合', manifest: '/manifest.json', + // 供配套浏览器扩展(moontvplus-extension)识别本站部署(勿删) + other: { + 'moontvplus-site': '1', + }, // iOS 添加到主屏幕:沉浸式状态栏(需配合 viewport-fit=cover + 顶部 safe-area) appleWebApp: { capable: true, @@ -336,8 +340,10 @@ export default async function RootLayout({ }; return ( - + + {/* 配套 moontvplus-extension 识别指纹;仅本项目部署站应带此标记 */} + { + if (!source) return false; + return ( + source === 'openlist' || + source === 'xiaoya' || + source === 'emby' || + source.startsWith('emby_') + ); + }; + + const applyVideoCrossOrigin = ( + video: HTMLVideoElement | null, + source?: string | null + ) => { + if (!video) return; + if (needsPrivateSourceCrossOrigin(source ?? currentSourceRef.current)) { + if (video.crossOrigin !== 'anonymous') { + video.crossOrigin = 'anonymous'; + } + } else if (video.crossOrigin) { + // 切回普通源时去掉,避免无 CORS 的 CDN 在 CORS 模式下播挂 + video.crossOrigin = null; + } + }; + const isM3u8LikeUrl = (url?: string) => { if (!url) return false; const normalizedUrl = url.toLowerCase(); @@ -3785,6 +3811,9 @@ function PlayPageClient() { // 使用 property 方式也设置一次,确保兼容性 (video as any).playsInline = true; (video as any).webkitPlaysInline = true; + + // openlist/emby/xiaoya:CORS 模式加载,需配套「moontvplus 扩展」注入 ACAO 后 Anime4K 才能读帧 + applyVideoCrossOrigin(video, currentSourceRef.current); }; // Wake Lock 相关函数 @@ -6838,6 +6867,13 @@ function PlayPageClient() { } else { artPlayerRef.current.option.type = ''; } + // switch 前先对齐 crossOrigin,避免私人影库直链以非 CORS 模式缓存后无法超分 + if (artPlayerRef.current?.video) { + applyVideoCrossOrigin( + artPlayerRef.current.video as HTMLVideoElement, + currentSourceRef.current + ); + } artPlayerRef.current.switch = videoUrl; artPlayerRef.current.title = `${videoTitle} - ${playerEpisodeLabel}`; artPlayerRef.current.poster = videoCover; @@ -7078,6 +7114,10 @@ function PlayPageClient() { playsInline: true, 'webkit-playsinline': 'true', referrerpolicy: 'no-referrer', + // 私人影库跨域直链:配合同级 moontvplus-extension 注入 ACAO,供 Anime4K 读帧 + ...(needsPrivateSourceCrossOrigin(currentSourceRef.current) + ? { crossOrigin: 'anonymous' } + : {}), } as any, // HLS 支持配置 customType: {