From 295b93984fd94a11d0337637f76ff91b5a618215 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 24 四月 2023 09:49:26 +0800
Subject: [PATCH] 2023-04-24

---
 src/views/main/index.jsx |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/views/main/index.jsx b/src/views/main/index.jsx
index 8dd7821..3fa342e 100644
--- a/src/views/main/index.jsx
+++ b/src/views/main/index.jsx
@@ -17,7 +17,15 @@
 const _locale = sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS
 
 class Main extends Component {
-  state = {}
+  state = {
+    userId: sessionStorage.getItem('UserID')
+  }
+
+  UNSAFE_componentWillMount() {
+    if (!this.state.userId) {
+      this.props.history.replace('/login')
+    }
+  }
 
   componentDidMount () {
     MKEmitter.addListener('resetSelectLine', this.resetParentParam)
@@ -50,7 +58,9 @@
 
   render () {
     const navBar = window.GLOB.navBar
-    
+
+    if (!this.state.userId) return null
+
     return (
       <div className="mk-main-view">
         <ConfigProvider locale={_locale}>

--
Gitblit v1.8.0