import { useContext, useEffect, useState } from "react"; import { CSSTransition, SwitchTransition } from "react-transition-group"; import collapseMenu from "~/assets/images/map_bi/content/collapse_menu.png"; import collapseMenuBg from "~/assets/images/map_bi/content/collapse_menu_bg.png"; import { portUtilsList } from "~/pages/Container/Map/components/BottomUtils/portUtilsList"; import PortFengBi from "~/pages/Container/Map/components/Content/port/FengBi"; import IndexInfo from "~/pages/Container/Map/components/Content/port/IndexInfo"; import PortMenJin from "~/pages/Container/Map/components/Content/port/MenJin"; import PortIndex from "~/pages/Container/Map/components/Content/port/PortIndex"; import PortQiXiang from "~/pages/Container/Map/components/Content/port/QiXiang"; import PortRenYuan from "~/pages/Container/Map/components/Content/port/RenYuan"; import PortWeiXian from "~/pages/Container/Map/components/Content/port/WeiXian"; import PortXiaoFang from "~/pages/Container/Map/components/Content/port/XiaoFang"; import PortZhongDian from "~/pages/Container/Map/components/Content/port/ZhongDian"; import { Context } from "~/pages/Container/Map/js/context"; import mitt from "~/pages/Container/Map/js/mitt"; import { changeContentAnimationKeyMittKey } from "~/pages/Container/Map/js/mittKey"; import "./index.less"; function Content() { const { currentPort, currentBranchOffice, pureMap, bottomUtilsCurrentIndex } = useContext(Context); const [animationKey, setAnimationKey] = useState(0); const [collapse, setCollapse] = useState(false); useEffect(() => { setAnimationKey(Math.random()); mitt.on(changeContentAnimationKeyMittKey, () => { setAnimationKey(Math.random()); setCollapse(false); }); return () => { mitt.off(changeContentAnimationKeyMittKey); }; }, []); const onChangeCollapse = () => { setAnimationKey(Math.random()); setCollapse(!collapse); }; const renderPortContent = () => { if (!currentBranchOffice) { const bottomUtilsCurrentType = bottomUtilsCurrentIndex !== -1 ? portUtilsList[bottomUtilsCurrentIndex].type : ""; if (bottomUtilsCurrentType === "" || bottomUtilsCurrentType === "camera") return ; if (bottomUtilsCurrentType === "door") return ; if (bottomUtilsCurrentType === "fire") return ; if (bottomUtilsCurrentType === "danger") return ; if (bottomUtilsCurrentType === "weather") return ; if (bottomUtilsCurrentType === "people") return ; if (bottomUtilsCurrentType === "project") return ; if (bottomUtilsCurrentType === "closedArea") return ; } }; const renderContent = () => { if (pureMap || collapse) return null; return (
{!currentPort && } {currentPort === "00003" && renderPortContent()}
); }; const renderCollapseMenu = () => { if (pureMap) return null; if (currentPort) { return (
); } }; return (
{renderContent()} {renderCollapseMenu()}
); } export default Content;