fix(download): support downloader and save_path parameters

This commit is contained in:
InfinityPacer
2024-10-09 02:32:02 +08:00
parent d703909177
commit 63206fea2e
+14 -9
View File
@@ -17,10 +17,10 @@ const props = defineProps({
const $toast = useToast() const $toast = useToast()
// 选择的下载器 // 选择的下载器
const selectedDownloader = ref(null) const selectedDownloader = ref<string | null>(null)
// 选择的保存目录 // 选择的保存目录
const selectedDirectory = ref(null) const selectedDirectory = ref<string | null>(null)
// 定义成功和失败事件 // 定义成功和失败事件
const emit = defineEmits(['done', 'error', 'close']) const emit = defineEmits(['done', 'error', 'close'])
@@ -81,15 +81,20 @@ async function addDownload() {
try { try {
let result: { [key: string]: any } let result: { [key: string]: any }
if (props.media) { const payload: any = {
result = await api.post('download/', { torrent_in: props.torrent,
media_in: props.media, downloader: selectedDownloader.value,
torrent_in: props.torrent, save_path: selectedDirectory.value,
})
} else {
result = await api.post('download/add', props.torrent)
} }
if (props.media) {
payload.media_in = props.media
}
const endpoint = props.media ? 'download/' : 'download/add'
result = await api.post(endpoint, payload)
if (result && result.success) { if (result && result.success) {
// 添加下载成功 // 添加下载成功
$toast.success(`${props.torrent?.site_name} ${props.torrent?.title} 下载成功!`) $toast.success(`${props.torrent?.site_name} ${props.torrent?.title} 下载成功!`)