From 5b04542e8474fe144ff803a924f093a736ce4dc0 Mon Sep 17 00:00:00 2001 From: JoJo_ <92574547+JoJohw@users.noreply.github.com> Date: Thu, 7 Nov 2024 14:21:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=BA=90=E8=80=97=E6=97=B6=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=20(#1970)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/src/components/SyncRecords.vue | 23 ++++++------------- .../other-share/index.vue | 23 ++++++------------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/src/pages/src/components/SyncRecords.vue b/src/pages/src/components/SyncRecords.vue index 7e8811fb8..4657cb5ea 100644 --- a/src/pages/src/components/SyncRecords.vue +++ b/src/pages/src/components/SyncRecords.vue @@ -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}分钟`; } }; diff --git a/src/pages/src/views/setting/cross-tenant-collaboration/other-share/index.vue b/src/pages/src/views/setting/cross-tenant-collaboration/other-share/index.vue index d7aba4f88..b7581fea9 100644 --- a/src/pages/src/views/setting/cross-tenant-collaboration/other-share/index.vue +++ b/src/pages/src/views/setting/cross-tenant-collaboration/other-share/index.vue @@ -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}分钟`; } };