mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 23:56:42 +08:00
Update StorageCard.vue to improve download handling
This commit is contained in:
@@ -4,6 +4,7 @@ import { formatFileSize } from '@/@core/utils/formatters'
|
|||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import type { Context } from '@/api/types'
|
import type { Context } from '@/api/types'
|
||||||
import AddDownloadDialog from '../dialog/AddDownloadDialog.vue'
|
import AddDownloadDialog from '../dialog/AddDownloadDialog.vue'
|
||||||
|
import { isNullOrEmptyObject } from '@/@core/utils'
|
||||||
|
|
||||||
// 输入参数
|
// 输入参数
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -25,6 +26,9 @@ const media = ref(props.torrent?.media_info)
|
|||||||
// 识别元数据
|
// 识别元数据
|
||||||
const meta = ref(props.torrent?.meta_info)
|
const meta = ref(props.torrent?.meta_info)
|
||||||
|
|
||||||
|
// 当前下载项
|
||||||
|
const downloadItem = ref(props.torrent)
|
||||||
|
|
||||||
// 站点图标
|
// 站点图标
|
||||||
const siteIcon = ref('')
|
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
|
addDownloadDialog.value = true
|
||||||
}
|
}
|
||||||
@@ -91,7 +98,7 @@ onMounted(() => {
|
|||||||
:width="props.width"
|
:width="props.width"
|
||||||
:height="props.height"
|
:height="props.height"
|
||||||
:variant="downloaded.includes(torrent?.enclosure || '') ? 'outlined' : 'elevated'"
|
:variant="downloaded.includes(torrent?.enclosure || '') ? 'outlined' : 'elevated'"
|
||||||
@click="handleAddDownload"
|
@click="handleAddDownload(props.torrent)"
|
||||||
>
|
>
|
||||||
<template v-if="!showMoreTorrents" #image>
|
<template v-if="!showMoreTorrents" #image>
|
||||||
<VAvatar class="absolute right-2 bottom-2 rounded" variant="flat" rounded="0">
|
<VAvatar class="absolute right-2 bottom-2 rounded" variant="flat" rounded="0">
|
||||||
@@ -135,7 +142,7 @@ onMounted(() => {
|
|||||||
<VCardText class="text-subtitle-2">
|
<VCardText class="text-subtitle-2">
|
||||||
{{ torrent?.title }}
|
{{ torrent?.title }}
|
||||||
</VCardText>
|
</VCardText>
|
||||||
<VCardText>{{ torrent?.description }}</VCardText>
|
<VCardText>【{{ torrent?.site_name }}】{{ torrent?.description }}</VCardText>
|
||||||
<VCardItem v-if="torrent?.labels" class="pb-3 pt-0 pe-12">
|
<VCardItem v-if="torrent?.labels" class="pb-3 pt-0 pe-12">
|
||||||
<VChip v-if="torrent?.hit_and_run" variant="elevated" size="small" class="me-1 mb-1 text-white bg-black">
|
<VChip v-if="torrent?.hit_and_run" variant="elevated" size="small" class="me-1 mb-1 text-white bg-black">
|
||||||
H&R
|
H&R
|
||||||
@@ -190,11 +197,7 @@ onMounted(() => {
|
|||||||
<div v-show="showMoreTorrents">
|
<div v-show="showMoreTorrents">
|
||||||
<VDivider />
|
<VDivider />
|
||||||
<VChipGroup class="p-3" column>
|
<VChipGroup class="p-3" column>
|
||||||
<VChip
|
<VChip v-for="(item, index) in props.more" :key="index" @click.stop="handleAddDownload(item)">
|
||||||
v-for="(item, index) in props.more"
|
|
||||||
:key="index"
|
|
||||||
@click.stop="handleAddDownload(item.torrent_info?.site_name, item.media_info, item.torrent_info)"
|
|
||||||
>
|
|
||||||
<template #append>
|
<template #append>
|
||||||
<VBadge color="primary" :content="`↑${item.torrent_info?.seeders}`" inline size="small" />
|
<VBadge color="primary" :content="`↑${item.torrent_info?.seeders}`" inline size="small" />
|
||||||
<VBadge
|
<VBadge
|
||||||
@@ -213,9 +216,11 @@ onMounted(() => {
|
|||||||
<AddDownloadDialog
|
<AddDownloadDialog
|
||||||
v-if="addDownloadDialog"
|
v-if="addDownloadDialog"
|
||||||
v-model="addDownloadDialog"
|
v-model="addDownloadDialog"
|
||||||
:title="`${media?.title_year || meta?.name} ${meta?.season_episode}`"
|
:title="`${downloadItem?.media_info?.title_year || downloadItem?.meta_info?.name} ${
|
||||||
:media="media"
|
downloadItem?.meta_info?.season_episode
|
||||||
:torrent="torrent"
|
}`"
|
||||||
|
:media="downloadItem?.media_info"
|
||||||
|
:torrent="downloadItem?.torrent_info"
|
||||||
@done="addDownloadSuccess"
|
@done="addDownloadSuccess"
|
||||||
@error="addDownloadError"
|
@error="addDownloadError"
|
||||||
@close="addDownloadDialog = false"
|
@close="addDownloadDialog = false"
|
||||||
|
|||||||
@@ -130,9 +130,10 @@ onMounted(() => {
|
|||||||
<VCardText>
|
<VCardText>
|
||||||
<VRow>
|
<VRow>
|
||||||
<VCol cols="12" class="text-lg text-high-emphasis pb-0">
|
<VCol cols="12" class="text-lg text-high-emphasis pb-0">
|
||||||
<strong>标题:</strong>{{ props.torrent?.title }}<br />
|
<div><strong>站点:</strong>{{ props.torrent?.site_name }}</div>
|
||||||
<strong>站点:</strong>{{ props.torrent?.site_name }}<br />
|
<div><strong>标题:</strong>{{ props.torrent?.title }}</div>
|
||||||
<strong>大小:</strong>{{ formatFileSize(props.torrent?.size || 0) }}
|
<div><strong>描述:</strong>{{ props.torrent?.description }}</div>
|
||||||
|
<div><strong>大小:</strong>{{ formatFileSize(props.torrent?.size || 0) }}</div>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol cols="12" md="4">
|
<VCol cols="12" md="4">
|
||||||
<VSelect
|
<VSelect
|
||||||
|
|||||||
Reference in New Issue
Block a user