From a02fc6a77fa1b35c6516b2d37108d80e260c6c85 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 07 十一月 2024 22:05:08 +0800
Subject: [PATCH] 2024-11-07

---
 src/components/mkIcon/index.jsx |   29 +++++++++++++++++------------
 1 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/components/mkIcon/index.jsx b/src/components/mkIcon/index.jsx
index 529f3a4..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,6 +61,8 @@
   }
 
   getIcons = () => {
+    const { selectIcon } = this.state
+    
     Api.getCloudConfig({ func: 's_get_icons' }).then(res => {
       if (!res.status) {
         notification.warning({
@@ -72,20 +70,25 @@
           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