From 744f572f6ca9e6071da61abe5ec23950ad56e909 Mon Sep 17 00:00:00 2001 From: yml Date: Sat, 23 May 2026 01:56:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=97=B6=E9=97=B4=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/utils/time.ts | 23 +++++++++++++++++++ .../src/views/account/NotificationsView.vue | 3 ++- .../src/views/account/OrderDetailView.vue | 7 +++--- frontend/src/views/account/RealnameView.vue | 3 ++- frontend/src/views/account/WalletView.vue | 5 +++- .../src/views/admin/AdminAuditLogsView.vue | 5 +++- .../src/views/admin/AdminDashboardView.vue | 9 ++++++-- .../views/admin/AdminListingDetailView.vue | 5 ++-- .../views/admin/AdminListingReviewView.vue | 5 +++- .../src/views/admin/AdminListingsView.vue | 9 ++++++-- .../src/views/admin/AdminOrderDetailView.vue | 7 +++--- frontend/src/views/admin/AdminOrdersView.vue | 5 +++- .../views/admin/AdminSystemConfigsView.vue | 7 ++++-- frontend/src/views/admin/AdminUsersView.vue | 5 +++- .../src/views/admin/AdminWalletLedgerView.vue | 5 +++- .../src/views/mobile/MobileOrdersView.vue | 3 ++- .../src/views/mobile/MobileRealnameView.vue | 3 ++- 17 files changed, 85 insertions(+), 24 deletions(-) create mode 100644 frontend/src/utils/time.ts diff --git a/frontend/src/utils/time.ts b/frontend/src/utils/time.ts new file mode 100644 index 0000000..cf1b804 --- /dev/null +++ b/frontend/src/utils/time.ts @@ -0,0 +1,23 @@ +type DateInput = string | number | Date | null | undefined + +export function formatDateTime(value: DateInput, fallback = '-') { + if (!value) return fallback + const date = value instanceof Date ? value : new Date(value) + if (Number.isNaN(date.getTime())) { + return typeof value === 'string' && value.trim() ? value.replace('T', ' ') : fallback + } + return [ + date.getFullYear(), + pad(date.getMonth() + 1), + pad(date.getDate()), + ].join('-') + ` ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}` +} + +export function formatDateMinute(value: DateInput, fallback = '-') { + const formatted = formatDateTime(value, fallback) + return formatted === fallback ? fallback : formatted.slice(0, 16) +} + +function pad(value: number) { + return String(value).padStart(2, '0') +} diff --git a/frontend/src/views/account/NotificationsView.vue b/frontend/src/views/account/NotificationsView.vue index 068c0b5..1890ebe 100644 --- a/frontend/src/views/account/NotificationsView.vue +++ b/frontend/src/views/account/NotificationsView.vue @@ -3,6 +3,7 @@ import { ElMessage } from 'element-plus' import { onMounted, ref } from 'vue' import { fetchNotifications, markNotificationRead, type NotificationItem } from '@/api/notifications' +import { formatDateTime } from '@/utils/time' const loading = ref(false) const notifications = ref([]) @@ -40,7 +41,7 @@ async function markRead(id: number) { {{ item.type }}

{{ item.title }}

{{ item.content }}

- {{ item.created_at }} + {{ formatDateTime(item.created_at) }}
diff --git a/frontend/src/views/account/OrderDetailView.vue b/frontend/src/views/account/OrderDetailView.vue index 89f1dde..7045ad0 100644 --- a/frontend/src/views/account/OrderDetailView.vue +++ b/frontend/src/views/account/OrderDetailView.vue @@ -17,6 +17,7 @@ import { type Order, } from '@/api/orders' import { useSessionStore } from '@/stores/session' +import { formatDateTime } from '@/utils/time' const route = useRoute() const router = useRouter() @@ -207,8 +208,8 @@ function readError(error: unknown, fallback: string) {

租期:{{ order.rent_hours }} 小时

-

开始:{{ order.rent_start_at || '未开始' }}

-

结束:{{ order.rent_end_at || '未设置' }}

+

开始:{{ formatDateTime(order.rent_start_at, '未开始') }}

+

结束:{{ formatDateTime(order.rent_end_at, '未设置') }}

取消订单并释放账号 @@ -220,7 +221,7 @@ function readError(error: unknown, fallback: string) {
{{ record.type }}

{{ record.content }}

- {{ record.created_at }} + {{ formatDateTime(record.created_at) }}
diff --git a/frontend/src/views/account/RealnameView.vue b/frontend/src/views/account/RealnameView.vue index fce3ad8..3c8319e 100644 --- a/frontend/src/views/account/RealnameView.vue +++ b/frontend/src/views/account/RealnameView.vue @@ -4,6 +4,7 @@ import { onMounted, reactive, ref } from 'vue' import { getRealnameStatus, startRealname, type RealnameStatus } from '@/api/realname' import { useSessionStore } from '@/stores/session' +import { formatDateTime } from '@/utils/time' const session = useSessionStore() const loading = ref(false) @@ -61,7 +62,7 @@ function readError(error: unknown, fallback: string) { {{ status.status }}

姓名:{{ status.masked_name }}

证件号:{{ status.masked_id_no }}

-

通过时间:{{ status.verified_at }}

+

通过时间:{{ formatDateTime(status.verified_at) }}