From 6afdec0062dacbded57e166230eb22cc55ced0c1 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 08 五月 2021 14:30:21 +0800
Subject: [PATCH] 2021-05-08

---
 src/tabviews/home/index.jsx |   28 +++++++++++++++++++++++++---
 1 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx
index 26fbcd0..9505906 100644
--- a/src/tabviews/home/index.jsx
+++ b/src/tabviews/home/index.jsx
@@ -1,5 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
+import { connect } from 'react-redux'
 import { notification, Spin } from 'antd'
 
 import Api from '@/api'
@@ -17,11 +18,20 @@
   state = {
     loading: true,
     background: sessionStorage.getItem('home_background'),
+    waiting: true,
     view: ''
   }
 
   componentDidMount () {
     this.loadHomeConfig()
+  }
+
+  UNSAFE_componentWillReceiveProps (nextProps) {
+    if (nextProps.permMenus.length > 0 && JSON.stringify(nextProps.permAction) !== '{}') {
+      this.setState({
+        waiting: false
+      })
+    }
   }
 
   loadHomeConfig = () => {
@@ -39,6 +49,7 @@
         } else {
           this.setState({
             loading: false,
+            waiting: false,
             view: 'default'
           })
         }
@@ -57,9 +68,9 @@
   }
 
   render() {
-    const { loading, view, background } = this.state
+    const { loading, waiting, view, background } = this.state
 
-    if (loading) {
+    if (loading || waiting) {
       return (<div className="home-loading-view" style={{background: background}}><Spin className="home-box-spin" size="large" /></div>)
     } else if (view === 'custom') {
       return (<CustomPage MenuID={this.props.MenuID}/>)
@@ -69,4 +80,15 @@
   }
 }
 
-export default Home
\ No newline at end of file
+const mapStateToProps = (state) => {
+  return {
+    permAction: state.permAction,
+    permMenus: state.permMenus
+  }
+}
+
+const mapDispatchToProps = () => {
+  return {}
+}
+
+export default connect(mapStateToProps, mapDispatchToProps)(Home)
\ No newline at end of file

--
Gitblit v1.8.0