diff --git a/src/App.tsx b/src/App.tsx index 2cdf77c..f071f33 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -13,6 +13,7 @@ const { Header, Footer, Sider, Content } = Layout; function App() { const dispatch = useAppDispatch(); + const navigate = useNavigate(); useEffect(() => { //连接websocket @@ -25,7 +26,7 @@ function App() { // } else { // navigate("/login"); // } - }else if(data.messageType === 'STATE'){ + } else if (data.messageType === "STATE") { dispatch(updateDeviceState(data.data)); } }); @@ -33,6 +34,14 @@ function App() { return () => subscription.unsubscribe(); }); + useEffect(() => { + if (localStorage.getItem("user")) { + navigate("/measure/config", { replace: true }); + } else { + navigate("/login"); + } + }, [navigate]); + const headerStyle: React.CSSProperties = { height: 64, padding: 0,