From 68c14c24b8c412f16b77e06234e9f9315451fd68 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sun, 9 Feb 2025 22:21:43 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E4=B8=BATMDB=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E5=92=8C=E9=A3=8E=E6=A0=BC=E5=AD=97=E5=85=B8=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E5=AE=9A=E4=B9=89=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=8F=82=E6=95=B0=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E7=A1=AE=E4=BF=9D=E5=8F=82=E6=95=B0=E6=9C=89=E6=95=88?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/discover/TheMovieDbView.vue | 35 +++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/src/views/discover/TheMovieDbView.vue b/src/views/discover/TheMovieDbView.vue index ed674c68..7a40c01e 100644 --- a/src/views/discover/TheMovieDbView.vue +++ b/src/views/discover/TheMovieDbView.vue @@ -17,7 +17,7 @@ const filterParams = reactive({ }) // TMDB 电影排序字典 -const tmdbSortDict = { +const tmdbSortDict: Record = { 'popularity.desc': '热度降序', 'popularity.asc': '热度升序', 'release_date.desc': '上映日期降序', @@ -27,7 +27,7 @@ const tmdbSortDict = { } // TMDB 电视剧排序字典 -const tmdbTvSortDict = { +const tmdbTvSortDict: Record = { 'popularity.desc': '热度降序', 'popularity.asc': '热度升序', 'first_air_date.desc': '首播日期降序', @@ -37,7 +37,7 @@ const tmdbTvSortDict = { } // TMDB电影风格字典 -const tmdbMovieGenreDict = { +const tmdbMovieGenreDict: Record = { '28': '动作', '12': '冒险', '16': '动画', @@ -60,7 +60,7 @@ const tmdbMovieGenreDict = { } // TMDB电视剧风格字典 -const tmdbTvGenreDict = { +const tmdbTvGenreDict: Record = { '10759': '动作冒险', '16': '动画', '35': '喜剧', @@ -104,9 +104,30 @@ watch(type, () => { if (!type.value) { type.value = 'movies' } - filterParams.with_genres = '' - filterParams.sort_by = 'popularity.desc' - currentKey.value++ + let refresh = true + if (type.value === 'movies') { + if (!tmdbSortDict[filterParams.sort_by]) { + filterParams.sort_by = 'popularity.desc' + refresh = false + } + if (!tmdbMovieGenreDict[filterParams.with_genres]) { + filterParams.with_genres = '' + refresh = false + } + } + if (type.value === 'tvs') { + if (!tmdbTvSortDict[filterParams.sort_by]) { + filterParams.sort_by = 'popularity.desc' + refresh = false + } + if (!tmdbTvGenreDict[filterParams.with_genres]) { + filterParams.with_genres = '' + refresh = false + } + } + if (refresh) { + currentKey.value++ + } }) // 过滤参数变化