🎨 refactor some code

This commit is contained in:
afc163 2019-04-08 22:48:34 +08:00
parent fbcc884b5b
commit ace93f1b42
No known key found for this signature in database
GPG Key ID: 5F00908D72002306

View File

@ -61,13 +61,17 @@ export default class Progress extends React.Component<ProgressProps> {
default: PropTypes.oneOf(['default', 'small']), default: PropTypes.oneOf(['default', 'small']),
}; };
getProgressStatus() { getPercentNumber() {
const { successPercent, percent = 0, status } = this.props; const { successPercent, percent = 0 } = this.props;
const percentNumber = parseInt( return parseInt(
successPercent !== undefined ? successPercent.toString() : percent.toString(), successPercent !== undefined ? successPercent.toString() : percent.toString(),
10, 10,
); );
if (percentNumber >= 100 && ProgressStatuses.indexOf(status!) < 0) { }
getProgressStatus() {
const { status } = this.props;
if (ProgressStatuses.indexOf(status!) < 0 && this.getPercentNumber() >= 100) {
return 'success'; return 'success';
} }
return status || 'normal'; return status || 'normal';