king
2023-08-27 da64ab0923bf8817fc8599a6e37b953ce38f64c8
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()