From a04327fd05a6a70828d87e9e064acd8a0afa94f8 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Wed, 27 May 2026 01:23:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20=E4=BB=AA=E8=A1=A8?= =?UTF-8?q?=E7=9B=98=E4=B8=80=E7=9B=B4=E8=BD=AC=E5=9C=88ug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/modules/admindashboard/repository.go | 4 ++-- frontend/src/api/adminAuth.ts | 2 +- frontend/src/api/adminDashboard.ts | 6 +++++- frontend/src/api/client.ts | 2 +- frontend/src/views/admin/AdminDashboardView.vue | 1 + 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backend/internal/modules/admindashboard/repository.go b/backend/internal/modules/admindashboard/repository.go index 8a596b0..472cc49 100644 --- a/backend/internal/modules/admindashboard/repository.go +++ b/backend/internal/modules/admindashboard/repository.go @@ -79,7 +79,7 @@ func (r *Repository) Summary() (*DashboardDTO, error) { } func (r *Repository) recentOrders() ([]RecentOrderDTO, error) { - var rows []RecentOrderDTO + rows := make([]RecentOrderDTO, 0) err := r.db.Table("rental_orders AS o"). Select("o.id, o.order_no, a.title, o.renter_id, o.owner_id, o.status, o.rent_amount, o.deposit_amount, o.created_at"). Joins("JOIN game_accounts AS a ON a.id = o.account_id"). @@ -90,7 +90,7 @@ func (r *Repository) recentOrders() ([]RecentOrderDTO, error) { } func (r *Repository) recentDisputes() ([]RecentDisputeDTO, error) { - var rows []RecentDisputeDTO + rows := make([]RecentDisputeDTO, 0) err := r.db.Table("disputes AS d"). Select("d.id, d.order_id, o.order_no, a.title, d.type, d.status, d.initiator_id, d.created_at"). Joins("JOIN rental_orders AS o ON o.id = d.order_id"). diff --git a/frontend/src/api/adminAuth.ts b/frontend/src/api/adminAuth.ts index c3af849..0156981 100644 --- a/frontend/src/api/adminAuth.ts +++ b/frontend/src/api/adminAuth.ts @@ -60,7 +60,7 @@ export async function logoutAdmin() { export async function refreshAdminSession() { const refreshToken = getRefreshToken('admin') if (!refreshToken) throw new Error('no refresh token') - const { data } = await axios.post>('/api/admin/auth/refresh', { refresh_token: refreshToken }) + const { data } = await axios.post>('/api/admin/auth/refresh', { refresh_token: refreshToken }, { timeout: 10000 }) setAuthTokens('admin', data.data) return data.data } diff --git a/frontend/src/api/adminDashboard.ts b/frontend/src/api/adminDashboard.ts index 1bf7857..2896310 100644 --- a/frontend/src/api/adminDashboard.ts +++ b/frontend/src/api/adminDashboard.ts @@ -53,5 +53,9 @@ export interface AdminDashboard { export async function fetchAdminDashboard() { const { data } = await apiClient.get>('/admin/dashboard') - return data.data + return { + ...data.data, + recent_orders: data.data.recent_orders ?? [], + recent_disputes: data.data.recent_disputes ?? [], + } } diff --git a/frontend/src/api/client.ts b/frontend/src/api/client.ts index 7290097..f119a59 100644 --- a/frontend/src/api/client.ts +++ b/frontend/src/api/client.ts @@ -78,7 +78,7 @@ async function refreshToken(scope: AuthScope): Promise { if (!refreshToken) throw new Error('no refresh token') const endpoint = scope === 'admin' ? '/api/admin/auth/refresh' : '/api/auth/refresh' - const { data } = await axios.post(endpoint, { refresh_token: refreshToken }) + const { data } = await axios.post(endpoint, { refresh_token: refreshToken }, { timeout: 10000 }) const tokens = { access_token: data.data.access_token, refresh_token: data.data.refresh_token, diff --git a/frontend/src/views/admin/AdminDashboardView.vue b/frontend/src/views/admin/AdminDashboardView.vue index 7958bf5..a5cba48 100644 --- a/frontend/src/views/admin/AdminDashboardView.vue +++ b/frontend/src/views/admin/AdminDashboardView.vue @@ -8,6 +8,7 @@ import { Operation, Refresh, ScaleToOriginal, + ShoppingBag, Shop, Tickets, User,