diff --git a/src/pages/Home.tsx b/src/pages/Home.tsx index 7bc80fb..d142003 100644 --- a/src/pages/Home.tsx +++ b/src/pages/Home.tsx @@ -48,10 +48,11 @@ export default function StationDashboard() { const el = powerTrendCardRef.current; if (!el) return; try { - if (!document.fullscreenElement) { - await el.requestFullscreen(); - } else { + // 只有当前全屏的是本卡片时才退出,否则请求卡片全屏(兼容页面整体全屏) + if (document.fullscreenElement === el) { await document.exitFullscreen(); + } else { + await el.requestFullscreen(); } } catch (err) { console.error('全屏切换异常:', err); @@ -65,7 +66,8 @@ export default function StationDashboard() { useEffect(() => { const onFullScreenChange = () => { - setIsPowerCardFullscreen(!!document.fullscreenElement); + // 只有发电趋势卡片本身全屏时才拉伸,页面整体全屏时保持原有尺寸 + setIsPowerCardFullscreen(document.fullscreenElement === powerTrendCardRef.current); }; document.addEventListener('fullscreenchange', onFullScreenChange); return () => { @@ -326,7 +328,7 @@ export default function StationDashboard() {