From 51675f6129752ccdbf1e987b2228043333c9af11 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Thu, 2 May 2024 01:25:55 +0800 Subject: [PATCH] refactor: improve server list update at display --- src/client/components/server/ServerList.tsx | 2 +- src/client/utils/date.ts | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/client/components/server/ServerList.tsx b/src/client/components/server/ServerList.tsx index 194310e..7a922fe 100644 --- a/src/client/components/server/ServerList.tsx +++ b/src/client/components/server/ServerList.tsx @@ -136,7 +136,7 @@ export const ServerList: React.FC = React.memo((props) => { columnHelper.accessor('updatedAt', { header: t('updatedAt'), size: 130, - cell: (props) => dayjs(props.getValue()).format('MMM D HH:mm:ss'), + cell: (props) => dayjs(props.getValue()).fromNow(), }), ]; }, [t]); diff --git a/src/client/utils/date.ts b/src/client/utils/date.ts index a10777d..d24f945 100644 --- a/src/client/utils/date.ts +++ b/src/client/utils/date.ts @@ -1,11 +1,13 @@ import dayjs from 'dayjs'; import utc from 'dayjs/plugin/utc'; import timezone from 'dayjs/plugin/timezone'; +import relativeTime from 'dayjs/plugin/relativeTime'; import advancedFormat from 'dayjs/plugin/advancedFormat'; import type { DateUnit } from '@tianji/shared'; dayjs.extend(utc); dayjs.extend(timezone); +dayjs.extend(relativeTime); dayjs.extend(advancedFormat); export type { DateUnit };