From aa15f061ba185b05f22c98a0a979c72d08bcd974 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 11 二月 2025 09:42:38 +0800
Subject: [PATCH] 2025-02-11
---
src/tabviews/home/index.jsx | 76 ++++++++++++++++++++++++++++++--------
1 files changed, 60 insertions(+), 16 deletions(-)
diff --git a/src/tabviews/home/index.jsx b/src/tabviews/home/index.jsx
index b53c5bd..b26fe42 100644
--- a/src/tabviews/home/index.jsx
+++ b/src/tabviews/home/index.jsx
@@ -16,32 +16,76 @@
state = {
loading: true,
+ 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 = () => {
let _param = {
func: 'sPC_Get_LongParam',
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,
@@ -52,12 +96,12 @@
}
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}/>)
+ return (<CustomPage MenuID={this.props.MenuID} MenuName="棣栭〉"/>)
} else {
return (<DefaultHome />)
}
--
Gitblit v1.8.0