From 5d8eb51419d2c1b7dc88dd0cbde5c8341cceda2f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 24 二月 2023 18:01:14 +0800 Subject: [PATCH] 2023-02-24 --- src/menu/stylecontroller/index.jsx | 32 +++++++++----------------------- 1 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/menu/stylecontroller/index.jsx b/src/menu/stylecontroller/index.jsx index b795e25..e06a198 100644 --- a/src/menu/stylecontroller/index.jsx +++ b/src/menu/stylecontroller/index.jsx @@ -167,12 +167,16 @@ this.callback = null } - updateStyle = (style) => { + updateStyle = (style, prop) => { const { card } = this.state let _style = { ...card, ...style + } + + if (prop && !_style[prop]) { + delete _style[prop] } this.setState({ @@ -278,7 +282,7 @@ * @description 淇敼鑳屾櫙棰滆壊 锛岄鑹叉帶浠� */ changeBackgroundColor = (val) => { - this.updateStyle({backgroundColor: val}) + this.updateStyle({backgroundColor: val}, 'backgroundColor') } changeBackground = (val) => { @@ -438,29 +442,11 @@ } changeWidth = (val) => { - const { card } = this.state - let _style = {...card} - - if (val === '0px') { - delete _style.width - } else { - _style.width = val - } - - this.setState({ - card: _style - }) - - this.callback && this.callback(_style) + this.updateStyle({width: val === '0px' ? '' : val}, 'width') } changeHeight = (val) => { - let _val = val - if (_val === '0px') { - _val = 'auto' - } - - this.updateStyle({height: _val}) + this.updateStyle({height: val === '0px' ? '' : val}, 'height') } changeNormalStyle = (val, type) => { @@ -633,7 +619,7 @@ label={<BgColorsOutlined title="鑳屾櫙棰滆壊"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <ColorSketch value={card.backgroundColor || '#ffffff'} onChange={this.changeBackgroundColor} /> + <ColorSketch allowClear={true} value={card.backgroundColor || ''} onChange={this.changeBackgroundColor} /> </Form.Item> <Form.Item colon={false} -- Gitblit v1.8.0