import api from './index'; export interface LoginResult { access_token: string; token_type: string; role: string; username: string; permissions: string[]; } export interface UserInfo { id: number; username: string; role: string; is_active: boolean; remark: string; permissions: string[]; } export const authApi = { login: (username: string, password: string) => api.post('/auth/login', { username, password }), me: () => api.get('/auth/me'), logout: () => api.post('/auth/logout'), }; export const userApi = { list: () => api.get('/users'), create: (data: { username: string; password: string; role: string; remark?: string }) => api.post('/users', data), update: (id: number, data: { password?: string; role?: string; is_active?: boolean; remark?: string }) => api.put(`/users/${id}`, data), delete: (id: number) => api.delete(`/users/${id}`), }; export const accountApi = { list: (params?: { assigned_only?: boolean; tag?: string; has_cookie?: boolean }) => api.get('/accounts', { params }), import: (text: string) => api.post('/accounts/import', { text }), assign: (id: number, assigned_to: number | null) => api.put(`/accounts/${id}/assign`, { assigned_to }), batchAssign: (account_ids: number[], assigned_to: number | null) => api.post('/accounts/batch-assign', { account_ids, assigned_to }), assignmentsSummary: () => api.get('/accounts/assignments/summary'), setTag: (id: number, tag: string) => api.put(`/accounts/${id}/tag`, { tag }), batchTag: (account_ids: number[], tag: string) => api.put('/accounts/batch-tag', { account_ids, tag }), listTags: () => api.get('/accounts/tags/list'), delete: (id: number) => api.delete(`/accounts/${id}`), }; export const loginApi = { createBatch: (account_ids: number[], max_geetest_retries?: number, concurrency?: number) => api.post('/login/batch', { account_ids, max_geetest_retries, concurrency }), listTasks: (batch_id?: string) => api.get('/login/tasks', { params: batch_id ? { batch_id } : {} }), stop: (batch_id: string) => api.post(`/login/stop/${batch_id}`), }; export const cookieApi = { list: () => api.get('/cookies'), exportCsv: () => api.get('/cookies/export', { responseType: 'blob' }), delete: (id: number) => api.delete(`/cookies/${id}`), }; export const proxyApi = { get: () => api.get('/proxy'), update: (data: any) => api.put('/proxy', data), test: () => api.post('/proxy/test'), testWhitelist: () => api.post('/proxy/whitelist/test'), };