From 7adbfe9a9937916d4f4a6ee2154d2ec7ea2ebebc Mon Sep 17 00:00:00 2001 From: jxxghp Date: Thu, 13 Jul 2023 17:36:03 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E8=B5=84=E6=BA=90=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E8=BF=87=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/discover/TorrentCardListView.vue | 175 +++++++++++++++++++++ 1 file changed, 175 insertions(+) diff --git a/src/views/discover/TorrentCardListView.vue b/src/views/discover/TorrentCardListView.vue index 296320f6..e9975e24 100644 --- a/src/views/discover/TorrentCardListView.vue +++ b/src/views/discover/TorrentCardListView.vue @@ -28,6 +28,121 @@ const progressValue = ref(0); // 加载进度SSE const progressEventSource = ref(); +// 过滤表单 +const filterForm = reactive({ + // 站点 + site: [] as string[], + // 季 + season: [] as string[], + // 制作组 + releaseGroup: [] as string[], + // 视频编码 + videoCode: [] as string[], + // 促销状态 + freeState: [] as string[], +}); + +// 获取站点过滤选项 +const getSiteFilterOptions = computed(() => { + const options: string[] = []; + dataList.value.forEach((data) => { + if (data.torrent_info?.site_name && !options.includes(data.torrent_info?.site_name)) { + options.push(data.torrent_info?.site_name); + } + }); + return options; +}); + +// 获取季过滤选项 +const getSeasonFilterOptions = computed(() => { + const options: string[] = []; + dataList.value.forEach((data) => { + if ( + data.meta_info.season_episode && + !options.includes(data.meta_info.season_episode) + ) { + options.push(data.meta_info.season_episode); + } + }); + return options; +}); + +// 获取制作组过滤选项 +const getReleaseGroupFilterOptions = computed(() => { + const options: string[] = []; + dataList.value.forEach((data) => { + if (data.meta_info.resource_team && !options.includes(data.meta_info.resource_team)) { + options.push(data.meta_info.resource_team); + } + }); + return options; +}); + +// 获取视频编码过滤选项 +const getVideoCodeFilterOptions = computed(() => { + const options: string[] = []; + dataList.value.forEach((data) => { + if (data.meta_info.video_encode && !options.includes(data.meta_info.video_encode)) { + options.push(data.meta_info.video_encode); + } + }); + return options; +}); + +// 获取促销状态过滤选项 +const getFreeStateFilterOptions = computed(() => { + const options: string[] = []; + dataList.value.forEach((data) => { + if ( + data.torrent_info.volume_factor && + !options.includes(data.torrent_info.volume_factor) + ) { + options.push(data.torrent_info.volume_factor); + } + }); + return options; +}); + +// 按过滤项过滤卡片 +const filterTorrentsCard = (data: Context) => { + const { torrent_info, meta_info } = data; + const { site_name, volume_factor } = torrent_info; + const { season_episode, resource_team, video_encode } = meta_info; + + // 站点过滤 + if (filterForm.site.length > 0 && !filterForm.site.includes(site_name || "")) { + return false; + } + + // 季过滤 + if (filterForm.season.length > 0 && !filterForm.season.includes(season_episode)) { + return false; + } + + // 制作组过滤 + if ( + filterForm.releaseGroup.length > 0 && + !filterForm.releaseGroup.includes(resource_team || "") + ) { + return false; + } + + // 视频编码过滤 + if ( + filterForm.videoCode.length > 0 && + !filterForm.videoCode.includes(video_encode || "") + ) { + return false; + } + + // 促销状态过滤 + if (filterForm.freeState.length > 0 && !filterForm.freeState.includes(volume_factor)) { + return false; + } + + return true; +}; + // 获取订阅列表数据 const fetchData = async () => { try { @@ -111,6 +226,65 @@ onBeforeMount(fetchData);