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 驾驶舱 ────────────────────────────────────────────────────────────────