| | |
| | | import { Popover } from 'antd' |
| | | import { CloseCircleFilled } from '@ant-design/icons' |
| | | |
| | | import Api from '@/api' |
| | | import './index.scss' |
| | | |
| | | const presetColors = [ |
| | |
| | | '#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 = { |
| | |
| | | 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 代表全部 |
| | | PageSize: 0, // 0 代表全部 |
| | | 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') |
| | | |
| | |
| | | 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++) { |
| | |
| | | } |
| | | } |
| | | |
| | | this.setState({color: initVal, initVal, allowClear: allowClear === true, colors}) |
| | | this.setState({colors}) |
| | | } |
| | | |
| | | handleChange = (color) => { |
| | |
| | | localStorage.setItem(_href + 'normal_colors', JSON.stringify(normal_colors)) |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | render() { |
| | | const { color, allowClear, colors } = this.state |