Files
live-hub-py/web/frontend/src/api/accounts.ts
T
yml2213 834bfdd1d0 feat(account-events): 账号详情页与账号事件历史全链路支持
1. 新增账号事件数据表 AccountEvent 与迁移版本 20261002_0040_account_events,支持审计 Cookie 变更、自动重登、健康检查及任务执行事件;
2. 后端新增 account_events_service 并扩展 /api/accounts 路由,支持事件查询、过滤与上报;
3. 前端新增 AccountDetailPage 账号详情页组件,支持账号元信息展示、事件历史瀑布流与快捷重登操作;
4. 修复 CK 重登与自动化定时任务中事件关联逻辑,补充 test_account_events 单元测试;
5. 新增生产服务器高负载排查分析报告及相关设计文档。
2026-10-03 12:58:58 +08:00

51 lines
2.7 KiB
TypeScript

import api from './client';
import type {
AccountEventPage,
AccountItem,
AccountBulkSelection,
AccountBulkTagRequest,
AccountOverview,
AssignmentsSummary,
BasicSummary,
MessageCountResponse,
MessageDeletedResponse,
MessageResponse,
PageParams,
PaginatedResponse,
} from './types';
export const accountApi = {
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, tag?: string) =>
api.post<MessageCountResponse, MessageCountResponse>('/accounts/import', { text, tag: tag || '' }),
assign: (id: number, assigned_to: number | null) =>
api.put<MessageResponse, MessageResponse>(`/accounts/${id}/assign`, { assigned_to }),
batchAssign: (account_ids: number[], assigned_to: number | null) =>
api.post<MessageCountResponse, MessageCountResponse>('/accounts/batch-assign', { account_ids, assigned_to }),
assignmentsSummary: () =>
api.get<AssignmentsSummary, AssignmentsSummary>('/accounts/assignments/summary'),
setTag: (id: number, tag: string) =>
api.put<MessageResponse, MessageResponse>(`/accounts/${id}/tag`, { tag }),
batchTag: (account_ids: number[], tag: string) =>
api.put<MessageCountResponse, MessageCountResponse>('/accounts/batch-tag', { account_ids, tag }),
batchTagSelection: (data: AccountBulkTagRequest) =>
api.put<MessageCountResponse, MessageCountResponse>('/accounts/batch-tag-selection', data),
listTags: () => api.get<string[], string[]>('/accounts/tags/list'),
delete: (id: number) => api.delete<MessageResponse, MessageResponse>(`/accounts/${id}`),
batchDelete: (account_ids: number[]) =>
api.delete<MessageDeletedResponse, MessageDeletedResponse>('/accounts/batch/delete', { params: { account_ids: account_ids.join(',') } }),
batchDeleteSelection: (data: AccountBulkSelection) =>
api.post<MessageDeletedResponse, MessageDeletedResponse>('/accounts/batch-delete', data),
// 详情页:状态卡 + 统计
overview: (id: number) => api.get<AccountOverview, AccountOverview>(`/accounts/${id}/overview`),
// 时间线(倒序分页),event_type 为空表示全部
events: (id: number, params: { page?: number; page_size?: number; event_type?: string }) =>
api.get<AccountEventPage, AccountEventPage>(`/accounts/${id}/events`, {
params: { page: 1, page_size: 50, ...params, event_type: params.event_type || '' },
}),
};