代码优化。

This commit is contained in:
tengge1 2019-12-26 21:06:40 +08:00
parent 02063dd6a2
commit aa983a433c
8 changed files with 39 additions and 28 deletions

View File

@ -19,18 +19,19 @@ class Canvas extends React.Component {
className={classNames('Canvas', className)}
style={style}
ref={this.dom}
{...others}></canvas>;
{...others}
/>;
}
}
Canvas.propTypes = {
className: PropTypes.string,
style: PropTypes.object,
style: PropTypes.object
};
Canvas.defaultProps = {
className: null,
style: null,
style: null
};
export default Canvas;

View File

@ -23,7 +23,8 @@ class Icon extends React.Component {
name={name}
value={value}
title={title}
onClick={this.handleClick}></i>;
onClick={this.handleClick}
/>;
}
handleClick(event) {
@ -41,7 +42,7 @@ Icon.propTypes = {
value: PropTypes.string,
icon: PropTypes.string,
title: PropTypes.string,
onClick: PropTypes.func,
onClick: PropTypes.func
};
Icon.defaultProps = {
@ -51,7 +52,7 @@ Icon.defaultProps = {
value: null,
icon: null,
title: null,
onClick: null,
onClick: null
};
export default Icon;

View File

@ -21,7 +21,8 @@ class Image extends React.Component {
style={style}
src={src}
title={title}
onError={this.handleError}></img>;
onError={this.handleError}
/>;
}
handleError(event) {
@ -45,14 +46,14 @@ Image.propTypes = {
className: PropTypes.string,
style: PropTypes.object,
src: PropTypes.string,
title: PropTypes.string,
title: PropTypes.string
};
Image.defaultProps = {
className: null,
style: null,
src: null,
title: null,
title: null
};
export default Image;

View File

@ -22,12 +22,14 @@ class ImageSelector extends React.Component {
className={classNames('ImageSelector', className)}
style={style}
src={value}
onClick={this.handleSelect} />;
onClick={this.handleSelect}
/>;
} else {
return <div
className={classNames('ImageSelector', 'empty', className)}
style={style}
onClick={this.handleSelect}>
onClick={this.handleSelect}
>
{noImageText}
</div>;
}
@ -70,7 +72,7 @@ ImageSelector.propTypes = {
name: PropTypes.string,
value: PropTypes.any,
noImageText: PropTypes.string,
onChange: PropTypes.func,
onChange: PropTypes.func
};
ImageSelector.defaultProps = {
@ -79,7 +81,7 @@ ImageSelector.defaultProps = {
name: null,
value: null,
noImageText: 'No Image',
onChange: null,
onChange: null
};
export default ImageSelector;

View File

@ -17,15 +17,18 @@ class ImageUploader extends React.Component {
render() {
const { className, style, url, server, noImageText } = this.props;
if (url && url != 'null') {
if (url && url !== 'null') {
return <img
className={classNames('ImageUploader', className)}
style={style}
src={server + url}
onClick={this.handleSelect} />;
onClick={this.handleSelect}
/>;
} else {
return <div
className={classNames('ImageUploader', 'empty', className)}
onClick={this.handleSelect}>
onClick={this.handleSelect}
>
{noImageText}
</div>;
}
@ -67,7 +70,7 @@ ImageUploader.propTypes = {
url: PropTypes.string,
server: PropTypes.string,
noImageText: PropTypes.string,
onChange: PropTypes.func,
onChange: PropTypes.func
};
ImageUploader.defaultProps = {
@ -76,7 +79,7 @@ ImageUploader.defaultProps = {
url: null,
server: '',
noImageText: 'No Image',
onChange: null,
onChange: null
};
export default ImageUploader;

View File

@ -12,13 +12,14 @@ class AbsoluteLayout extends React.Component {
const position = {
left: left || 0,
top: top || 0,
top: top || 0
};
return <div
className={classNames('AbsoluteLayout', className)}
style={style ? Object.assign({}, style, position) : position}
{...others}>{children}</div>;
{...others}
>{children}</div>;
}
}
@ -27,7 +28,7 @@ AbsoluteLayout.propTypes = {
style: PropTypes.object,
children: PropTypes.node,
left: PropTypes.string,
top: PropTypes.string,
top: PropTypes.string
};
AbsoluteLayout.defaultProps = {
@ -35,7 +36,7 @@ AbsoluteLayout.defaultProps = {
style: null,
children: null,
left: '0',
top: '0',
top: '0'
};
export default AbsoluteLayout;

View File

@ -13,20 +13,21 @@ class HBoxLayout extends React.Component {
return <div
className={classNames('HBoxLayout', className)}
style={style}
{...others}>{children}</div>;
{...others}
>{children}</div>;
}
}
HBoxLayout.propTypes = {
className: PropTypes.string,
style: PropTypes.object,
children: PropTypes.node,
children: PropTypes.node
};
HBoxLayout.defaultProps = {
className: null,
style: null,
children: null,
children: null
};
export default HBoxLayout;

View File

@ -13,20 +13,21 @@ class VBoxLayout extends React.Component {
return <div
className={classNames('VBoxLayout', className)}
style={style}
{...others}>{children}</div>;
{...others}
>{children}</div>;
}
}
VBoxLayout.propTypes = {
className: PropTypes.string,
style: PropTypes.object,
children: PropTypes.node,
children: PropTypes.node
};
VBoxLayout.defaultProps = {
className: null,
style: null,
children: null,
children: null
};
export default VBoxLayout;