vulgar5201 | 055346a | 2025-06-05 14:15:55 +0800 | [diff] [blame] | 1 | import request from './request'
|
| 2 |
|
| 3 | /**
|
| 4 | * 上传种子
|
| 5 | * @param {FormData} formData - 包含种子文件和相关信息的表单数据
|
| 6 | * @returns {Promise}
|
| 7 | */
|
| 8 | export function uploadTorrent(formData) {
|
| 9 | return request({
|
| 10 | url: '/torrent/upload',
|
| 11 | method: 'post',
|
| 12 | data: formData,
|
| 13 | headers: {
|
| 14 | 'Content-Type': 'multipart/form-data'
|
| 15 | }
|
| 16 | })
|
| 17 | }
|
| 18 |
|
| 19 | /**
|
| 20 | * 获取分类列表
|
| 21 | * @returns {Promise}
|
| 22 | */
|
| 23 | export function getCategories() {
|
| 24 | console.log('调用获取分类列表API(使用假数据)...')
|
| 25 |
|
| 26 | // 由于后端分类API还没实现,返回模拟数据
|
| 27 | return new Promise((resolve) => {
|
| 28 | setTimeout(() => {
|
| 29 | const categories = [
|
| 30 | { id: 1, name: '操作系统', slug: 'os', icon: 'computer' },
|
| 31 | { id: 2, name: '软件应用', slug: 'software', icon: 'application' },
|
| 32 | { id: 3, name: '游戏', slug: 'games', icon: 'game' },
|
| 33 | { id: 4, name: '影音娱乐', slug: 'media', icon: 'video' },
|
| 34 | { id: 5, name: '开发工具', slug: 'dev-tools', icon: 'code' },
|
| 35 | { id: 6, name: '学习资料', slug: 'education', icon: 'book' },
|
| 36 | { id: 7, name: '移动应用', slug: 'mobile', icon: 'mobile' },
|
| 37 | { id: 8, name: '服务器软件', slug: 'server', icon: 'server' },
|
| 38 | { id: 9, name: '安全工具', slug: 'security', icon: 'shield' },
|
| 39 | { id: 10, name: '其他', slug: 'others', icon: 'folder' }
|
| 40 | ]
|
| 41 |
|
| 42 | console.log('分类列表模拟数据加载成功:', categories)
|
| 43 | resolve({ data: categories })
|
| 44 | }, 200) // 模拟网络延迟
|
| 45 | })
|
| 46 | }
|
| 47 |
|
| 48 | /**
|
| 49 | * 获取标签列表
|
| 50 | * @returns {Promise}
|
| 51 | * 暂时还没有获取标签的列表
|
| 52 | */
|
| 53 | export function getTags() {
|
| 54 | console.log('调用获取标签列表API...')
|
| 55 | // 由于后端没有标签的Controller,返回模拟数据
|
| 56 | return new Promise((resolve) => {
|
| 57 | setTimeout(() => {
|
| 58 | resolve({
|
| 59 | data: [
|
| 60 | { id: 1, name: 'linux' },
|
| 61 | { id: 2, name: 'ubuntu' },
|
| 62 | { id: 3, name: 'debian' },
|
| 63 | { id: 4, name: 'windows' },
|
| 64 | { id: 5, name: 'macos' },
|
| 65 | { id: 6, name: 'centos' },
|
| 66 | { id: 7, name: 'redhat' },
|
| 67 | { id: 8, name: 'android' },
|
| 68 | { id: 9, name: 'ios' },
|
| 69 | { id: 10, name: 'server' },
|
| 70 | { id: 11, name: 'desktop' }
|
| 71 | ]
|
| 72 | })
|
| 73 | }, 100)
|
| 74 | })
|
| 75 | }
|
| 76 |
|
| 77 | /**
|
| 78 | * 获取种子详情
|
| 79 | * @param {string} infoHash - 种子的info hash
|
| 80 | * @returns {Promise}
|
| 81 | */
|
| 82 | export function getTorrentDetail(infoHash) {
|
| 83 | return request({
|
vulgar5201 | ef2b41e | 2025-06-05 19:09:44 +0800 | [diff] [blame^] | 84 | url: `/torrent/${infoHash}`,
|
vulgar5201 | 055346a | 2025-06-05 14:15:55 +0800 | [diff] [blame] | 85 | method: 'get'
|
| 86 | })
|
| 87 | }
|
| 88 |
|
| 89 | /**
|
| 90 | * 获取种子列表
|
| 91 | * @param {Object} params - 查询参数
|
| 92 | * @returns {Promise}
|
| 93 | */
|
| 94 | export function getTorrents(params) {
|
| 95 | return request({
|
vulgar5201 | ef2b41e | 2025-06-05 19:09:44 +0800 | [diff] [blame^] | 96 | url: '/torrents',
|
vulgar5201 | 055346a | 2025-06-05 14:15:55 +0800 | [diff] [blame] | 97 | method: 'get',
|
| 98 | params
|
| 99 | })
|
| 100 | } |