import request from './request' | |
/** | |
* 上传种子 | |
* @param {FormData} formData - 包含种子文件和相关信息的表单数据 | |
* @returns {Promise} | |
*/ | |
export function uploadTorrent(formData) { | |
return request({ | |
url: '/torrent/upload', | |
method: 'post', | |
data: formData, | |
headers: { | |
'Content-Type': 'multipart/form-data' | |
} | |
}) | |
} | |
/** | |
* 获取分类列表 | |
* @returns {Promise} | |
*/ | |
export function getCategories() { | |
console.log('调用获取分类列表API(使用假数据)...') | |
// 由于后端分类API还没实现,返回模拟数据 | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
const categories = [ | |
{ id: 1, name: '操作系统', slug: 'os', icon: 'computer' }, | |
{ id: 2, name: '软件应用', slug: 'software', icon: 'application' }, | |
{ id: 3, name: '游戏', slug: 'games', icon: 'game' }, | |
{ id: 4, name: '影音娱乐', slug: 'media', icon: 'video' }, | |
{ id: 5, name: '开发工具', slug: 'dev-tools', icon: 'code' }, | |
{ id: 6, name: '学习资料', slug: 'education', icon: 'book' }, | |
{ id: 7, name: '移动应用', slug: 'mobile', icon: 'mobile' }, | |
{ id: 8, name: '服务器软件', slug: 'server', icon: 'server' }, | |
{ id: 9, name: '安全工具', slug: 'security', icon: 'shield' }, | |
{ id: 10, name: '其他', slug: 'others', icon: 'folder' } | |
] | |
console.log('分类列表模拟数据加载成功:', categories) | |
resolve({ data: categories }) | |
}, 200) // 模拟网络延迟 | |
}) | |
} | |
/** | |
* 获取标签列表 | |
* @returns {Promise} | |
* 暂时还没有获取标签的列表 | |
*/ | |
export function getTags() { | |
console.log('调用获取标签列表API...') | |
// 由于后端没有标签的Controller,返回模拟数据 | |
return new Promise((resolve) => { | |
setTimeout(() => { | |
resolve({ | |
data: [ | |
{ id: 1, name: 'linux' }, | |
{ id: 2, name: 'ubuntu' }, | |
{ id: 3, name: 'debian' }, | |
{ id: 4, name: 'windows' }, | |
{ id: 5, name: 'macos' }, | |
{ id: 6, name: 'centos' }, | |
{ id: 7, name: 'redhat' }, | |
{ id: 8, name: 'android' }, | |
{ id: 9, name: 'ios' }, | |
{ id: 10, name: 'server' }, | |
{ id: 11, name: 'desktop' } | |
] | |
}) | |
}, 100) | |
}) | |
} | |
/** | |
* 获取种子详情 | |
* @param {string} infoHash - 种子的info hash | |
* @returns {Promise} | |
*/ | |
export function getTorrentDetail(infoHash) { | |
return request({ | |
url: `/torrent/${infoHash}`, | |
method: 'get' | |
}) | |
} | |
/** | |
* 获取种子列表 | |
* @param {Object} params - 查询参数 | |
* @returns {Promise} | |
*/ | |
export function getTorrents(params) { | |
return request({ | |
url: '/torrents', | |
method: 'get', | |
params | |
}) | |
} |