From 39fcdbf6da239e3ad5fea1da2198dbf007684d6d Mon Sep 17 00:00:00 2001 From: QihuAI Design Date: Sun, 23 Aug 2026 12:26:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend-v2):=20ProfilePage=20=E7=9C=9F?= =?UTF-8?q?=E5=AE=9E=E6=95=B0=E6=8D=AE=E9=A1=B5=20(#987-#990)=20-=20?= =?UTF-8?q?=E6=8E=A5=20profile=20API=206=20=E5=8C=BA=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend-v2/src/api/client.ts | 79 +++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 7 deletions(-) diff --git a/frontend-v2/src/api/client.ts b/frontend-v2/src/api/client.ts index da24e0c..272215a 100644 --- a/frontend-v2/src/api/client.ts +++ b/frontend-v2/src/api/client.ts @@ -219,21 +219,86 @@ export const imBotApi = { // ─── Profile ───────────────────────────────────────────────────────────────────── +export interface MembershipInfo { + id: string; + plan_id: string; + status: string; + start_at: string; + expire_at: string; + is_expired: boolean; +} + export interface UserProfile { id: string; username: string; email: string; - avatar_url: string; - balance: number; - membership: string; + phone: string; + avatar: string; + role: string; + status: string; + membership: MembershipInfo | null; + created_at: string; + updated_at: string; +} + +export interface LoginLogItem { + id: string; + ip: string; + user_agent: string; + login_at: string; +} + +export interface LoginLogList { + total: number; + page: number; + page_size: number; + items: LoginLogItem[]; +} + +export interface ApiKeyItem { + id: string; + name: string; + key_preview: string; + status: string; + last_used_at: string | null; + created_at: string; + expire_at: string | null; +} + +export interface PurchasedAppItem { + id: string; + app_id: string; + app_name: string; + app_icon: string; + app_type: string; + price: number; + purchased_at: string; } export const profileApi = { - get: () => request('/profile/'), - update: (data: Partial) => - request('/profile/', { method: 'PUT', body: JSON.stringify(data) }), + get: () => data('/profile/'), - getBalance: () => request<{ balance: number; total_used: number }>('/profile/balance'), + update: (payload: Partial>) => + data('/profile/', { method: 'PUT', body: JSON.stringify(payload) }), + + getBalance: () => data('/profile/balance'), + + getMembership: () => data<{ + has_membership: boolean; + id: string; + plan_id: string; + status: string; + start_at: string; + expire_at: string; + is_expired: boolean; + }>('/profile/membership'), + + getLoginLogs: (page = 1, page_size = 10) => + data(`/profile/login-logs?page=${page}&page_size=${page_size}`), + + getApiKeys: () => data('/profile/api-keys'), + + getPurchasedApps: () => data('/profile/purchased-apps'), }; // ─── Token 驾驶舱 ────────────────────────────────────────────────────────────────