From 0842caa7d0fc431d6f6812e114bdef0d56af480e Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Mon, 10 Mar 2025 14:03:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=94=A8=E6=88=B7=E7=99=BB?= =?UTF-8?q?=E5=BD=95=E7=8A=B6=E6=80=81=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.tsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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,