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 |   35 +++++++++++++++++++++++++++++++----
 1 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx
index b53c5bd..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'
@@ -16,10 +17,24 @@
 
   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 = () => {
     let _param = {
       func: 'sPC_Get_LongParam',
       MenuID: this.props.MenuID
@@ -34,6 +49,7 @@
         } else {
           this.setState({
             loading: false,
+            waiting: false,
             view: 'default'
           })
         }
@@ -52,10 +68,10 @@
   }
 
   render() {
-    const { loading, view } = this.state
+    const { loading, waiting, view, background } = this.state
 
-    if (loading) {
-      return (<Spin className="home-box-spin" size="large" />)
+    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}/>)
     } else {
@@ -64,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