tsg-web/src/views/Home/index.tsx

125 lines
3.6 KiB
TypeScript
Raw Normal View History

2024-09-20 15:02:50 +08:00
import React, { useEffect, useState } from 'react'
import { useLocation } from 'react-router'
import { useDispatch, useSelector } from 'react-redux'
import './index.less'
import MapCtrl from './MapCtrl/index'
2024-09-20 15:02:50 +08:00
import HomePanelsLayoutPage from './homePanelsLayoutPage'
import Ysgzq from '../ysgzq/ssyq'
import Sssq from '../ysgzq/sssq'
import Ddxsfx from '../fxdd/dqxsfx'
// import Tqyb from '../fxdd/tqyb'
import Fhxs from './fhxs'
import Tqyb from './tqyb'
2025-10-09 09:49:16 +08:00
import Hsyy from './hsyy'
2025-08-07 11:28:32 +08:00
import Btn from './btn'
2024-09-20 15:02:50 +08:00
const HomePage = () => {
const getLayerVisible = (s:any) => s.map.layerVisible;
2025-08-07 11:28:32 +08:00
const mode = useSelector((s:any) => s.map.mode);
2024-09-20 15:02:50 +08:00
const layerVisible = useSelector(getLayerVisible);
2025-08-07 11:28:32 +08:00
const [showPanels, setShowPanels] = useState(true)
2024-09-20 15:02:50 +08:00
const location = useLocation()
const dispatch = useDispatch()
const pathname = location.pathname
useEffect(() => {
// if (pathname !== '/mgr/home') {
// dispatch.map.setLayerVisible({ ShuiKuLayer: false })
// dispatch.map.setZhongxingSk(true)
// } else {
// dispatch.map.setLayerVisible({ ShuiKuLayer: true })
// dispatch.map.setZhongxingSk(true)
// }
2025-10-09 09:49:16 +08:00
if(pathname === '/mgr/sy/hsyy'){
dispatch.map.setMode('3d');
}else{
dispatch.map.setMode('2d');
}
2024-09-20 15:02:50 +08:00
}, [pathname])
useEffect(() => {
// if (pathname == '/mgr/home' && !showPanels) {
// dispatch.map.setZhongxingSk(true)
// dispatch.map.setLayerVisible({ AdcdLayer: true })
// dispatch.map.setLayerVisible({ ShuiKuLayer: true })
// }
}, [showPanels])
return (
<div
style={{
height: '100%',
background: '#ECF2F9',
display: 'flex',
alignItems: 'stretch',
}}
>
<div style={{ flex: 1, padding: 0 }} className="indexBox">
<div
style={{
height: '100%',
position: 'relative',
background: '#ECF2F9',
}}
>
{/* 控制按钮 */}
2025-10-14 13:57:38 +08:00
<Btn showPanels={showPanels} setShowPanels={setShowPanels} pathname={pathname}/>
2024-09-20 15:02:50 +08:00
{/* 地图 */}
2025-08-07 11:28:32 +08:00
<MapCtrl mode={mode}/>
2024-09-20 15:02:50 +08:00
{/*首页面板*/}
{pathname === '/mgr/home' ? (
2025-10-14 13:57:38 +08:00
<HomePanelsLayoutPage showPanels={showPanels} mode={mode}/>
2024-09-20 15:02:50 +08:00
) : null}
2024-09-23 10:33:56 +08:00
{/*四预-防洪形势*/}
{pathname === '/mgr/sy/fhxzfx' ? (
2024-09-20 15:02:50 +08:00
<Fhxs showPanels={showPanels}/>
) : null}
2024-09-23 10:33:56 +08:00
{/*四预-天气预报*/}
{pathname === '/mgr/sy/tqyb' ? (
2024-09-20 15:02:50 +08:00
<Tqyb showPanels={showPanels}/>
) : null}
2025-10-09 09:49:16 +08:00
{/*四预-洪水预演*/}
{pathname === '/mgr/sy/hsyy' ? (
<Hsyy showPanels={showPanels}/>
) : null}
2024-09-20 15:02:50 +08:00
{/*雨水工灾情面板-雨情*/}
{pathname === '/mgr/ysgzq/ssyq' ? (
<div style={showPanels ? { display: 'block' } : { display: 'none' }}><Ysgzq /></div>
) : null}
{/*雨水工灾情面板-水情*/}
{pathname === '/mgr/ysgzq/sssq' ? (
<div style={showPanels ? { display: 'block' } : { display: 'none' }}><Sssq /></div>
) : null}
{/*防汛调度面板-当前形势*/}
{pathname === '/mgr/fxdd/dqxsfx' ? (
<div style={showPanels ? { display: 'block' } : { display: 'none' }}><Ddxsfx /></div>
) : null}
{/*防汛调度-天气预报面板*/}
{/* {pathname === '/mgr/fxdd/tqyb' ? (
<div style={showPanels ? { display: 'block' } : { display: 'none' }}><Tqyb /></div>
) : null} */}
</div>
</div>
</div>
)
}
export default HomePage