diff --git a/src/App.js b/src/App.js index 19ee3e8..b7649fa 100644 --- a/src/App.js +++ b/src/App.js @@ -3,24 +3,40 @@ import "./index.css"; import Head from "./components/Common/Company"; import useSlider, { Slider } from "./hooks/useSlider"; import NavMenu from "./components/Common/NavMenu"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import Home from "./pages/Home"; import EnergyAnalysis from "./pages/EnergyCostAnalysis"; import RulerContainer from "./components/Tools/Ruler"; import { createPortal } from "react-dom"; +const Menus = ["窑炉总览", "窑炉内部", "退火监测", "质检统计", "能耗分析"]; + function App() { const { styles, value, setValue } = useSlider(100); const [navActive, setNavActive] = useState("窑炉总览"); + useEffect(() => { + const timer = setInterval(() => { + handleMenuChange(Menus[(Menus.indexOf(navActive) + 1) % Menus.length]); + }, 10000); + + return () => { + clearInterval(timer); + }; + }, [navActive]); + + function handleMenuChange(value) { + setNavActive(value); + } + return ( <>
- setNavActive(v)} /> + {navActive == "能耗分析" && } - {navActive == "能耗分析" &&
} + {navActive == "能耗分析" &&
} {navActive != "能耗分析" && }
diff --git a/src/pages/Home/index.jsx b/src/pages/Home/index.jsx index bde47b6..e492b97 100644 --- a/src/pages/Home/index.jsx +++ b/src/pages/Home/index.jsx @@ -16,7 +16,7 @@ import useRefresh from "../../hooks/useRefresh"; export default function Home({ active }) { useRefresh(true); - + const videoUp = useRef(null); const videoDown = useRef(null);