fix:地图仪表盘全屏下问题修复

This commit is contained in:
2025-06-19 23:02:50 +08:00
parent b0b8036fda
commit 230560e321
@@ -12,7 +12,7 @@ import {
ClockCircleOutlined, WarningOutlined, InfoCircleOutlined, ClockCircleOutlined, WarningOutlined, InfoCircleOutlined,
EyeOutlined, PlayCircleOutlined, PauseCircleOutlined, HomeOutlined, EyeOutlined, PlayCircleOutlined, PauseCircleOutlined, HomeOutlined,
CameraOutlined, ControlOutlined, BellOutlined, BarChartOutlined, CameraOutlined, ControlOutlined, BellOutlined, BarChartOutlined,
PauseOutlined, SearchOutlined PauseOutlined, SearchOutlined, FullscreenOutlined, FullscreenExitOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import moment from 'moment'; import moment from 'moment';
import { Amap } from '@amap/amap-react'; import { Amap } from '@amap/amap-react';
@@ -1835,17 +1835,46 @@ const DeviceMapDashboard: React.FC = () => {
currentMarkers.clear(); currentMarkers.clear();
}; };
const [isFullscreen, setIsFullscreen] = useState(false);
const containerRef = useRef<HTMLDivElement>(null);
// 处理全屏切换
const toggleFullscreen = () => {
if (!document.fullscreenElement) {
containerRef.current?.requestFullscreen();
setIsFullscreen(true);
} else {
document.exitFullscreen();
setIsFullscreen(false);
}
};
// 监听全屏变化
useEffect(() => {
const handleFullscreenChange = () => {
setIsFullscreen(!!document.fullscreenElement);
};
document.addEventListener('fullscreenchange', handleFullscreenChange);
return () => {
document.removeEventListener('fullscreenchange', handleFullscreenChange);
};
}, []);
return ( return (
<div style={{ <div
height: '100vh', ref={containerRef}
width: '100%', // 改为100%而不是100vw style={{
position: 'relative', height: '100vh',
overflow: 'hidden', width: '100%',
display: 'flex', position: 'relative',
flexDirection: 'column', overflow: 'hidden',
margin: '-24px', // 抵消 PageContainer 的 padding display: 'flex',
marginTop: '-16px' flexDirection: 'column',
}}> margin: '-24px',
marginTop: '-16px'
}}
>
{/* 顶部控制栏 */} {/* 顶部控制栏 */}
<div style={{ <div style={{
flex: '0 0 auto', flex: '0 0 auto',
@@ -2022,6 +2051,14 @@ const DeviceMapDashboard: React.FC = () => {
)} )}
</> </>
)} )}
<Button
icon={isFullscreen ? <FullscreenExitOutlined /> : <FullscreenOutlined />}
onClick={toggleFullscreen}
size="small"
>
{!isMobile && (isFullscreen ? '退出全屏' : '全屏')}
</Button>
</Space> </Space>
</Col> </Col>
</Row> </Row>
@@ -2033,8 +2070,9 @@ const DeviceMapDashboard: React.FC = () => {
position: 'relative', position: 'relative',
display: 'flex', display: 'flex',
overflow: 'hidden', overflow: 'hidden',
height: 'calc(100vh - 56px - 48px)', // 减去顶部工具栏和全局头部的高度 height: 'calc(100vh - 56px - 48px)',
width: '100%' // 确保宽度填满 width: '100%',
gap: 0 // 移除面板之间的间距
}}> }}>
{/* 左侧统计面板 */} {/* 左侧统计面板 */}
{leftPanelVisible && ( {leftPanelVisible && (
@@ -2045,7 +2083,7 @@ const DeviceMapDashboard: React.FC = () => {
height: '100%', height: '100%',
zIndex: 1000, zIndex: 1000,
transition: 'all 0.3s ease', transition: 'all 0.3s ease',
marginRight: '8px' marginRight: 0 // 移除右边距
}}> }}>
<Card <Card
title={leftPanelCollapsed ? null : "设备统计"} title={leftPanelCollapsed ? null : "设备统计"}
@@ -2271,7 +2309,8 @@ const DeviceMapDashboard: React.FC = () => {
position: 'relative', position: 'relative',
minWidth: 0, minWidth: 0,
minHeight: 0, minHeight: 0,
display: 'flex' display: 'flex',
margin: 0 // 移除边距
}}> }}>
{/* 地图容器 */} {/* 地图容器 */}
<div <div
@@ -2281,8 +2320,8 @@ const DeviceMapDashboard: React.FC = () => {
height: '100%', height: '100%',
position: 'relative', position: 'relative',
backgroundColor: '#f5f5f5', backgroundColor: '#f5f5f5',
border: '1px solid #e8e8e8', border: 'none', // 移除边框
borderRadius: '4px' borderRadius: 0 // 移除圆角
}} }}
/> />
@@ -2420,7 +2459,7 @@ const DeviceMapDashboard: React.FC = () => {
height: '100%', height: '100%',
position: 'relative', position: 'relative',
transition: 'all 0.3s ease', transition: 'all 0.3s ease',
marginLeft: '8px', marginLeft: 0, // 移除左边距
flexShrink: 0, flexShrink: 0,
overflow: 'hidden' overflow: 'hidden'
}}> }}>
@@ -2448,7 +2487,9 @@ const DeviceMapDashboard: React.FC = () => {
height: '100%', height: '100%',
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
overflow: 'hidden' overflow: 'hidden',
borderRadius: 0, // 移除卡片圆角
border: 'none' // 移除卡片边框
}} }}
bodyStyle={{ bodyStyle={{
padding: '12px', padding: '12px',