From 486717570e2fc4b81b6e9db511cd445447fca333 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 18 八月 2023 22:58:08 +0800 Subject: [PATCH] Merge branch 'develop' --- src/mob/colorsketch/index.jsx | 56 ++++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/mob/colorsketch/index.jsx b/src/mob/colorsketch/index.jsx index 63abecf..35822cb 100644 --- a/src/mob/colorsketch/index.jsx +++ b/src/mob/colorsketch/index.jsx @@ -4,6 +4,7 @@ import { Popover } from 'antd' import { CloseCircleFilled } from '@ant-design/icons' +import Api from '@/api' import './index.scss' const presetColors = [ @@ -12,6 +13,7 @@ '#adc6ff', '#EBE9E9', '#d9d9d9', 'rgba(0, 0, 0, 0.65)', 'rgba(0, 0, 0, 0.85)', '#000000', '#ffffff', 'transparent' ] const _href = window.location.href.split('#')[0] +let loading = false class ColorSketch extends Component { static propTpyes = { @@ -38,7 +40,39 @@ initVal = value } - let _colors = sessionStorage.getItem('app_colors') + this.setState({color: initVal, initVal, allowClear: allowClear === true}, () => { + this.checkcolors() + }) + } + + checkcolors = () => { + let app_colors = window.GLOB.app_colors + + if (app_colors) { + this.getColors(app_colors) + } else { + if (loading) { + this.getColors([]) + } else { + loading = true + let param = { + func: 's_url_db_adduptdel', + PageIndex: 0, // 0 浠h〃鍏ㄩ儴 + PageSize: 0, // 0 浠h〃鍏ㄩ儴 + typecharone: 'color', + type: 'search' + } + + Api.getCloudConfig(param).then(res => { + loading = false + window.GLOB.app_colors = res.data || [] + this.getColors(res.data || []) + }) + } + } + } + + getColors = (appColors) => { let colors = JSON.parse(JSON.stringify(presetColors)) let normal_colors = localStorage.getItem(_href + 'normal_colors') @@ -56,19 +90,11 @@ normal_colors = [] } - if (_colors) { - try { - _colors = JSON.parse(_colors) - } catch (e) { - _colors = [] - } + appColors.forEach(item => { + if (normal_colors.includes(item.linkurl)) return - _colors.forEach(item => { - if (normal_colors.includes(item.linkurl)) return - - colors.push({color: item.linkurl, title: '绯荤粺鑹诧細' + item.linkurl}) - }) - } + colors.push({color: item.linkurl, title: '绯荤粺鑹诧細' + item.linkurl}) + }) if (colors.length < 40) { for (let i = colors.length; i < 40; i++) { @@ -76,7 +102,7 @@ } } - this.setState({color: initVal, initVal, allowClear: allowClear === true, colors}) + this.setState({colors}) } handleChange = (color) => { @@ -126,8 +152,6 @@ localStorage.setItem(_href + 'normal_colors', JSON.stringify(normal_colors)) } } - - render() { const { color, allowClear, colors } = this.state -- Gitblit v1.8.0