diff --git a/src/components/cards/TorrentCard.vue b/src/components/cards/TorrentCard.vue index 8866f78a..0108825e 100644 --- a/src/components/cards/TorrentCard.vue +++ b/src/components/cards/TorrentCard.vue @@ -4,6 +4,7 @@ import { formatFileSize } from '@/@core/utils/formatters' import api from '@/api' import type { Context } from '@/api/types' import AddDownloadDialog from '../dialog/AddDownloadDialog.vue' +import { isNullOrEmptyObject } from '@/@core/utils' // 输入参数 const props = defineProps({ @@ -25,6 +26,9 @@ const media = ref(props.torrent?.media_info) // 识别元数据 const meta = ref(props.torrent?.meta_info) +// 当前下载项 +const downloadItem = ref(props.torrent) + // 站点图标 const siteIcon = ref('') @@ -56,7 +60,10 @@ async function getSiteIcon() { } // 询问并添加下载 -async function handleAddDownload() { +async function handleAddDownload(item: Context | null = null) { + if (item && !isNullOrEmptyObject(item)) { + downloadItem.value = item + } // 打开下载对话框 addDownloadDialog.value = true } @@ -91,7 +98,7 @@ onMounted(() => { :width="props.width" :height="props.height" :variant="downloaded.includes(torrent?.enclosure || '') ? 'outlined' : 'elevated'" - @click="handleAddDownload" + @click="handleAddDownload(props.torrent)" >