From 0472ec32cadb4f9bca6dbab82ac33a42e76f37ed Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 28 六月 2022 16:24:15 +0800 Subject: [PATCH] 菜单栏&时间轴 --- src/menu/bgcontroller/index.jsx | 34 ++++++++++++++++++++++++++++++++-- 1 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/menu/bgcontroller/index.jsx b/src/menu/bgcontroller/index.jsx index 9a0f560..ba87f28 100644 --- a/src/menu/bgcontroller/index.jsx +++ b/src/menu/bgcontroller/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Form, Select } from 'antd' +import { Form, Select, Input } from 'antd' import asyncComponent from '@/utils/asyncComponent' import './index.scss' @@ -17,6 +17,7 @@ } state = { + background: '', backgroundColor: '', backgroundImage: '', backgroundSize: '', @@ -34,6 +35,7 @@ } this.setState({ + background: config.style.background || '', backgroundColor: config.style.backgroundColor, backgroundImage: bgImg, backgroundSize: config.style.backgroundSize || '100%', @@ -96,8 +98,33 @@ this.props.updateConfig(config) } + changeBackground = (val) => { + this.setState({ + background: val, + }) + + if (!val || /(^linear-gradient|^radial-gradient)\(.*\)$/.test(val)) { + let config = fromJS(this.props.config).toJS() + config.style.background = val + + delete config.style.backgroundColor + delete config.style.backgroundImage + + if (!val) { + delete config.style.background + } + + this.setState({ + backgroundImage: '', + backgroundColor: '' + }) + + this.props.updateConfig(config) + } + } + render () { - const { backgroundColor, backgroundImage, backgroundSize, backgroundRepeat } = this.state + const { backgroundColor, backgroundImage, backgroundSize, backgroundRepeat, background } = this.state const formItemLayout = { labelCol: { xs: { span: 24 }, @@ -115,6 +142,9 @@ <Form.Item className="color-control" colon={false} label="棰滆壊"> <ColorSketch value={backgroundColor} onChange={this.changeBackgroundColor} /> </Form.Item> + {window.develop === true ? <Form.Item colon={false} label="棰滆壊"> + <Input value={background} onChange={(e) => this.changeBackground(e.target.value)} /> + </Form.Item> : null} <Form.Item colon={false} label="鍥剧墖"> <SourceComponent value={backgroundImage} type="" placement="right" onChange={this.imgChange}/> </Form.Item> -- Gitblit v1.8.0