From 3984b6315df34d78df0e312a31ad322b531fc4be Mon Sep 17 00:00:00 2001 From: shinya Date: Tue, 24 Jun 2025 00:01:50 +0800 Subject: [PATCH] feat: all in on player --- src/app/globals.css | 4 ++ src/app/play/page.tsx | 97 +++++++++++++++++++++++++++++++++++-------- 2 files changed, 83 insertions(+), 18 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index 3e08c2f..15914dc 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -99,3 +99,7 @@ body { background-repeat: no-repeat !important; /* 防止重复 */ background-color: #000 !important; /* 其余区域填充为黑色 */ } + +.art-video-player .art-layers { + z-index: 100 !important; +} diff --git a/src/app/play/page.tsx b/src/app/play/page.tsx index 6be6677..005fa3e 100644 --- a/src/app/play/page.tsx +++ b/src/app/play/page.tsx @@ -113,6 +113,11 @@ function PlayPageClient() { Hls: any | null; }>({ Artplayer: null, Hls: null }); + // 新增:业务层容器引用 + const topLayerRef = useRef(null); + const episodeLayerRef = useRef(null); + const sourceLayerRef = useRef(null); + // 解决 iOS Safari 100vh 不准确的问题:将视口高度写入 CSS 变量 --vh useEffect(() => { const setVH = () => { @@ -518,9 +523,6 @@ function PlayPageClient() { html: '选集', tooltip: '选择集数', click: function () { - if (artPlayerRef.current && artPlayerRef.current.fullscreen) { - artPlayerRef.current.fullscreen = false; - } setShowEpisodePanel(true); }, }, @@ -574,6 +576,47 @@ function PlayPageClient() { videoUrl ); } + + // ===== 在创建完成后,注入业务层并搬运 DOM ===== + const topLayerEl = document.createElement('div'); + const episodeLayerEl = document.createElement('div'); + const sourceLayerEl = document.createElement('div'); + + artPlayerRef.current.layers.add({ + name: 'topbar', + html: topLayerEl, + index: 3, + }); + artPlayerRef.current.layers.add({ + name: 'episodepanel', + html: episodeLayerEl, + index: 2, + }); + artPlayerRef.current.layers.add({ + name: 'sourcepanel', + html: sourceLayerEl, + index: 1, + }); + + topLayerRef.current = topLayerEl; + episodeLayerRef.current = episodeLayerEl; + sourceLayerRef.current = sourceLayerEl; + + // 将现有节点移动到对应业务层容器 + setTimeout(() => { + const topDom = document.querySelector('[data-top-bar]'); + if (topDom && !topLayerEl.contains(topDom)) { + topLayerEl.appendChild(topDom as HTMLElement); + } + const episodeDom = document.querySelector('[data-episode-panel]'); + if (episodeDom && !episodeLayerEl.contains(episodeDom)) { + episodeLayerEl.appendChild(episodeDom as HTMLElement); + } + const sourceDom = document.querySelector('[data-source-panel]'); + if (sourceDom && !sourceLayerEl.contains(sourceDom)) { + sourceLayerEl.appendChild(sourceDom as HTMLElement); + } + }, 0); } catch (err) { console.error('创建播放器失败:', err); setError('播放器初始化失败'); @@ -1358,7 +1401,8 @@ function PlayPageClient() { {/* 顶栏 */}
@@ -1395,12 +1439,7 @@ function PlayPageClient() { }} className='flex-shrink-0' > - +
@@ -1500,18 +1539,18 @@ function PlayPageClient() { {/* 选集侧拉面板 */} {totalEpisodes > 1 && ( - <> +
{/* 遮罩层 */} {showEpisodePanel && (
setShowEpisodePanel(false)} /> )} {/* 侧拉面板 */}
@@ -1561,22 +1600,22 @@ function PlayPageClient() {
- + )} {/* 换源侧拉面板 */} - <> +
{/* 遮罩层 */} {showSourcePanel && (
setShowSourcePanel(false)} /> )} {/* 侧拉面板 */}
@@ -1706,11 +1745,33 @@ function PlayPageClient() {
- + ); } +const FavoriteIcon = ({ filled }: { filled: boolean }) => { + if (filled) { + return ( + + + + ); + } + return ; +}; + export default function PlayPage() { return (