mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-05 07:28:37 +08:00
feat:下载状态标记
This commit is contained in:
@@ -5,7 +5,7 @@ import { useConfirm } from 'vuetify-use-dialog'
|
|||||||
import { formatFileSize } from '@/@core/utils/formatters'
|
import { formatFileSize } from '@/@core/utils/formatters'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { doneNProgress, startNProgress } from '@/api/nprogress'
|
import { doneNProgress, startNProgress } from '@/api/nprogress'
|
||||||
import type { Context } from '@/api/types'
|
import type { Context, MediaInfo, TorrentInfo } from '@/api/types'
|
||||||
|
|
||||||
// 输入参数
|
// 输入参数
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -36,6 +36,9 @@ const meta = ref(props.torrent?.meta_info)
|
|||||||
// 站点图标
|
// 站点图标
|
||||||
const siteIcon = ref('')
|
const siteIcon = ref('')
|
||||||
|
|
||||||
|
// 存储是否已经下载过的记录
|
||||||
|
const downloaded = ref<String[]>([])
|
||||||
|
|
||||||
// 查询站点图标
|
// 查询站点图标
|
||||||
async function getSiteIcon() {
|
async function getSiteIcon() {
|
||||||
try {
|
try {
|
||||||
@@ -76,7 +79,7 @@ async function handleAddDownload(_site: any = undefined,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加下载
|
// 添加下载
|
||||||
async function addDownload(_media: any, _torrent: any) {
|
async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) {
|
||||||
startNProgress()
|
startNProgress()
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('download/', {
|
const result: { [key: string]: any } = await api.post('download/', {
|
||||||
@@ -87,6 +90,7 @@ async function addDownload(_media: any, _torrent: any) {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
// 添加下载成功
|
// 添加下载成功
|
||||||
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`)
|
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`)
|
||||||
|
downloaded.value.push(_torrent?.enclosure || '')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 添加下载失败
|
// 添加下载失败
|
||||||
@@ -131,6 +135,7 @@ onMounted(() => {
|
|||||||
<VCard
|
<VCard
|
||||||
:width="props.width"
|
:width="props.width"
|
||||||
:height="props.height"
|
:height="props.height"
|
||||||
|
:variant="downloaded.includes(torrent?.enclosure || '') ? 'tonal' : 'elevated'"
|
||||||
@click="handleAddDownload"
|
@click="handleAddDownload"
|
||||||
>
|
>
|
||||||
<template
|
<template
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useConfirm } from 'vuetify-use-dialog'
|
|||||||
import { formatFileSize } from '@/@core/utils/formatters'
|
import { formatFileSize } from '@/@core/utils/formatters'
|
||||||
import api from '@/api'
|
import api from '@/api'
|
||||||
import { doneNProgress, startNProgress } from '@/api/nprogress'
|
import { doneNProgress, startNProgress } from '@/api/nprogress'
|
||||||
import type { Context } from '@/api/types'
|
import type { Context, MediaInfo, TorrentInfo } from '@/api/types'
|
||||||
|
|
||||||
// 输入参数
|
// 输入参数
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@@ -33,6 +33,9 @@ const meta = ref(props.torrent?.meta_info)
|
|||||||
// 站点图标
|
// 站点图标
|
||||||
const siteIcon = ref('')
|
const siteIcon = ref('')
|
||||||
|
|
||||||
|
// 存储是否已经下载过的记录
|
||||||
|
const downloaded = ref<String[]>([])
|
||||||
|
|
||||||
// 查询站点图标
|
// 查询站点图标
|
||||||
async function getSiteIcon() {
|
async function getSiteIcon() {
|
||||||
try {
|
try {
|
||||||
@@ -73,7 +76,7 @@ async function handleAddDownload(_site: any = undefined,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 添加下载
|
// 添加下载
|
||||||
async function addDownload(_media: any, _torrent: any) {
|
async function addDownload(_media: MediaInfo, _torrent: TorrentInfo) {
|
||||||
startNProgress()
|
startNProgress()
|
||||||
try {
|
try {
|
||||||
const result: { [key: string]: any } = await api.post('download/', {
|
const result: { [key: string]: any } = await api.post('download/', {
|
||||||
@@ -84,6 +87,7 @@ async function addDownload(_media: any, _torrent: any) {
|
|||||||
if (result.success) {
|
if (result.success) {
|
||||||
// 添加下载成功
|
// 添加下载成功
|
||||||
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`)
|
$toast.success(`${_torrent?.site_name} ${_torrent?.title} 添加下载成功!`)
|
||||||
|
downloaded.value.push(_torrent?.enclosure || '')
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 添加下载失败
|
// 添加下载失败
|
||||||
@@ -125,7 +129,10 @@ onMounted(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VListItem @click="handleAddDownload">
|
<VListItem
|
||||||
|
@click="handleAddDownload"
|
||||||
|
:variant="downloaded.includes(torrent?.enclosure || '') ? 'tonal' : 'flat'"
|
||||||
|
>
|
||||||
<template
|
<template
|
||||||
v-if="!showMoreTorrents"
|
v-if="!showMoreTorrents"
|
||||||
#prepend
|
#prepend
|
||||||
|
|||||||
@@ -104,16 +104,16 @@ onMounted(() => {
|
|||||||
<template>
|
<template>
|
||||||
<VRow>
|
<VRow>
|
||||||
<VCol>
|
<VCol>
|
||||||
<VList v-if="dataList.length === 0" lines="three" class="rounded">
|
<VList v-if="dataList.length === 0" lines="three" class="rounded p-0">
|
||||||
<VListItem>
|
<VListItem>
|
||||||
<VListItemTitle>没有附合当前过滤条件的资源。</VListItemTitle>
|
<VListItemTitle>没有附合当前过滤条件的资源。</VListItemTitle>
|
||||||
</VListItem>
|
</VListItem>
|
||||||
</VList>
|
</VList>
|
||||||
<div>
|
<VList v-if="dataList.length !== 0" lines="three" class="rounded p-0">
|
||||||
<div v-for="(item, index) in dataList" :key="`${index}_${item.torrent_info.title}_${item.torrent_info.site}`">
|
<div v-for="(item, index) in dataList" :key="`${index}_${item.torrent_info.title}_${item.torrent_info.site}`">
|
||||||
<TorrentItem v-if="defer(index)" :torrent="item" />
|
<TorrentItem v-if="defer(index)" :torrent="item" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</VList>
|
||||||
</VCol>
|
</VCol>
|
||||||
<VCol xl="2" md="3" class="d-none d-md-block">
|
<VCol xl="2" md="3" class="d-none d-md-block">
|
||||||
<VList lines="one" class="rounded">
|
<VList lines="one" class="rounded">
|
||||||
|
|||||||
Reference in New Issue
Block a user