zcloud-gbs-bi-react/src/pages/Container/Map/components/Content/index.js

108 lines
3.9 KiB
JavaScript
Raw Normal View History

2026-01-05 14:53:49 +08:00
import { useMount } from "ahooks";
import { useContext, 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";
2026-01-06 13:33:01 +08:00
import { portUtilsList } from "~/pages/Container/Map/components/BottomUtils/portUtilsList";
2026-01-05 14:53:49 +08:00
import FengBi from "~/pages/Container/Map/components/Content/port/FengBi";
import IndexInfo from "~/pages/Container/Map/components/Content/port/IndexInfo";
import MenJin from "~/pages/Container/Map/components/Content/port/MenJin";
import PortIndex from "~/pages/Container/Map/components/Content/port/PortIndex";
import QiXiang from "~/pages/Container/Map/components/Content/port/QiXiang";
import RenYuan from "~/pages/Container/Map/components/Content/port/RenYuan";
import WeiXian from "~/pages/Container/Map/components/Content/port/WeiXian";
import XiaoFang from "~/pages/Container/Map/components/Content/port/XiaoFang";
import ZhongDian 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);
useMount(() => {
setAnimationKey(Math.random());
mitt.on(changeContentAnimationKeyMittKey, () => {
setAnimationKey(Math.random());
setCollapse(false);
});
});
const onChangeCollapse = () => {
setAnimationKey(Math.random());
setCollapse(!collapse);
};
const renderPortContent = () => {
if (!currentBranchOffice) {
2026-01-06 13:33:01 +08:00
const bottomUtilsCurrentType = bottomUtilsCurrentIndex !== -1 ? portUtilsList[bottomUtilsCurrentIndex].type : "";
if (bottomUtilsCurrentType === "" || bottomUtilsCurrentType === "camera")
2026-01-05 14:53:49 +08:00
return <PortIndex />;
2026-01-06 13:33:01 +08:00
if (bottomUtilsCurrentType === "door")
2026-01-05 14:53:49 +08:00
return <MenJin />;
2026-01-06 13:33:01 +08:00
if (bottomUtilsCurrentType === "fire")
2026-01-05 14:53:49 +08:00
return <XiaoFang />;
2026-01-06 13:33:01 +08:00
if (bottomUtilsCurrentType === "danger")
2026-01-05 14:53:49 +08:00
return <WeiXian />;
2026-01-06 13:33:01 +08:00
if (bottomUtilsCurrentType === "weather")
2026-01-05 14:53:49 +08:00
return <QiXiang />;
2026-01-06 13:33:01 +08:00
if (bottomUtilsCurrentType === "people")
2026-01-05 14:53:49 +08:00
return <RenYuan />;
2026-01-06 13:33:01 +08:00
if (bottomUtilsCurrentType === "project")
2026-01-05 14:53:49 +08:00
return <ZhongDian />;
2026-01-06 13:33:01 +08:00
if (bottomUtilsCurrentType === "closedArea")
2026-01-05 14:53:49 +08:00
return <FengBi />;
}
};
const renderContent = () => {
if (pureMap || collapse)
return <div></div>;
return (
<div className="map_content_container__content">
{!currentPort && <IndexInfo />}
{currentPort === "00003" && renderPortContent()}
</div>
);
};
return (
<div className="map_content_container">
<SwitchTransition>
<CSSTransition
timeout={500}
classNames={{
enter: "animate__animated animate__faster",
enterActive: "animate__animated animate__faster animate__fadeInLeft",
exit: "animate__animated animate__faster",
exitActive: "animate__animated animate__faster animate__fadeOutLeft",
}}
unmountOnExit
key={animationKey}
>
<div>
{renderContent()}
{(!pureMap && currentPort) && (
<div
className={`collapse_menu ${collapse ? "active" : ""}`}
style={{ backgroundImage: `url(${collapseMenuBg})` }}
onClick={onChangeCollapse}
>
<img src={collapseMenu} alt="" />
</div>
)}
</div>
</CSSTransition>
</SwitchTransition>
</div>
);
}
export default Content;