fix:地图仪表盘全屏下问题修复
This commit is contained in:
@@ -12,7 +12,7 @@ import {
|
||||
ClockCircleOutlined, WarningOutlined, InfoCircleOutlined,
|
||||
EyeOutlined, PlayCircleOutlined, PauseCircleOutlined, HomeOutlined,
|
||||
CameraOutlined, ControlOutlined, BellOutlined, BarChartOutlined,
|
||||
PauseOutlined, SearchOutlined
|
||||
PauseOutlined, SearchOutlined, FullscreenOutlined, FullscreenExitOutlined
|
||||
} from '@ant-design/icons';
|
||||
import moment from 'moment';
|
||||
import { Amap } from '@amap/amap-react';
|
||||
@@ -1835,17 +1835,46 @@ const DeviceMapDashboard: React.FC = () => {
|
||||
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 (
|
||||
<div style={{
|
||||
height: '100vh',
|
||||
width: '100%', // 改为100%而不是100vw
|
||||
position: 'relative',
|
||||
overflow: 'hidden',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
margin: '-24px', // 抵消 PageContainer 的 padding
|
||||
marginTop: '-16px'
|
||||
}}>
|
||||
<div
|
||||
ref={containerRef}
|
||||
style={{
|
||||
height: '100vh',
|
||||
width: '100%',
|
||||
position: 'relative',
|
||||
overflow: 'hidden',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
margin: '-24px',
|
||||
marginTop: '-16px'
|
||||
}}
|
||||
>
|
||||
{/* 顶部控制栏 */}
|
||||
<div style={{
|
||||
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>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -2033,8 +2070,9 @@ const DeviceMapDashboard: React.FC = () => {
|
||||
position: 'relative',
|
||||
display: 'flex',
|
||||
overflow: 'hidden',
|
||||
height: 'calc(100vh - 56px - 48px)', // 减去顶部工具栏和全局头部的高度
|
||||
width: '100%' // 确保宽度填满
|
||||
height: 'calc(100vh - 56px - 48px)',
|
||||
width: '100%',
|
||||
gap: 0 // 移除面板之间的间距
|
||||
}}>
|
||||
{/* 左侧统计面板 */}
|
||||
{leftPanelVisible && (
|
||||
@@ -2045,7 +2083,7 @@ const DeviceMapDashboard: React.FC = () => {
|
||||
height: '100%',
|
||||
zIndex: 1000,
|
||||
transition: 'all 0.3s ease',
|
||||
marginRight: '8px'
|
||||
marginRight: 0 // 移除右边距
|
||||
}}>
|
||||
<Card
|
||||
title={leftPanelCollapsed ? null : "设备统计"}
|
||||
@@ -2271,7 +2309,8 @@ const DeviceMapDashboard: React.FC = () => {
|
||||
position: 'relative',
|
||||
minWidth: 0,
|
||||
minHeight: 0,
|
||||
display: 'flex'
|
||||
display: 'flex',
|
||||
margin: 0 // 移除边距
|
||||
}}>
|
||||
{/* 地图容器 */}
|
||||
<div
|
||||
@@ -2281,8 +2320,8 @@ const DeviceMapDashboard: React.FC = () => {
|
||||
height: '100%',
|
||||
position: 'relative',
|
||||
backgroundColor: '#f5f5f5',
|
||||
border: '1px solid #e8e8e8',
|
||||
borderRadius: '4px'
|
||||
border: 'none', // 移除边框
|
||||
borderRadius: 0 // 移除圆角
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -2420,7 +2459,7 @@ const DeviceMapDashboard: React.FC = () => {
|
||||
height: '100%',
|
||||
position: 'relative',
|
||||
transition: 'all 0.3s ease',
|
||||
marginLeft: '8px',
|
||||
marginLeft: 0, // 移除左边距
|
||||
flexShrink: 0,
|
||||
overflow: 'hidden'
|
||||
}}>
|
||||
@@ -2448,7 +2487,9 @@ const DeviceMapDashboard: React.FC = () => {
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
overflow: 'hidden'
|
||||
overflow: 'hidden',
|
||||
borderRadius: 0, // 移除卡片圆角
|
||||
border: 'none' // 移除卡片边框
|
||||
}}
|
||||
bodyStyle={{
|
||||
padding: '12px',
|
||||
|
||||
Reference in New Issue
Block a user