Skip to content

Commit

Permalink
fix: 修复同步数据源耗时展示错误问题 (#1970)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoJohw authored Nov 7, 2024
1 parent 9329537 commit 5b04542
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 32 deletions.
23 changes: 7 additions & 16 deletions src/pages/src/components/SyncRecords.vue
Original file line number Diff line number Diff line change
Expand Up @@ -173,25 +173,16 @@ const getSyncRecordsList = async () => {
}
};
const durationText = (value) => {
const durationText = (value: string) => {
if (value) {
value = value.slice(6);
if (value < 60) {
const [hour, min, sec] = value.split(':').map(Number);
const roundedSec = Math.round(sec);
if (min < 1) {
return `<1 ${t('分钟')}`;
} if (hour < 1) {
return `${min} ${t('分钟')}${roundedSec > 0 ? ` ${roundedSec} ${t('')}` : ''}`;
}
if (60 <= value && value < 3600) {
const time = value / 60;
const min = time.toString().split('.')[0];
const sec = parseInt(time.toString().split('.')[1][0], 10) * 6;
return `${min} ${t('分钟')} ${sec} ${t('')}`;
}
if (3600 <= value) {
const time = value / 3600;
const hour = time.toString().split('.')[0];
const min = parseInt(time.toString().split('.')[1][0], 10) * 6;
return `${hour}小时${min}分钟`;
}
return value;
return `${hour}小时${min}分钟`;
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -482,25 +482,16 @@ const handleRowExpand = async ({ row }) => {
}
};
const durationText = (value) => {
const durationText = (value: string) => {
if (value) {
value = value.slice(6);
if (value < 60) {
const [hour, min, sec] = value.split(':').map(Number);
const roundedSec = Math.round(sec);
if (min < 1) {
return `<1 ${t('分钟')}`;
} if (hour < 1) {
return `${min} ${t('分钟')}${roundedSec > 0 ? ` ${roundedSec} ${t('')}` : ''}`;
}
if (60 <= value && value < 3600) {
const time = value / 60;
const min = time.toString().split('.')[0];
const sec = parseInt(time.toString().split('.')[1][0], 10) * 6;
return `${min} ${t('分钟')} ${sec} ${t('')}`;
}
if (3600 <= value) {
const time = value / 3600;
const hour = time.toString().split('.')[0];
const min = parseInt(time.toString().split('.')[1][0], 10) * 6;
return `${hour}小时${min}分钟`;
}
return value;
return `${hour}小时${min}分钟`;
}
};
</script>
Expand Down

0 comments on commit 5b04542

Please sign in to comment.