From 479bb9452596cc6b085f49b78821adfbecbe752d Mon Sep 17 00:00:00 2001 From: Morning <150018138+mazongYY@users.noreply.github.com> Date: Sat, 12 Sep 2026 12:53:45 +0800 Subject: [PATCH] fix(frontend): format created_at and updated_at with local date across admin views (#1146) * fix: format created_at and updated_at with local date in admin account view * fix(frontend): format created_at with local date in user management and sender access views * fix(frontend): guard utcToLocalDate against null or empty timestamps --- frontend/src/utils/index.ts | 3 ++- frontend/src/views/admin/Account.vue | 15 +++++++++++---- frontend/src/views/admin/SenderAccess.vue | 8 ++++++-- frontend/src/views/admin/UserManagement.vue | 9 ++++++--- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 5e0864b0..c2d82c99 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -19,7 +19,8 @@ export const getRouterPathWithLang = (path: string, lang: string) => { return getPathWithLocale(path, normalizedLang); } -export const utcToLocalDate = (utcDate: string, useUTCDate: boolean) => { +export const utcToLocalDate = (utcDate: string | null | undefined, useUTCDate: boolean) => { + if (!utcDate) return ''; const utcDateString = `${utcDate} UTC`; if (useUTCDate) { return utcDateString; diff --git a/frontend/src/views/admin/Account.vue b/frontend/src/views/admin/Account.vue index 423dfc2d..94d18e4c 100644 --- a/frontend/src/views/admin/Account.vue +++ b/frontend/src/views/admin/Account.vue @@ -5,14 +5,15 @@ import { useScopedI18n } from '@/i18n/app' import { useGlobalState } from '../../store' import { api } from '../../api' -import { hashPassword } from '../../utils' +import { hashPassword, utcToLocalDate } from '../../utils' import { NButton, NMenu } from 'naive-ui'; import { MenuFilled } from '@vicons/material' import AddressCredentialModal from '../../components/AddressCredentialModal.vue' const { loading, adminTab, openSettings, - adminMailTabAddress, adminSendBoxTabAddress + adminMailTabAddress, adminSendBoxTabAddress, + useUTCDate } = useGlobalState() const message = useMessage() @@ -274,13 +275,19 @@ const columns = computed(() => [ title: t('created_at'), key: "created_at", sorter: true, - sortOrder: sortBy.value === 'created_at' ? sortOrder.value : false + sortOrder: sortBy.value === 'created_at' ? sortOrder.value : false, + render(row) { + return utcToLocalDate(row.created_at, useUTCDate.value); + } }, { title: t('updated_at'), key: "updated_at", sorter: true, - sortOrder: sortBy.value === 'updated_at' ? sortOrder.value : false + sortOrder: sortBy.value === 'updated_at' ? sortOrder.value : false, + render(row) { + return utcToLocalDate(row.updated_at, useUTCDate.value); + } }, { title: t('source_meta'), diff --git a/frontend/src/views/admin/SenderAccess.vue b/frontend/src/views/admin/SenderAccess.vue index 2efab176..3f5db3b1 100644 --- a/frontend/src/views/admin/SenderAccess.vue +++ b/frontend/src/views/admin/SenderAccess.vue @@ -4,8 +4,9 @@ import { useScopedI18n } from '@/i18n/app' import { useGlobalState } from '../../store' import { api } from '../../api' +import { utcToLocalDate } from '../../utils'; -const { loading } = useGlobalState() +const { loading, useUTCDate } = useGlobalState() const message = useMessage() const { t } = useScopedI18n('views.admin.SenderAccess') @@ -70,7 +71,10 @@ const columns = [ }, { title: t('created_at'), - key: "created_at" + key: "created_at", + render(row) { + return utcToLocalDate(row.created_at, useUTCDate.value); + } }, { title: t('balance'), diff --git a/frontend/src/views/admin/UserManagement.vue b/frontend/src/views/admin/UserManagement.vue index c890a7e9..f802ebcb 100644 --- a/frontend/src/views/admin/UserManagement.vue +++ b/frontend/src/views/admin/UserManagement.vue @@ -6,11 +6,11 @@ import { MenuFilled } from '@vicons/material' import { useGlobalState } from '../../store' import { api } from '../../api' -import { hashPassword } from '../../utils'; +import { hashPassword, utcToLocalDate } from '../../utils'; import UserAddressManagement from './UserAddressManagement.vue' -const { loading, openSettings } = useGlobalState() +const { loading, openSettings, useUTCDate } = useGlobalState() const message = useMessage() const { t } = useScopedI18n('views.admin.UserManagement') @@ -193,7 +193,10 @@ const columns = [ }, { title: t('created_at'), - key: "created_at" + key: "created_at", + render(row) { + return utcToLocalDate(row.created_at, useUTCDate.value); + } }, { title: t('actions'),