From 01e2514650c39d9a9a1b460ec95f24e8e4ad8a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8C=97=E6=9E=B3?= <7854742+wang_rumeng@user.noreply.gitee.com> Date: Thu, 9 Oct 2025 20:22:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BA=E5=88=86=20Edge=20=E6=B5=8F=E8=A7=88?= =?UTF-8?q?=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/pages/work-flow/H5MediaViewer.tsx | 21 +++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/components/pages/work-flow/H5MediaViewer.tsx b/components/pages/work-flow/H5MediaViewer.tsx index 631d107..d159c9d 100644 --- a/components/pages/work-flow/H5MediaViewer.tsx +++ b/components/pages/work-flow/H5MediaViewer.tsx @@ -226,6 +226,7 @@ export function H5MediaViewer({ const [activeIndex, setActiveIndex] = useState(0); const [isPlaying, setIsPlaying] = useState(false); const [isCatalogOpen, setIsCatalogOpen] = useState(false); + const [isEdgeBrowser, setIsEdgeBrowser] = useState(false); /** 解析形如 "16:9" 的比例字符串 */ const parseAspect = (input?: string): { w: number; h: number } => { @@ -238,18 +239,28 @@ export function H5MediaViewer({ }; }; + /** 检测是否为 Edge 浏览器(客户端挂载后执行) */ + useEffect(() => { + const isEdge = navigator.userAgent.indexOf('Edg') !== -1; + setIsEdgeBrowser(isEdge); + }, []); + + /** 根据浏览器类型获取最大高度值 */ + const maxHeight = useMemo(() => { + return isEdgeBrowser ? 'calc(100vh - 10.5rem)' : 'calc(100vh - 15rem)'; + }, [isEdgeBrowser]); + /** 视频轮播容器高度:按 aspectRatio 计算(基于视口宽度) */ const videoWrapperHeight = useMemo(() => { const { w, h } = parseAspect(aspectRatio); - return `min(calc(100vw * ${h} / ${w}), calc(100vh - 15rem))`; - }, [aspectRatio]); + return `min(calc(100vw * ${h} / ${w}), ${maxHeight})`; + }, [aspectRatio, maxHeight]); /** 图片轮播容器高度:默认 16:9 */ const imageWrapperHeight = useMemo(() => { - // return 'calc(100vw * 9 / 16)'; const { w, h } = parseAspect(aspectRatio); - return `min(calc(100vw * ${h} / ${w}), calc(100vh - 15rem))`; - }, [aspectRatio]); + return `min(calc(100vw * ${h} / ${w}), ${maxHeight})`; + }, [aspectRatio, maxHeight]); // 计算当前阶段类型 const stage = (selectedView === 'final' && taskObject.final?.url)