2022-05-10 15:43:29 +08:00
|
|
|
import warning from '../_util/warning';
|
2020-08-20 15:27:16 +08:00
|
|
|
|
2019-01-18 15:19:36 +08:00
|
|
|
export function validProgress(progress: number | undefined) {
|
|
|
|
if (!progress || progress < 0) {
|
|
|
|
return 0;
|
2019-08-14 18:21:24 +08:00
|
|
|
}
|
|
|
|
if (progress > 100) {
|
2019-01-18 15:19:36 +08:00
|
|
|
return 100;
|
|
|
|
}
|
|
|
|
return progress;
|
2019-03-06 13:45:40 +08:00
|
|
|
}
|
2020-08-20 15:27:16 +08:00
|
|
|
|
|
|
|
export function getSuccessPercent({
|
|
|
|
success,
|
|
|
|
successPercent,
|
|
|
|
}: {
|
|
|
|
success?: {
|
|
|
|
progress?: number;
|
|
|
|
percent?: number;
|
|
|
|
};
|
|
|
|
successPercent?: number;
|
|
|
|
}) {
|
|
|
|
let percent = successPercent;
|
|
|
|
/** @deprecated Use `percent` instead */
|
|
|
|
if (success && 'progress' in success) {
|
2022-05-10 15:43:29 +08:00
|
|
|
warning(
|
2020-08-20 15:27:16 +08:00
|
|
|
false,
|
|
|
|
'Progress',
|
|
|
|
'`success.progress` is deprecated. Please use `success.percent` instead.',
|
|
|
|
);
|
|
|
|
percent = success.progress;
|
|
|
|
}
|
|
|
|
if (success && 'percent' in success) {
|
|
|
|
percent = success.percent;
|
|
|
|
}
|
|
|
|
return percent;
|
|
|
|
}
|