修复首页 全屏 之后 发电趋势 变形的问题
This commit is contained in:
@@ -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() {
|
||||
<UniversalLineChart
|
||||
data={powerTrendData}
|
||||
xKey="time"
|
||||
height={isPowerCardFullscreen ? window.innerHeight : 200}
|
||||
height={isPowerCardFullscreen ? 'calc(100vh - 96px)' : 200}
|
||||
smooth
|
||||
dot
|
||||
backgroundColor="transparent"
|
||||
|
||||
Reference in New Issue
Block a user