king
2021-12-30 09e0de52a398dd08a0dc3f4b43e4589d211e9c27
src/mob/colorsketch/index.jsx
@@ -1,8 +1,8 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
// import { is, fromJS } from 'immutable'
import { SketchPicker } from 'react-color'
import { Popover, Icon } from 'antd'
import { Popover } from 'antd'
import { CloseCircleFilled } from '@ant-design/icons'
import './index.scss'
@@ -36,19 +36,25 @@
      initVal = value
    }
    let _colors = sessionStorage.getItem('app_colors') || []
    try {
      _colors = JSON.parse(_colors)
    } catch {
      _colors = []
    }
    let colors = presetColors.map((item, i) => {
      if (_colors[i] && _colors[i].linkurl && !presetColors.includes(_colors[i].linkurl)) {
        return _colors[i].linkurl
    let _colors = sessionStorage.getItem('app_colors')
    let colors = presetColors
    if (_colors && _colors !== '[]') {
      try {
        _colors = JSON.parse(_colors)
      } catch (e) {
        _colors = null
      }
      return item
    })
      if (_colors) {
        colors = presetColors.map((item, i) => {
          if (_colors[i] && _colors[i].linkurl && !presetColors.includes(_colors[i].linkurl)) {
            return _colors[i].linkurl
          }
          return item
        })
      }
    }
    
    this.setState({color: initVal, allowClear: allowClear === true, colors})
  }
@@ -84,7 +90,7 @@
            <div className="color-sketch-block-inner" style={ {background: color} }></div>
          </div>
        </Popover>
        <div className="color-sketch-value">{color}{allowClear && color ? <Icon onClick={this.clear} type="close"/> : null}</div>
        <div className="color-sketch-value">{color}{allowClear && color ? <CloseCircleFilled onClick={this.clear}/> : null}</div>
      </div>
    )
  }