BirdNETM | b0f7153 | 2025-05-26 17:37:33 +0800 | [diff] [blame] | 1 | import { request } from '@umijs/max'; |
| 2 | import type { |
| 3 | RewardItem, |
| 4 | RewardListParams, |
| 5 | } from '@/pages/Reward/data'; // 假设你把 data.d.ts 放这里 |
BirdNETM | 02a57e5 | 2025-06-05 00:27:31 +0800 | [diff] [blame] | 6 | import type { |
| 7 | BtTorrent, |
| 8 | BtTorrentFile, |
| 9 | BtTorrentAnnounce, |
| 10 | BtTorrentTag, |
| 11 | } from '@/pages/Torrent/data'; |
BirdNETM | b0f7153 | 2025-05-26 17:37:33 +0800 | [diff] [blame] | 12 | /** 获取悬赏任务列表 */ |
| 13 | export async function getRewardList(params?: RewardListParams) { |
| 14 | const queryString = params |
| 15 | ? `?${new URLSearchParams(params as Record<string, any>).toString()}` |
| 16 | : ''; |
| 17 | const response = await request(`/api/reward/list${queryString}`, { |
| 18 | method: 'get', |
| 19 | }); |
| 20 | if (!response || response.length === 0) { |
| 21 | return [{ id: 1, name: '虚假任务1', description: '这是一个虚假的任务描述' }, { id: 2, name: '虚假任务2', description: '这是另一个虚假的任务描述' }]; |
| 22 | } |
| 23 | return response; |
| 24 | } |
| 25 | |
| 26 | /** 获取悬赏任务详细信息 */ |
| 27 | export async function getReward(rewardId: number) { |
| 28 | return request(`/api/reward/${rewardId}`, { |
| 29 | method: 'get', |
| 30 | }); |
| 31 | } |
| 32 | |
| 33 | /** 新增悬赏任务 */ |
| 34 | export async function addReward(params: RewardItem) { |
| 35 | return request('/api/reward', { |
| 36 | method: 'post', |
| 37 | data: params, |
| 38 | }); |
| 39 | } |
| 40 | |
| 41 | /** 修改悬赏任务 */ |
| 42 | export async function updateReward(params: RewardItem) { |
| 43 | return request('/api/reward', { |
| 44 | method: 'put', |
| 45 | data: params, |
| 46 | }); |
| 47 | } |
| 48 | |
| 49 | /** 删除悬赏任务 */ |
| 50 | export async function removeReward(ids: string) { |
| 51 | return request(`/api/reward/${ids}`, { |
| 52 | method: 'delete', |
| 53 | }); |
BirdNETM | 02a57e5 | 2025-06-05 00:27:31 +0800 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /** 新增种子 */ |
| 57 | export async function addBtTorrent(data: BtTorrent) { |
| 58 | return request('/api/system/torrent', { |
| 59 | method: 'post', |
| 60 | data, |
| 61 | }); |
BirdNETM | b0f7153 | 2025-05-26 17:37:33 +0800 | [diff] [blame] | 62 | } |