From 9e6ef86c35e500c28671c1c8731125b1d6ea5088 Mon Sep 17 00:00:00 2001 From: JoJohw <3096241994@qq.com> Date: Thu, 7 Nov 2024 14:40:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20durationText=E6=8A=BD=E7=A6=BB?= =?UTF-8?q?=E5=88=B0util=20#=20Reviewed,=20transaction=20id:=2023118?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/src/components/SyncRecords.vue | 15 +-------------- src/pages/src/utils/index.ts | 13 +++++++++++++ .../other-share/index.vue | 15 +-------------- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/src/pages/src/components/SyncRecords.vue b/src/pages/src/components/SyncRecords.vue index 4657cb5ea..c6fdd935d 100644 --- a/src/pages/src/components/SyncRecords.vue +++ b/src/pages/src/components/SyncRecords.vue @@ -97,7 +97,7 @@ import Empty from '@/components/SearchEmpty.vue'; import SQLFile from '@/components/sql-file/SQLFile.vue'; import { getSyncLogs, getSyncRecords } from '@/http'; import { t } from '@/language/index'; -import { dataRecordStatus } from '@/utils'; +import { dataRecordStatus, durationText } from '@/utils'; const props = defineProps({ dataSource: { @@ -173,19 +173,6 @@ const getSyncRecordsList = async () => { } }; -const durationText = (value: string) => { - if (value) { - 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('秒')}` : ''}`; - } - return `${hour}小时${min}分钟`; - } -}; - const dataRecordFilter = ({ checked }) => { if (checked.length === 0) { pagination.current = 1; diff --git a/src/pages/src/utils/index.ts b/src/pages/src/utils/index.ts index d21fa74de..d7f0be046 100644 --- a/src/pages/src/utils/index.ts +++ b/src/pages/src/utils/index.ts @@ -399,3 +399,16 @@ export const handleSwitchLocale = (locale: string) => { document.querySelector('html')?.setAttribute('lang', locale); window.location.reload(); }; + +export const durationText = (value: string) => { + if (value) { + 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('秒')}` : ''}`; + } + 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 b7581fea9..70dbd4b9c 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 @@ -289,7 +289,7 @@ import { useTableMaxHeight } from '@/hooks'; import { getCollaborationSyncRecords, getCollaborationSyncRecordsLogs, getFromStrategies, putFromStrategiesStatus } from '@/http'; import { t } from '@/language/index'; import { useMainViewStore, useUser } from '@/store'; -import { dataRecordStatus, dataSourceStatus } from '@/utils'; +import { dataRecordStatus, dataSourceStatus, durationText } from '@/utils'; const props = defineProps({ active: { @@ -481,19 +481,6 @@ const handleRowExpand = async ({ row }) => { }); } }; - -const durationText = (value: string) => { - if (value) { - 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('秒')}` : ''}`; - } - return `${hour}小时${min}分钟`; - } -};