优化列表分页和数据加载
This commit is contained in:
@@ -2,14 +2,20 @@ import api from './client';
|
||||
import type {
|
||||
AccountItem,
|
||||
AssignmentsSummary,
|
||||
BasicSummary,
|
||||
MessageCountResponse,
|
||||
MessageDeletedResponse,
|
||||
MessageResponse,
|
||||
PageParams,
|
||||
PaginatedResponse,
|
||||
} from './types';
|
||||
|
||||
export const accountApi = {
|
||||
list: (params?: { assigned_only?: boolean; tag?: string; has_cookie?: boolean }) =>
|
||||
list: (params?: { assigned_only?: boolean; tag?: string; has_cookie?: boolean; include_sensitive?: boolean }) =>
|
||||
api.get<AccountItem[], AccountItem[]>('/accounts', { params }),
|
||||
listPaged: (params: PageParams & { assigned_only?: boolean; tag?: string; has_cookie?: boolean; include_sensitive?: boolean }) =>
|
||||
api.get<PaginatedResponse<AccountItem>, PaginatedResponse<AccountItem>>('/accounts', { params }),
|
||||
summary: () => api.get<BasicSummary, BasicSummary>('/accounts/summary'),
|
||||
import: (text: string) => api.post<MessageCountResponse, MessageCountResponse>('/accounts/import', { text }),
|
||||
assign: (id: number, assigned_to: number | null) =>
|
||||
api.put<MessageResponse, MessageResponse>(`/accounts/${id}/assign`, { assigned_to }),
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import api from './client';
|
||||
import type { CookieItem, MessageDeletedResponse, MessageResponse } from './types';
|
||||
import type { BasicSummary, CookieItem, PageParams, PaginatedResponse, MessageDeletedResponse, MessageResponse } from './types';
|
||||
|
||||
export const cookieApi = {
|
||||
list: () => api.get<CookieItem[], CookieItem[]>('/cookies'),
|
||||
listPaged: (params: PageParams & { include_cookie?: boolean }) =>
|
||||
api.get<PaginatedResponse<CookieItem>, PaginatedResponse<CookieItem>>('/cookies', { params }),
|
||||
summary: () => api.get<BasicSummary, BasicSummary>('/cookies/summary'),
|
||||
get: (id: number) => api.get<CookieItem, CookieItem>(`/cookies/${id}`),
|
||||
exportCsv: (format?: string) => api.get<Blob, Blob>('/cookies/export', { responseType: 'blob', params: format ? { format } : {} }),
|
||||
delete: (id: number) => api.delete<MessageResponse, MessageResponse>(`/cookies/${id}`),
|
||||
deleteBatch: (ids: number[]) => api.delete<MessageDeletedResponse, MessageDeletedResponse>('/cookies/batch', { params: { task_ids: ids.join(',') } }),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import api from './client';
|
||||
import type {
|
||||
BasicSummary,
|
||||
HuyaAccountItem,
|
||||
HuyaAccountSummary,
|
||||
HuyaAutoRegisterBatch,
|
||||
HuyaAutoRegisterRequest,
|
||||
HuyaAutoRegisterRetryRequest,
|
||||
@@ -25,12 +27,17 @@ import type {
|
||||
MessageCountResponse,
|
||||
MessageDeletedResponse,
|
||||
MessageResponse,
|
||||
PageParams,
|
||||
PaginatedResponse,
|
||||
} from './types';
|
||||
|
||||
export const huyaApi = {
|
||||
taskTypes: () => api.get<Record<string, string>, Record<string, string>>('/huya/task-types'),
|
||||
listAccounts: (params?: { assigned_only?: boolean; tag?: string; has_cookie?: boolean }) =>
|
||||
listAccounts: (params?: { assigned_only?: boolean; tag?: string; has_cookie?: boolean; include_cookie?: boolean }) =>
|
||||
api.get<HuyaAccountItem[], HuyaAccountItem[]>('/huya/accounts', { params }),
|
||||
listAccountsPaged: (params: PageParams & { assigned_only?: boolean; tag?: string; has_cookie?: boolean; include_cookie?: boolean }) =>
|
||||
api.get<PaginatedResponse<HuyaAccountItem>, PaginatedResponse<HuyaAccountItem>>('/huya/accounts', { params }),
|
||||
accountsSummary: () => api.get<HuyaAccountSummary, HuyaAccountSummary>('/huya/accounts/summary'),
|
||||
importCookies: (text: string, tag: string = '') =>
|
||||
api.post<HuyaCookieImportResult, HuyaCookieImportResult>('/huya/accounts/import-cookies', { text, tag }),
|
||||
importPasswordAccounts: (text: string, tag: string = '') =>
|
||||
@@ -76,6 +83,10 @@ export const huyaApi = {
|
||||
deleteAccounts: (accountIds: number[]) =>
|
||||
api.delete<MessageDeletedResponse, MessageDeletedResponse>('/huya/accounts/batch', { params: { account_ids: accountIds.join(',') } }),
|
||||
listCookies: () => api.get<HuyaCookieItem[], HuyaCookieItem[]>('/huya/cookies'),
|
||||
listCookiesPaged: (params: PageParams & { include_cookie?: boolean }) =>
|
||||
api.get<PaginatedResponse<HuyaCookieItem>, PaginatedResponse<HuyaCookieItem>>('/huya/cookies', { params }),
|
||||
cookiesSummary: () => api.get<BasicSummary, BasicSummary>('/huya/cookies/summary'),
|
||||
getCookie: (id: number) => api.get<HuyaCookieItem, HuyaCookieItem>(`/huya/cookies/${id}`),
|
||||
exportCookies: (format?: string) => api.get<Blob, Blob>('/huya/cookies/export', { responseType: 'blob', params: format ? { format } : {} }),
|
||||
deleteCookie: (id: number) => api.delete<MessageResponse, MessageResponse>(`/huya/cookies/${id}`),
|
||||
deleteCookies: (accountIds: number[]) =>
|
||||
|
||||
@@ -17,6 +17,26 @@ export interface AppInfo {
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface PageParams {
|
||||
page: number;
|
||||
page_size: number;
|
||||
search?: string;
|
||||
}
|
||||
|
||||
export interface PaginatedResponse<T> {
|
||||
items: T[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
export interface BasicSummary {
|
||||
total: number;
|
||||
assigned_count: number;
|
||||
unassigned_count: number;
|
||||
tag_count?: number;
|
||||
}
|
||||
|
||||
// ==================== Auth ====================
|
||||
|
||||
export interface LoginResult {
|
||||
@@ -172,6 +192,12 @@ export interface HuyaAccountItem {
|
||||
updated_at: string | null;
|
||||
}
|
||||
|
||||
export interface HuyaAccountSummary extends BasicSummary {
|
||||
password_ready_count: number;
|
||||
point_count: number;
|
||||
bound_count: number;
|
||||
}
|
||||
|
||||
export interface HuyaCookieImportResult extends MessageCountResponse {
|
||||
skipped: number;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user