index.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* eslint-disable jsx-a11y/iframe-has-title */
  2. import React, { useCallback, useState } from "react";
  3. import styles from "./index.module.scss";
  4. import classNames from "classnames";
  5. import history from "@/utils/history";
  6. import A0Map from "../A0Map";
  7. import { envData, envDataSonType, envDataType, envUrl } from "@/utils/env";
  8. import Tab1 from "./Tab1";
  9. import Tab4 from "./Tab4";
  10. function A2Main() {
  11. // 传给历史
  12. const [swData, setSwData] = useState<envDataSonType[]>([]);
  13. // 右侧选中的状态
  14. const [type, setType] = useState(0);
  15. const typeChangeFu = useCallback((item: envDataType) => {
  16. setSwData(item.data);
  17. setType(item.id);
  18. }, []);
  19. return (
  20. <div className={styles.A2Main}>
  21. {/* 图片页面 */}
  22. <div className="threeBox">
  23. <A0Map type={type} sonChaneType={(val) => setType(val)} />
  24. </div>
  25. {/* 左上方logo */}
  26. <div className="logo" title="首页" onClick={() => history.push("/")}>
  27. <img src={`${envUrl}/home/logo.png`} alt="" />
  28. </div>
  29. {/* 底部轮播图 */}
  30. <div
  31. className={classNames(
  32. "swBox",
  33. [1, 4, 5].includes(type) ? "swBox1" : ""
  34. )}
  35. >
  36. <div className="swBoxMain">
  37. <div className="top">
  38. {envData.map((v) => (
  39. <div
  40. onClick={() => typeChangeFu(v)}
  41. className={classNames(
  42. "row",
  43. `row${v.id}`,
  44. type === v.id ? `rowAc${v.id}` : ""
  45. )}
  46. key={v.id}
  47. ></div>
  48. ))}
  49. {/* 展开收起按钮 */}
  50. <div
  51. className={classNames("openIcon", type ? "openIconAc" : "")}
  52. onClick={() => {
  53. if (type) setType(0);
  54. else typeChangeFu(envData[0]);
  55. }}
  56. ></div>
  57. </div>
  58. {/* 历史 */}
  59. {
  60. type === 1 ? (
  61. <Tab1 data={swData} />
  62. ) : type === 4 ? (
  63. <Tab4 />
  64. ) : type === 5 ? null : null // <KnowLedge />
  65. }
  66. </div>
  67. </div>
  68. </div>
  69. );
  70. }
  71. const MemoA2Main = React.memo(A2Main);
  72. export default MemoA2Main;