From da64ab0923bf8817fc8599a6e37b953ce38f64c8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 27 八月 2023 18:37:36 +0800 Subject: [PATCH] 2023-08-27 --- src/menu/stylecontroller/index.jsx | 229 +++++++++++++++++++++++++++++---------------------------- 1 files changed, 117 insertions(+), 112 deletions(-) diff --git a/src/menu/stylecontroller/index.jsx b/src/menu/stylecontroller/index.jsx index 6acd6cc..163a7c6 100644 --- a/src/menu/stylecontroller/index.jsx +++ b/src/menu/stylecontroller/index.jsx @@ -1,5 +1,4 @@ import React, {Component} from 'react' -import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' import { Collapse, Form, Col, InputNumber, Input, Select, Radio, Drawer, Button, message } from 'antd' import { @@ -29,7 +28,8 @@ ArrowLeftOutlined, ArrowRightOutlined, SwapOutlined, - EnterOutlined + EnterOutlined, + DragOutlined } from '@ant-design/icons' import MKEmitter from '@/utils/events.js' @@ -46,11 +46,6 @@ const SourceComponent = asyncComponent(() => import('@/menu/components/share/sourcecomponent')) class MobController extends Component { - static propTpyes = { - editElem: PropTypes.any, - updateStyle: PropTypes.func, - } - state = { card: null, fonts: null, @@ -168,7 +163,7 @@ this.callback = null } - updateStyle = (style, prop) => { + updateStyle = (style) => { const { card } = this.state let _style = { @@ -176,8 +171,20 @@ ...style } - if (prop && !_style[prop]) { - delete _style[prop] + Object.keys(style).forEach(key => { + if (!_style[key] && _style[key] !== 0) { + delete _style[key] + } + }) + + if (_style.position === 'relative') { + _style.zIndex = 1 + } else if (_style.position === 'absolute') { + _style.zIndex = 2 + } else if (_style.position === 'fixed') { + _style.zIndex = 3 + } else { + delete _style.zIndex } this.setState({ @@ -237,55 +244,6 @@ this.updateStyle({textIndent: `${value}px`}) } - /** - * @description 淇敼瀛椾綋绮楃粏 - */ - boldChange = (val) => { - this.updateStyle({fontWeight: val}) - } - - /** - * @description 鑷姩鎹㈣ - */ - wordBreakChange = (val) => { - this.updateStyle({wordBreak: val}) - } - - /** - * @description 淇敼瀛椾綋棰滆壊 锛岄鑹叉帶浠� - */ - changeFontColor = (val) => { - this.updateStyle({color: val}) - } - - /** - * @description 瀛椾綋瀵归綈 - */ - changeTextAlign = (e) => { - this.updateStyle({textAlign: e.target.value}) - } - - /** - * @description 瀛椾綋鏍峰紡锛屽�炬枩 - */ - changeFontStyle = (e) => { - this.updateStyle({fontStyle: e.target.value}) - } - - /** - * @description 瀛椾綋瑁呴グ锛屼笅鍒掔嚎銆佽疮绌跨嚎銆佷笂鍒掔嚎 - */ - changeTextDecoration = (e) => { - this.updateStyle({textDecoration: e.target.value}) - } - - /** - * @description 淇敼鑳屾櫙棰滆壊 锛岄鑹叉帶浠� - */ - changeBackgroundColor = (val) => { - this.updateStyle({backgroundColor: val}, 'backgroundColor') - } - changeBackground = (val) => { const { card } = this.state @@ -307,27 +265,6 @@ if (!val || /(^linear-gradient|^radial-gradient)\(.*\)$/.test(val)) { this.callback && this.callback(_style) } - } - - /** - * @description 淇敼鑳屾櫙澶у皬 - */ - changeBackgroundSize = (val) => { - this.updateStyle({backgroundSize: val}) - } - - /** - * @description 淇敼鑳屾櫙浣嶇疆 - */ - changeBackgroundPositon= (val) => { - this.updateStyle({backgroundPosition: val}) - } - - /** - * @description 淇敼鑳屾櫙閲嶅璁剧疆 - */ - changeBackgroundRepeat = (val) => { - this.updateStyle({backgroundRepeat: val}) } /** @@ -440,14 +377,6 @@ } this.updateStyle(_style) - } - - changeWidth = (val) => { - this.updateStyle({width: val === '0px' ? '' : val}, 'width') - } - - changeHeight = (val) => { - this.updateStyle({height: val === '0px' ? '' : val}, 'height') } changeNormalStyle = (val, type) => { @@ -564,7 +493,7 @@ label={<ColumnWidthOutlined title="瀹藉害"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.width || ''} options={['px', 'vh', 'vw', '%', 'auto']} onChange={this.changeWidth}/> + <StyleInput clear={true} defaultValue={card.width || ''} options={['px', 'vh', 'vw', '%', 'auto']} onChange={(val) => this.changeNormalStyle(val, 'width')}/> </Form.Item> </Col> </Panel> : null} @@ -575,7 +504,7 @@ label={<ColumnHeightOutlined title="楂樺害"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.height || ''} options={['px', 'vh', 'vw']} onChange={this.changeHeight}/> + <StyleInput clear={true} defaultValue={card.height || ''} options={['px', 'vh', 'vw']} onChange={(val) => this.changeNormalStyle(val, 'height')}/> </Form.Item> </Col> </Panel> : null} @@ -587,7 +516,7 @@ </Col> : null} {fonts.includes('fontWeight') ? <Col span={12}> <Form.Item colon={false} label={<BoldOutlined title="瀛椾綋绮楃粏"/>}> - <Select defaultValue={card.fontWeight || 'normal'} onChange={this.boldChange}> + <Select defaultValue={card.fontWeight || 'normal'} onChange={(val) => this.changeNormalStyle(val, 'fontWeight')}> <Option value="normal">normal</Option> <Option value="bold">bold</Option> <Option value="bolder">bolder</Option> @@ -621,7 +550,7 @@ </Col> : null} {fonts.includes('wordBreak') ? <Col span={12}> <Form.Item colon={false} label={<EnterOutlined title="鑷姩鎹㈣"/>}> - <Select defaultValue={card.wordBreak || 'normal'} onChange={this.wordBreakChange}> + <Select defaultValue={card.wordBreak || 'normal'} onChange={(val) => this.changeNormalStyle(val, 'wordBreak')}> <Option value="normal">normal</Option> <Option value="break-all">break-all</Option> </Select> @@ -633,14 +562,14 @@ label={<FontColorsOutlined title="瀛椾綋棰滆壊"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <ColorSketch value={card.color || ''} onChange={this.changeFontColor} /> + <ColorSketch value={card.color || ''} onChange={(val) => this.changeNormalStyle(val, 'color')} /> </Form.Item> <Form.Item colon={false} label={<BgColorsOutlined title="绯荤粺鑹�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <SysColorSketch onChange={this.changeFontColor} /> + <SysColorSketch onChange={(val) => this.changeNormalStyle(val, 'color')} /> </Form.Item> </Col> : null} {fonts.includes('fontStyle') ? <Col span={24}> @@ -649,7 +578,7 @@ label={' '} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <Radio.Group defaultValue={card.fontStyle || 'normal'} onChange={this.changeFontStyle}> + <Radio.Group defaultValue={card.fontStyle || 'normal'} onChange={(e) => this.changeNormalStyle(e.target.value, 'fontStyle')}> <Radio.Button value="normal"><span title="鏍囧噯">N</span></Radio.Button> <Radio.Button value="italic"><ItalicOutlined title="鏂滀綋"/></Radio.Button> <Radio.Button value="oblique" style={{fontStyle: 'oblique'}}><span title="鍊炬枩">B</span></Radio.Button> @@ -662,7 +591,7 @@ label={' '} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <Radio.Group className="text-align" defaultValue={card.textAlign || 'left'} onChange={this.changeTextAlign}> + <Radio.Group className="text-align" defaultValue={card.textAlign || 'left'} onChange={(e) => this.changeNormalStyle(e.target.value, 'textAlign')}> <Radio.Button value="left"><AlignLeftOutlined title="宸﹀榻�"/></Radio.Button> <Radio.Button value="center"><AlignCenterOutlined title="灞呬腑瀵归綈"/></Radio.Button> <Radio.Button value="right"><AlignRightOutlined title="鍙冲榻�"/></Radio.Button> @@ -675,7 +604,7 @@ label={' '} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <Radio.Group className="text-decoration" defaultValue={card.textDecoration || 'none'} onChange={this.changeTextDecoration}> + <Radio.Group className="text-decoration" defaultValue={card.textDecoration || 'none'} onChange={(e) => this.changeNormalStyle(e.target.value, 'textDecoration')}> <Radio.Button value="none"><span title="鏍囧噯">N</span></Radio.Button> <Radio.Button value="underline"><UnderlineOutlined title="涓嬪垝绾�"/></Radio.Button> <Radio.Button value="line-through"><StrikethroughOutlined title="涓垝绾�"/></Radio.Button> @@ -691,14 +620,14 @@ label={<BgColorsOutlined title="鑳屾櫙棰滆壊"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <ColorSketch allowClear={true} value={card.backgroundColor || ''} onChange={this.changeBackgroundColor} /> + <ColorSketch allowClear={true} value={card.backgroundColor || ''} onChange={(val) => this.changeNormalStyle(val, 'backgroundColor')} /> </Form.Item> <Form.Item colon={false} label={<BgColorsOutlined title="绯荤粺鑹�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <SysColorSketch onChange={this.changeBackgroundColor} /> + <SysColorSketch onChange={(val) => this.changeNormalStyle(val, 'backgroundColor')} /> </Form.Item> </Col> {window.develop === true ? <Col span={24}> @@ -725,7 +654,7 @@ label="姣斾緥" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <Select defaultValue={card.backgroundSize || 'cover'} onChange={this.changeBackgroundSize}> + <Select defaultValue={card.backgroundSize || 'cover'} onChange={(val) => this.changeNormalStyle(val, 'backgroundSize')}> <Option value="100%">100%</Option> <Option value="100% 100%">100% 100%</Option> <Option value="auto 100%">auto 100%</Option> @@ -742,7 +671,7 @@ label="閲嶅" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <Select defaultValue={card.backgroundRepeat || 'no-repeat'} onChange={this.changeBackgroundRepeat}> + <Select defaultValue={card.backgroundRepeat || 'no-repeat'} onChange={(val) => this.changeNormalStyle(val, 'backgroundRepeat')}> <Option value="repeat">repeat</Option> <Option value="no-repeat">no-repeat</Option> <Option value="repeat-x">repeat-x</Option> @@ -756,7 +685,7 @@ label="浣嶇疆" labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <Select defaultValue={card.backgroundPosition || 'center'} onChange={this.changeBackgroundPositon}> + <Select defaultValue={card.backgroundPosition || 'center'} onChange={(val) => this.changeNormalStyle(val, 'backgroundPosition')}> <Option value="center">center</Option> <Option value="center top">center top</Option> <Option value="center bottom">center bottom</Option> @@ -863,7 +792,7 @@ label={<RadiusSettingOutlined title="鍦嗚"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.borderRadius || '0px'} options={['px', '%']} onChange={(val) => this.changeNormalStyle(val, 'borderRadius')}/> + <StyleInput clear={true} defaultValue={card.borderRadius || ''} options={['px', '%']} onChange={(val) => this.changeNormalStyle(val, 'borderRadius')}/> </Form.Item> </Col> </Panel> : null} @@ -919,7 +848,7 @@ label={<ArrowUpOutlined title="涓婅竟璺�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.marginTop || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginTop')}/> + <StyleInput clear={true} defaultValue={card.marginTop || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginTop')}/> </Form.Item> </Col> <Col span={24}> @@ -928,7 +857,7 @@ label={<ArrowDownOutlined title="涓嬭竟璺�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.marginBottom || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginBottom')}/> + <StyleInput clear={true} defaultValue={card.marginBottom || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginBottom')}/> </Form.Item> </Col> <Col span={24}> @@ -937,7 +866,7 @@ label={<ArrowLeftOutlined title="宸﹁竟璺�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.marginLeft || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginLeft')}/> + <StyleInput clear={true} defaultValue={card.marginLeft || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginLeft')}/> </Form.Item> </Col> <Col span={24}> @@ -946,7 +875,7 @@ label={<ArrowRightOutlined title="鍙宠竟璺�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.marginRight || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginRight')}/> + <StyleInput clear={true} defaultValue={card.marginRight || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'marginRight')}/> </Form.Item> </Col> </Panel> : null} @@ -957,7 +886,7 @@ label={<ArrowUpOutlined title="涓婅竟璺�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.paddingTop || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingTop')}/> + <StyleInput clear={true} defaultValue={card.paddingTop || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingTop')}/> </Form.Item> </Col> <Col span={24}> @@ -966,7 +895,7 @@ label={<ArrowDownOutlined title="涓嬭竟璺�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.paddingBottom || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingBottom')}/> + <StyleInput clear={true} defaultValue={card.paddingBottom || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingBottom')}/> </Form.Item> </Col> <Col span={24}> @@ -975,7 +904,7 @@ label={<ArrowLeftOutlined title="宸﹁竟璺�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.paddingLeft || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingLeft')}/> + <StyleInput clear={true} defaultValue={card.paddingLeft || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingLeft')}/> </Form.Item> </Col> <Col span={24}> @@ -984,7 +913,7 @@ label={<ArrowRightOutlined title="鍙宠竟璺�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.paddingRight || '0px'} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingRight')}/> + <StyleInput clear={true} defaultValue={card.paddingRight || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'paddingRight')}/> </Form.Item> </Col> </Panel> : null} @@ -1010,7 +939,7 @@ label={<ColumnHeightOutlined title="鏈�灏忛珮搴�"/>} labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } > - <StyleInput defaultValue={card.minHeight || ''} options={['px', 'vh', 'vw']} onChange={(val) => this.changeNormalStyle(val, 'minHeight')}/> + <StyleInput clear={true} defaultValue={card.minHeight || ''} options={['px', 'vh', 'vw']} onChange={(val) => this.changeNormalStyle(val, 'minHeight')}/> </Form.Item> </Col> </Panel> : null} @@ -1024,6 +953,7 @@ <Radio.Group style={{whiteSpace: 'nowrap'}} defaultValue={card.clear || 'none'} onChange={(e) => this.changeNormalStyle(e.target.value, 'clear')}> <Radio value="none">宸︽诞鍔�</Radio> <Radio value="left">涓嶆诞鍔�</Radio> + <Radio value="right">鍙虫诞鍔�</Radio> </Radio.Group> </Form.Item> </Col> @@ -1042,6 +972,81 @@ </Form.Item> </Col> </Panel> : null} + {options.includes('position') ? <Panel header="瀹氫綅" key="position"> + <div style={{paddingLeft: '35px', fontSize: '12px'}}>娉細瀹氫綅鏁堟灉璇峰湪杩愯鐜涓煡鐪嬨��</div> + <Col span={24}> + <Form.Item + colon={false} + label={<SwapOutlined title="瀹氫綅"/>} + labelCol={{xs: { span: 24 }, sm: { span: 3 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 21 }} } + > + <Radio.Group style={{whiteSpace: 'nowrap'}} defaultValue={card.position || 'unset'} onChange={(e) => this.changeNormalStyle(e.target.value, 'position')}> + <Radio value="unset">鏃�</Radio> + <Radio value="relative">鐩稿</Radio> + <Radio value="absolute">缁濆</Radio> + <Radio value="fixed">鍥哄畾</Radio> + </Radio.Group> + </Form.Item> + </Col> + <Col span={24}> + <Form.Item + colon={false} + label={<ArrowUpOutlined title="涓�"/>} + labelCol={{xs: { span: 24 }, sm: { span: 3 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 21 }} } + > + <StyleInput clear={true} defaultValue={card.top || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'top')}/> + </Form.Item> + </Col> + <Col span={24}> + <Form.Item + colon={false} + label={<ArrowDownOutlined title="涓�"/>} + labelCol={{xs: { span: 24 }, sm: { span: 3 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 21 }} } + > + <StyleInput clear={true} defaultValue={card.bottom || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'bottom')}/> + </Form.Item> + </Col> + <Col span={24}> + <Form.Item + colon={false} + label={<ArrowLeftOutlined title="宸�"/>} + labelCol={{xs: { span: 24 }, sm: { span: 3 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 21 }} } + > + <StyleInput clear={true} defaultValue={card.left || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'left')}/> + </Form.Item> + </Col> + <Col span={24}> + <Form.Item + colon={false} + label={<ArrowRightOutlined title="鍙�"/>} + labelCol={{xs: { span: 24 }, sm: { span: 3 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 21 }} } + > + <StyleInput clear={true} defaultValue={card.right || ''} options={['px', 'vh', 'vw', '%']} onChange={(val) => this.changeNormalStyle(val, 'right')}/> + </Form.Item> + </Col> + </Panel> : null} + {options.includes('transform') ? <Panel header="浣嶇疆鍙樻崲" key="transform"> + <div style={{paddingLeft: '50px', fontSize: '12px'}}>娉細鍙樻崲鏁堟灉璇峰湪杩愯鐜涓煡鐪嬨��</div> + <Col span={24}> + <Form.Item + colon={false} + label={<DragOutlined title="鍙樻崲"/>} + labelCol={{xs: { span: 24 }, sm: { span: 4 }}} wrapperCol={ {xs: { span: 24 }, sm: { span: 20 }} } + > + <Select defaultValue={card.transform || ''} onChange={(val) => this.changeNormalStyle(val, 'transform')}> + <Option value="">鏃�</Option> + <Option value="translateY(-50%)">涓婄Щ50%</Option> + <Option value="translateY(50%)">涓嬬Щ50%</Option> + <Option value="translateX(-50%)">宸︾Щ50%</Option> + <Option value="translateX(50%)">鍙崇Щ50%</Option> + <Option value="translate(-50%, -50%)">宸︿笂绉�50%</Option> + <Option value="translate(-50%, 50%)">宸︿笅绉�50%</Option> + <Option value="translate(50%, -50%)">鍙充笂绉�50%</Option> + <Option value="translate(50%, 50%)">鍙充笅绉�50%</Option> + </Select> + </Form.Item> + </Col> + </Panel> : null} </Collapse> : null} </Form> <div style={{textAlign: 'right', lineHeight: '60px', marginBottom: '30px'}}> -- Gitblit v1.8.0