From 63206fea2e290f5dad9d484d73ae4568f208dabb Mon Sep 17 00:00:00 2001 From: InfinityPacer <160988576+InfinityPacer@users.noreply.github.com> Date: Wed, 9 Oct 2024 02:32:02 +0800 Subject: [PATCH] fix(download): support downloader and save_path parameters --- src/components/dialog/AddDownloadDialog.vue | 23 +++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/components/dialog/AddDownloadDialog.vue b/src/components/dialog/AddDownloadDialog.vue index cd52a239..1abea6fb 100644 --- a/src/components/dialog/AddDownloadDialog.vue +++ b/src/components/dialog/AddDownloadDialog.vue @@ -17,10 +17,10 @@ const props = defineProps({ const $toast = useToast() // 选择的下载器 -const selectedDownloader = ref(null) +const selectedDownloader = ref(null) // 选择的保存目录 -const selectedDirectory = ref(null) +const selectedDirectory = ref(null) // 定义成功和失败事件 const emit = defineEmits(['done', 'error', 'close']) @@ -81,15 +81,20 @@ async function addDownload() { try { let result: { [key: string]: any } - if (props.media) { - result = await api.post('download/', { - media_in: props.media, - torrent_in: props.torrent, - }) - } else { - result = await api.post('download/add', props.torrent) + const payload: any = { + torrent_in: props.torrent, + downloader: selectedDownloader.value, + save_path: selectedDirectory.value, } + 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) { // 添加下载成功 $toast.success(`${props.torrent?.site_name} ${props.torrent?.title} 下载成功!`)