From ace93f1b427343ca47f4dbc4aba9337da0cd9ed8 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 8 Apr 2019 22:48:34 +0800 Subject: [PATCH] :art: refactor some code --- components/progress/progress.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/components/progress/progress.tsx b/components/progress/progress.tsx index 1d99e459fc..42c15d1aab 100644 --- a/components/progress/progress.tsx +++ b/components/progress/progress.tsx @@ -61,13 +61,17 @@ export default class Progress extends React.Component { default: PropTypes.oneOf(['default', 'small']), }; - getProgressStatus() { - const { successPercent, percent = 0, status } = this.props; - const percentNumber = parseInt( + getPercentNumber() { + const { successPercent, percent = 0 } = this.props; + return parseInt( successPercent !== undefined ? successPercent.toString() : percent.toString(), 10, ); - if (percentNumber >= 100 && ProgressStatuses.indexOf(status!) < 0) { + } + + getProgressStatus() { + const { status } = this.props; + if (ProgressStatuses.indexOf(status!) < 0 && this.getPercentNumber() >= 100) { return 'success'; } return status || 'normal';