From cb9ade2afd2a367ad767bc605ab7086c695dd010 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 09 十二月 2022 15:53:32 +0800
Subject: [PATCH] 2022-12-09

---
 src/mob/colorsketch/index.jsx |   28 +++++++++++++---------------
 1 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/src/mob/colorsketch/index.jsx b/src/mob/colorsketch/index.jsx
index c7ea1a8..68d2965 100644
--- a/src/mob/colorsketch/index.jsx
+++ b/src/mob/colorsketch/index.jsx
@@ -7,8 +7,8 @@
 import './index.scss'
 
 const presetColors = [
-  '#f5222d', '#fa541c', '#fa8c16', '#faad14', '#fadb14', '#a0d911', '#52c41a', '#13c2c2', '#1890ff', '#2f54eb', '#722ed1',
-  '#eb2f96', '#595959', '#ffa39e', '#ffbb96', '#ffd591', '#ffe58f', '#fffb8f', '#eaff8f', '#b7eb8f', '#87e8de', '#91d5ff',
+  '#1890ff', '#f5222d', '#fa541c', '#fa8c16', '#faad14', '#fadb14', '#a0d911', '#52c41a', '#13c2c2', '#2f54eb', '#722ed1',
+  '#eb2f96', '#aeb303', '#c32539', '#ffbb96', '#ffd591', '#ffe58f', '#fffb8f', '#eaff8f', '#b7eb8f', '#87e8de', '#91d5ff',
   '#adc6ff', '#d3adf7', '#EBE9E9', '#d9d9d9', '#434343', '#000000', '#ffffff', 'transparent'
 ]
 
@@ -37,33 +37,31 @@
     }
 
     let _colors = sessionStorage.getItem('app_colors')
-    let colors = presetColors
+    let colors = JSON.parse(JSON.stringify(presetColors))
 
-    if (_colors && _colors !== '[]') {
+    if (_colors) {
       try {
         _colors = JSON.parse(_colors)
       } catch (e) {
-        _colors = null
+        _colors = []
       }
       
-      if (_colors) {
-        colors = presetColors.map((item, i) => {
-          if (_colors[i] && _colors[i].linkurl && !presetColors.includes(_colors[i].linkurl)) {
-            return _colors[i].linkurl
-          }
-          return item
-        })
-      }
+      _colors.forEach(item => {
+        if (!colors.includes(item.linkurl)) {
+          colors.push(item.linkurl)
+        }
+      })
     }
-    
+
     this.setState({color: initVal, allowClear: allowClear === true, colors})
   }
 
   handleChange = (color) => {
     let _color = `rgba(${ color.rgb.r }, ${ color.rgb.g }, ${ color.rgb.b }, ${ color.rgb.a })`
+    let _hex = color.hex === 'transparent' ? '#ffffff' : color.hex
 
     this.setState({ color: _color }, () => {
-      this.props.onChange && this.props.onChange(_color)
+      this.props.onChange && this.props.onChange(_color, _hex)
     })
   }
 

--
Gitblit v1.8.0