From 3cbad93c94c39730e45600efeabdfebcd424c2cc Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 14 一月 2021 19:00:19 +0800
Subject: [PATCH] 2021-01-14

---
 src/menu/popview/index.jsx |   42 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 41 insertions(+), 1 deletions(-)

diff --git a/src/menu/popview/index.jsx b/src/menu/popview/index.jsx
index 59c0dcb..efb26ea 100644
--- a/src/menu/popview/index.jsx
+++ b/src/menu/popview/index.jsx
@@ -49,6 +49,7 @@
     oriConfig: null,
     openEdition: '',
     config: null,
+    customComponents: []
   }
 
   UNSAFE_componentWillMount() {
@@ -64,6 +65,8 @@
   componentDidMount () {
     MKEmitter.addListener('delButtons', this.delButtons)
     MKEmitter.addListener('submitComponentStyle', this.updateComponentStyle)
+    MKEmitter.addListener('updateCustomComponent', this.updateCustomComponent)
+    this.updateCustomComponent()
   }
 
   shouldComponentUpdate (nextProps, nextState) {
@@ -79,6 +82,40 @@
     }
     MKEmitter.removeListener('delButtons', this.delButtons)
     MKEmitter.removeListener('submitComponentStyle', this.updateComponentStyle)
+    MKEmitter.removeListener('updateCustomComponent', this.updateCustomComponent)
+  }
+
+  updateCustomComponent = () => {
+    Api.getSystemConfig({
+      func: 's_get_custom_components',
+      typecharone: ''
+    }).then(res => {
+      let coms = []
+      if (res.cus_list && res.cus_list.length > 0) {
+        res.cus_list.forEach(item => {
+          let config = ''
+
+          try {
+            config = JSON.parse(window.decodeURIComponent(window.atob(item.long_param)))
+          } catch (e) {
+            console.warn('Parse Failure')
+            config = ''
+          }
+
+          if (!config || !item.c_name) return
+
+          coms.push({
+            type: 'menu',
+            title: item.c_name,
+            url: item.images,
+            component: config.type,
+            subtype: config.subtype,
+            config
+          })
+        })
+      }
+      this.setState({customComponents: coms})
+    })
   }
 
   updateComponentStyle = (parentId, keys, style) => {
@@ -500,7 +537,7 @@
 
   render () {
     const { btn } = this.props
-    const { activeKey, MenuType, dict, config, menuloading } = this.state
+    const { activeKey, MenuType, dict, config, menuloading, customComponents } = this.state
 
     return (
       <DndProvider backend={HTML5Backend}>
@@ -518,6 +555,9 @@
               <Panel header={dict['mob.component']} key="component">
                 <SourceWrap MenuType={MenuType} />
               </Panel>
+              {customComponents && customComponents.length ? <Panel header="鑷畾涔夌粍浠�" key="cuscomponent">
+                <SourceWrap components={customComponents} MenuType={MenuType} />
+              </Panel> : null}
               <Panel header={'鑳屾櫙'} key="background">
                 {config ? <BgController config={config} updateConfig={this.updateConfig} /> : null}
               </Panel>

--
Gitblit v1.8.0