| import { request } from '@umijs/max'; |
| |
| // 获取分类 |
| export async function getCategories() { |
| return request('/api/tag/all_cat'); |
| } |
| |
| // 获取种子列表 |
| export async function getTorrentList(params: { |
| category?: string; |
| sortField: string; |
| sortDirection: string; |
| pageNum: number; |
| pageSize: number; |
| }) { |
| return request('/api/torrent/torrentList', { |
| method: 'POST', |
| data: params, |
| }); |
| } |
| |
| export async function getMyTorrentList() { |
| return request('/api/torrent/myList', { |
| method: 'POST', |
| }); |
| } |
| |
| export async function getTorrentInfo(params: { |
| id: string | number; |
| }) { |
| return request(`/api/torrent/info/${params.id}`, { |
| method: 'POST', |
| }); |
| } |
| |
| |
| export async function downloadTorrent(params: { |
| id: string | number; |
| passkey?: string; |
| }) { |
| return request('/api/torrent/download', { |
| method: 'GET', |
| params: { |
| id: params.id, |
| }, |
| responseType: 'blob', |
| }); |
| } |
| |
| export async function addComment(params: { |
| torrentId: number; |
| pid?: number; |
| comment: string; |
| }) { |
| return request('/api/torrent/addComment', { |
| method: 'POST', |
| data: params, |
| }); |
| } |
| |
| export async function getComments(params: { |
| torrentId: number; |
| pageNum?: number; |
| pageSize?: number; |
| }) { |
| return request('/api/torrent/comments', { |
| method: 'GET', |
| params, |
| }); |
| } |
| |
| export interface TorrentAddParam { |
| name: string; |
| title: string; |
| subheading: string; |
| cover?: string; |
| description: string; |
| category: number; |
| status?: number; |
| anonymous?: number; |
| remark?: string; |
| } |
| |
| // 审核种子参数 |
| export interface TorrentAuditParam { |
| id: number; |
| status: number; |
| remark?: string; |
| } |
| |
| // 种子实体 |
| export interface TorrentEntity { |
| id?: number; |
| infoHash?: Uint8Array; |
| name?: string; |
| filename?: string; |
| title?: string; |
| subheading?: string; |
| cover?: string; |
| description?: string; |
| category?: number; |
| status?: number; |
| fileStatus?: number; |
| reviewer?: number; |
| createTime?: string; |
| updateTime?: string; |
| owner?: number; |
| size?: number; |
| type?: number; |
| fileCount?: number; |
| comments?: number; |
| views?: number; |
| hits?: number; |
| visible?: number; |
| anonymous?: number; |
| leechers?: number; |
| seeders?: number; |
| completions?: number; |
| remark?: string; |
| } |
| |
| // 添加种子 |
| export async function addTorrent(param: TorrentAddParam) { |
| return request('/api/torrent/add', { |
| method: 'POST', |
| data: param, |
| }); |
| } |
| |
| // 审核种子 |
| export async function auditTorrent(param: TorrentAuditParam) { |
| return request('/api/torrent/audit', { |
| method: 'POST', |
| data: param, |
| }); |
| } |
| |
| // 点赞 |
| export async function favoriteTorrent(id: number) { |
| return request('/api/torrent/favorite', { |
| method: 'POST', |
| params: { id }, |
| }); |
| } |
| |
| // 上传种子.torrent |
| export async function uploadTorrentFile(file: File, id: number) { |
| const formData = new FormData(); |
| formData.append('file', file); |
| formData.append('id', id.toString()); |
| return request('/api/torrent/upload', { |
| method: 'POST', |
| data: formData, |
| }); |
| } |
| |
| // 更新种子 |
| export async function updateTorrent(entity: TorrentEntity) { |
| return request('/api/torrent/update', { |
| method: 'POST', |
| data: entity, |
| }); |
| } |
| |
| // 删除种子 |
| export async function deleteTorrent(ids: number[]) { |
| return request('/api/torrent/delete', { |
| method: 'POST', |
| data: ids, |
| }); |
| } |
| |
| // 获取服务器Tracker |
| export async function getTracker() { |
| return request('/api/torrent/tracker', { |
| method: 'POST', |
| }); |
| } |
| |
| export interface TorrentSearchRequest { |
| infoHash?: string; |
| category?: number; |
| status?: number; |
| fileStatus?: number; |
| owner?: number; |
| type?: number; |
| nameKeyword?: string; |
| titleKeyword?: string; |
| descriptionKeyword?: string; |
| minSize?: number; |
| maxSize?: number; |
| createTimeStart?: string; // ISO string |
| createTimeEnd?: string; // ISO string |
| sortField?: string; |
| sortDirection?: string; |
| pageNum?: number; |
| pageSize?: number; |
| } |
| |
| export interface UserEntity { |
| user_id: number; |
| user_name: string; |
| nick_name: string; |
| user_type: string; |
| email: string; |
| phonenumber: string; |
| gender: string; |
| avatar: string; |
| password: string; |
| status: number; |
| login_ip: string; |
| login_date: string; |
| create_by: string; |
| create_time: string; |
| update_by: string; |
| update_time: string; |
| remark: string; |
| full_name: string; |
| state: number; |
| added: string; |
| last_login: string; |
| last_access: string; |
| last_home: string; |
| last_offer: string; |
| forum_access: string; |
| last_staffmsg: string; |
| last_pm: string; |
| last_comment: string; |
| last_post: string; |
| last_active: string; |
| privacy: number; |
| reg_ip: string; |
| level: number; |
| seedtime: number; |
| leechtime: number; |
| real_uploaded: number; |
| real_downloaded: number; |
| modcomment: string; |
| warning_by: number; |
| warning_times: number; |
| warning: boolean; |
| warning_until: string; |
| download: number; |
| upload: number; |
| invited_by: number; |
| bonus: number; |
| exp: number; |
| check_code: string; |
| reg_type: number; |
| } |
| |
| export interface TorrentSearchResult { |
| torrent: TorrentEntity; |
| ownerInfo: UserEntity; |
| } |
| |
| export interface TorrentSearchResponse { |
| records: TorrentSearchResult[]; |
| total: number; |
| size: number; |
| current: number; |
| pages: number; |
| } |
| |
| export async function searchTorrents(params: TorrentSearchRequest) { |
| return request<TorrentSearchResponse>('/api/torrent/search', { |
| method: 'POST', |
| data: params, |
| }); |
| } |
| |
| export async function generatePassKey() { |
| return request('/api/torrent/generatePassKey', { |
| method: 'GET', |
| }); |
| } |
| |
| // 用户注册 |
| export async function registerUser(userName: string, password: string, passKey: string) { |
| return request('/api/api/register', { |
| method: 'POST', |
| data: { |
| userName, |
| password, |
| passKey, |
| }, |
| }); |
| } |