From fcdfdc9670866fecd2d239d75a6ec28391175e9f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 10 四月 2025 11:13:51 +0800
Subject: [PATCH] 2025-04-10

---
 src/tabviews/home/index.jsx |   71 +++++++++++++++++++++++++++--------
 1 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx
index 26fbcd0..b26fe42 100644
--- a/src/tabviews/home/index.jsx
+++ b/src/tabviews/home/index.jsx
@@ -16,12 +16,38 @@
 
   state = {
     loading: true,
-    background: sessionStorage.getItem('home_background'),
+    background: sessionStorage.getItem('home_background') || 'unset',
+    waiting: true,
     view: ''
   }
 
   componentDidMount () {
     this.loadHomeConfig()
+
+    this.check(0)
+  }
+
+  /**
+   * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊
+   */
+  componentWillUnmount () {
+    this.setState = () => {
+      return
+    }
+  }
+
+  check = (times) => {
+    times++
+
+    if ((window.GLOB.mkThdMenus.size > 0 && window.GLOB.mkActions.loaded) || times > 50) {
+      this.setState({
+        waiting: false
+      })
+    } else if (!window.GLOB.$error) {
+      setTimeout(() => {
+        this.check(times)
+      }, 200)
+    }
   }
 
   loadHomeConfig = () => {
@@ -30,23 +56,36 @@
       MenuID: this.props.MenuID
     }
     Api.getCacheConfig(_param).then(result => {
-      if (result.status) {
-        if (result.LongParam) {
-          this.setState({
-            loading: false,
-            view: 'custom'
-          })
-        } else {
-          this.setState({
-            loading: false,
-            view: 'default'
-          })
+      let view = 'default'
+      if (result.status && result.LongParam) {
+        let config = ''
+
+        try { // 閰嶇疆淇℃伅瑙f瀽
+          config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
+        } catch (e) {
+          console.warn('Parse Failure')
+          config = ''
         }
+
+        if (config && config.enabled) {
+          view = 'custom'
+        }
+      }
+
+      if (view === 'default') {
+        this.setState({
+          loading: false,
+          waiting: false,
+          view: 'default'
+        })
       } else {
         this.setState({
           loading: false,
-          view: 'default'
+          view: 'custom'
         })
+      }
+
+      if (!result.status) {
         notification.warning({
           top: 92,
           message: result.message,
@@ -57,12 +96,12 @@
   }
 
   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}/>)
+      return (<CustomPage MenuID={this.props.MenuID} MenuName="棣栭〉"/>)
     } else {
       return (<DefaultHome />)
     }

--
Gitblit v1.8.0