From cf3a204eac89e90a5af7101daaaef8e35b2e81f1 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 30 Sep 2024 16:00:32 +0800 Subject: [PATCH] refactor: Remove unused import in SiteTorrentTable.vue Remove the unused import of MediaInfo in SiteTorrentTable.vue to improve code cleanliness and reduce potential confusion. --- src/api/types.ts | 40 +++ src/components/cards/SubscribeCard.vue | 68 ++-- src/components/dialog/SubscribeEditDialog.vue | 6 +- .../dialog/SubscribeFilesDialog.vue | 301 ++++++++++++++++++ src/components/table/SiteTorrentTable.vue | 2 +- src/views/discover/MediaDetailView.vue | 15 +- 6 files changed, 397 insertions(+), 35 deletions(-) create mode 100644 src/components/dialog/SubscribeFilesDialog.vue diff --git a/src/api/types.ts b/src/api/types.ts index 86695b4a..b44ebcf5 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -982,3 +982,43 @@ export interface FilterRuleGroup { // # 适用媒体类别 None-全部 对应二级分类 category?: string } + +export interface SubscribeDownloadFileInfo { + // 种子名称 + torrent_title?: string + // 站点名称 + site_name?: string + // 下载器 + downloader?: string + // hash + hash?: string + // 文件路径 + file_path?: string +} + +export interface SubscribeLibraryFileInfo { + // 存储 + storage?: string + // 文件路径 + file_path?: string +} + +export interface SubscribeEpisodeInfo { + // 标题 + title?: string + // 描述 + description?: string + // 背景图 + backdrop?: string + // 下载文件信息 + download?: SubscribeDownloadFileInfo[] + // 媒体库文件信息 + library?: SubscribeLibraryFileInfo[] +} + +export interface SubscrbieInfo { + // 订阅信息 + subscribe: Subscribe + // 集信息 {集号: {download: 文件路径,library: 文件路径, backdrop: url, title: 标题, description: 描述}} + episodes: Record +} diff --git a/src/components/cards/SubscribeCard.vue b/src/components/cards/SubscribeCard.vue index e8079f38..b31bd0f7 100644 --- a/src/components/cards/SubscribeCard.vue +++ b/src/components/cards/SubscribeCard.vue @@ -2,6 +2,7 @@ import { useToast } from 'vue-toast-notification' import { useConfirm } from 'vuetify-use-dialog' import SubscribeEditDialog from '../dialog/SubscribeEditDialog.vue' +import SubscribeFilesDialog from '../dialog/SubscribeFilesDialog.vue' import { formatDateDifference } from '@/@core/utils/formatters' import { formatSeason } from '@/@core/utils/formatters' import api from '@/api' @@ -31,6 +32,9 @@ const imageLoaded = ref(false) // 订阅弹窗 const subscribeEditDialog = ref(false) +// 订阅文件信息弹窗 +const subscribeFilesDialog = ref(false) + // 上一次更新时间 const lastUpdateText = ref(props.media && props.media.last_update ? formatDateDifference(props.media.last_update) : '') @@ -39,13 +43,6 @@ function imageLoadHandler() { imageLoaded.value = true } -// 根据 type 返回不同的图标 -function getIcon() { - if (props.media?.type === '电影') return 'mdi-movie-open' - else if (props.media?.type === '电视剧') return 'mdi-television-play' - else return 'mdi-help-circle' -} - // 计算百分比 function getPercentage() { if (props.media?.total_episode === 0) return 0 @@ -107,7 +104,7 @@ async function editSubscribeDialog() { subscribeEditDialog.value = true } -// 查看详情 +// 查看媒体详情 async function viewMediaDetail() { router.push({ path: '/media', @@ -118,6 +115,11 @@ async function viewMediaDetail() { }) } +// 查看文件详情 +async function viewSubscribeFiles() { + subscribeFilesDialog.value = true +} + // 弹出菜单 const dropdownItems = ref([ { @@ -137,16 +139,24 @@ const dropdownItems = ref([ }, }, { - title: '查看详情', + title: '媒体详情', value: 3, props: { - prependIcon: 'mdi-open-in-new', + prependIcon: 'mdi-information-outline', click: viewMediaDetail, }, }, { - title: '重置', + title: '文件信息', value: 4, + props: { + prependIcon: 'mdi-file-document-outline', + click: viewSubscribeFiles, + }, + }, + { + title: '重置', + value: 5, props: { prependIcon: 'mdi-restore-alert', click: resetSubscribe, @@ -156,7 +166,7 @@ const dropdownItems = ref([ }, { title: '取消订阅', - value: 5, + value: 6, props: { prependIcon: 'mdi-trash-can-outline', color: 'error', @@ -190,6 +200,18 @@ const posterUrl = computed(() => { return `${import.meta.env.VITE_API_BASE_URL}system/cache/image?url=${encodeURIComponent(url)}` return url }) + +// 订阅编辑保存 +function onSubscribeEditSave() { + subscribeEditDialog.value = false + emit('save') +} + +// 订阅编辑取消 +function onSubscribeEditRemove() { + subscribeEditDialog.value = false + emit('remove') +} diff --git a/src/components/table/SiteTorrentTable.vue b/src/components/table/SiteTorrentTable.vue index 282e4f96..0eeedc88 100644 --- a/src/components/table/SiteTorrentTable.vue +++ b/src/components/table/SiteTorrentTable.vue @@ -1,6 +1,6 @@