From f36141f3075edf9d41928d64f759ad6bd1b1ac60 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 14 七月 2020 17:43:34 +0800 Subject: [PATCH] 2020-07-14 --- src/mob/controller/index.jsx | 61 ++++++++++-------------------- 1 files changed, 21 insertions(+), 40 deletions(-) diff --git a/src/mob/controller/index.jsx b/src/mob/controller/index.jsx index 6e822f7..a10efeb 100644 --- a/src/mob/controller/index.jsx +++ b/src/mob/controller/index.jsx @@ -65,61 +65,60 @@ return !is(fromJS(this.state), fromJS(nextState)) } + updateStyle = (style) => { + const { card } = this.state + + this.props.updateStyle({componentId: card.componentId, classId: card.classId, uuid: card.uuid, style}) + } + /** * @description 瀛椾綋澶у皬鍒囨崲锛岃秴鍑鸿寖鍥村拷鐣� */ changeFontSize = (val) => { - const { card } = this.state let value = parseInt(val) if (isNaN(value) || value < 12 || value > 100) return - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontSize: `${value}px`}}) + this.updateStyle({fontSize: `${value}px`}) } /** * @description 淇敼琛岄棿璺濓紝瓒呭嚭鑼冨洿蹇界暐 */ changeLineHeight = (val) => { - const { card } = this.state let value = parseFloat(val) if (isNaN(value) || value < 1 || value > 10) return - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {lineHeight: value}}) + this.updateStyle({lineHeight: value}) } /** * @description 瀛椾綋闂磋窛淇敼锛岃秴鍑鸿寖鍥村拷鐣� */ changeLetterSpacing = (val) => { - const { card } = this.state let value = parseFloat(val) if (isNaN(value) || value < 0 || value > 100) return - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {letterSpacing: `${value}px`}}) + this.updateStyle({letterSpacing: `${value}px`}) } /** * @description 淇敼瀛椾綋绮楃粏 */ boldChange = (val) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontWeight: val}}) + this.updateStyle({fontWeight: val}) } /** * @description 淇敼瀛椾綋棰滆壊 锛岄鑹叉帶浠� */ changeFontColor = (val) => { - const { card } = this.state - this.setState({ fontColor: val }) - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {color: val}}) + this.updateStyle({color: val}) } /** @@ -135,39 +134,31 @@ * @description 瀛椾綋瀵归綈 */ changeTextAlign = (e) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {textAlign: e.target.value}}) + this.updateStyle({textAlign: e.target.value}) } /** * @description 瀛椾綋鏍峰紡锛屽�炬枩 */ changeFontStyle = (e) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {fontStyle: e.target.value}}) + this.updateStyle({fontStyle: e.target.value}) } /** * @description 瀛椾綋瑁呴グ锛屼笅鍒掔嚎銆佽疮绌跨嚎銆佷笂鍒掔嚎 */ changeTextDecoration = (e) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {textDecoration: e.target.value}}) + this.updateStyle({textDecoration: e.target.value}) } /** * @description 淇敼鑳屾櫙棰滆壊 锛岄鑹叉帶浠� */ changeBackgroundColor = (val) => { - const { card } = this.state - this.setState({ backgroundColor: val }) - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundColor: val}}) + this.updateStyle({backgroundColor: val}) } /** @@ -180,14 +171,12 @@ } imgChange = (list) => { - const { card } = this.state - if (list[0] && list[0].response) { this.setState({ bgimages: [], backgroundImage: list[0].response }) - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundImage: `url(${list[0].response})`}}) + this.updateStyle({backgroundImage: `url(${list[0].response})`}) } else { this.setState({bgimages: list}) } @@ -200,7 +189,6 @@ } submitBackgroundImage = (e) => { - const { card } = this.state let val = e.target.value val = val.replace(/^\s*|\s*$/ig, '') @@ -210,22 +198,19 @@ val = `linear-gradient(${val})` } - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {backgroundImage: val}}) + this.updateStyle({backgroundImage: val}) } submitBorder = (val, type) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {[type]: val}}) + this.updateStyle({[type]: val}) } changeBorderRadius = (val) => { - const { card } = this.state let value = parseFloat(val) if (isNaN(value) || value < 0 || value > 500) return - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {borderRadius: `${value}px`}}) + this.updateStyle({borderRadius: `${value}px`}) } changeMarginTop = (e) => { @@ -244,12 +229,10 @@ } submitMarginTop = (val) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {marginTop: val}}) this.setState({ marginTop: val }) + this.updateStyle({marginTop: val}) } changeMarginBottom = (e) => { @@ -268,12 +251,10 @@ } submitMarginBottom = (val) => { - const { card } = this.state - - this.props.updateStyle({componentId: card.componentId, uuid: card.uuid, style: {marginBottom: val}}) this.setState({ marginBottom: val }) + this.updateStyle({marginBottom: val}) } render () { -- Gitblit v1.8.0