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
This commit is contained in:
Morning
2026-09-12 12:53:45 +08:00
committed by GitHub
parent 066fcfc8c2
commit 479bb94525
4 changed files with 25 additions and 10 deletions
+2 -1
View File
@@ -19,7 +19,8 @@ export const getRouterPathWithLang = (path: string, lang: string) => {
return getPathWithLocale(path, normalizedLang); 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`; const utcDateString = `${utcDate} UTC`;
if (useUTCDate) { if (useUTCDate) {
return utcDateString; return utcDateString;
+11 -4
View File
@@ -5,14 +5,15 @@ import { useScopedI18n } from '@/i18n/app'
import { useGlobalState } from '../../store' import { useGlobalState } from '../../store'
import { api } from '../../api' import { api } from '../../api'
import { hashPassword } from '../../utils' import { hashPassword, utcToLocalDate } from '../../utils'
import { NButton, NMenu } from 'naive-ui'; import { NButton, NMenu } from 'naive-ui';
import { MenuFilled } from '@vicons/material' import { MenuFilled } from '@vicons/material'
import AddressCredentialModal from '../../components/AddressCredentialModal.vue' import AddressCredentialModal from '../../components/AddressCredentialModal.vue'
const { const {
loading, adminTab, openSettings, loading, adminTab, openSettings,
adminMailTabAddress, adminSendBoxTabAddress adminMailTabAddress, adminSendBoxTabAddress,
useUTCDate
} = useGlobalState() } = useGlobalState()
const message = useMessage() const message = useMessage()
@@ -274,13 +275,19 @@ const columns = computed(() => [
title: t('created_at'), title: t('created_at'),
key: "created_at", key: "created_at",
sorter: true, 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'), title: t('updated_at'),
key: "updated_at", key: "updated_at",
sorter: true, 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'), title: t('source_meta'),
+6 -2
View File
@@ -4,8 +4,9 @@ import { useScopedI18n } from '@/i18n/app'
import { useGlobalState } from '../../store' import { useGlobalState } from '../../store'
import { api } from '../../api' import { api } from '../../api'
import { utcToLocalDate } from '../../utils';
const { loading } = useGlobalState() const { loading, useUTCDate } = useGlobalState()
const message = useMessage() const message = useMessage()
const { t } = useScopedI18n('views.admin.SenderAccess') const { t } = useScopedI18n('views.admin.SenderAccess')
@@ -70,7 +71,10 @@ const columns = [
}, },
{ {
title: t('created_at'), title: t('created_at'),
key: "created_at" key: "created_at",
render(row) {
return utcToLocalDate(row.created_at, useUTCDate.value);
}
}, },
{ {
title: t('balance'), title: t('balance'),
+6 -3
View File
@@ -6,11 +6,11 @@ import { MenuFilled } from '@vicons/material'
import { useGlobalState } from '../../store' import { useGlobalState } from '../../store'
import { api } from '../../api' import { api } from '../../api'
import { hashPassword } from '../../utils'; import { hashPassword, utcToLocalDate } from '../../utils';
import UserAddressManagement from './UserAddressManagement.vue' import UserAddressManagement from './UserAddressManagement.vue'
const { loading, openSettings } = useGlobalState() const { loading, openSettings, useUTCDate } = useGlobalState()
const message = useMessage() const message = useMessage()
const { t } = useScopedI18n('views.admin.UserManagement') const { t } = useScopedI18n('views.admin.UserManagement')
@@ -193,7 +193,10 @@ const columns = [
}, },
{ {
title: t('created_at'), title: t('created_at'),
key: "created_at" key: "created_at",
render(row) {
return utcToLocalDate(row.created_at, useUTCDate.value);
}
}, },
{ {
title: t('actions'), title: t('actions'),