From da64ab0923bf8817fc8599a6e37b953ce38f64c8 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 27 八月 2023 18:37:36 +0800
Subject: [PATCH] 2023-08-27

---
 src/components/mkIcon/index.jsx |   31 ++++++++++++++++++-------------
 1 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/components/mkIcon/index.jsx b/src/components/mkIcon/index.jsx
index 105f627..3427f4b 100644
--- a/src/components/mkIcon/index.jsx
+++ b/src/components/mkIcon/index.jsx
@@ -46,12 +46,8 @@
   }
 
   componentDidMount() {
-    if (!window.GLOB.designView) {
-      if (sessionStorage.getItem('systemIcons')) {
-        this.setState({cusicons: JSON.parse(sessionStorage.getItem('systemIcons'))})
-      } else {
-        this.getIcons()
-      }
+    if (!window.GLOB.designView && window.GLOB.systemIcons) {
+      this.setState({cusicons: window.GLOB.systemIcons})
     }
   }
 
@@ -65,27 +61,34 @@
   }
 
   getIcons = () => {
-    Api.getSystemConfig({ func: 's_get_icons' }).then(res => {
+    const { selectIcon } = this.state
+    
+    Api.getCloudConfig({ func: 's_get_icons' }).then(res => {
       if (!res.status) {
         notification.warning({
           top: 92,
           message: res.message,
           duration: 5
         })
-        sessionStorage.setItem('systemIcons', JSON.stringify([]))
-        return
-      } else if (!res.data) {
+        window.GLOB.systemIcons = []
         return
       }
 
-      let icons = res.data.map(item => {
+      let icons = (res.data || []).map(item => {
         item.icon_svg = window.decodeURIComponent(window.atob(item.icon_svg))
         return item
       })
 
-      sessionStorage.setItem('systemIcons', JSON.stringify(icons))
+      window.GLOB.systemIcons = icons
 
       this.setState({cusicons: icons})
+
+      if (icons.length > 0 && selectIcon && /<svg/.test(selectIcon)) {
+        setTimeout(() => {
+          let node = document.getElementById('mk-custom-tab')
+          node && node.click()
+        }, 200)
+      }
     })
   }
 
@@ -94,7 +97,9 @@
 
     this.setState({visible: true})
 
-    if (cusicons.length > 0 && selectIcon && /<svg/.test(selectIcon)) {
+    if (!window.GLOB.designView && !window.GLOB.systemIcons) {
+      this.getIcons()
+    } else if (cusicons.length > 0 && selectIcon && /<svg/.test(selectIcon)) {
       setTimeout(() => {
         let node = document.getElementById('mk-custom-tab')
         node && node.click()

--
Gitblit v1.8.0