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}分钟`; - } -};