mirror of
https://github.com/jxxghp/MoviePilot-Frontend.git
synced 2026-09-07 08:46:40 +08:00
feat:为TMDB排序和风格字典添加类型定义,优化过滤参数的逻辑,确保参数有效性
This commit is contained in:
@@ -17,7 +17,7 @@ const filterParams = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// TMDB 电影排序字典
|
// TMDB 电影排序字典
|
||||||
const tmdbSortDict = {
|
const tmdbSortDict: Record<string, string> = {
|
||||||
'popularity.desc': '热度降序',
|
'popularity.desc': '热度降序',
|
||||||
'popularity.asc': '热度升序',
|
'popularity.asc': '热度升序',
|
||||||
'release_date.desc': '上映日期降序',
|
'release_date.desc': '上映日期降序',
|
||||||
@@ -27,7 +27,7 @@ const tmdbSortDict = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TMDB 电视剧排序字典
|
// TMDB 电视剧排序字典
|
||||||
const tmdbTvSortDict = {
|
const tmdbTvSortDict: Record<string, string> = {
|
||||||
'popularity.desc': '热度降序',
|
'popularity.desc': '热度降序',
|
||||||
'popularity.asc': '热度升序',
|
'popularity.asc': '热度升序',
|
||||||
'first_air_date.desc': '首播日期降序',
|
'first_air_date.desc': '首播日期降序',
|
||||||
@@ -37,7 +37,7 @@ const tmdbTvSortDict = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TMDB电影风格字典
|
// TMDB电影风格字典
|
||||||
const tmdbMovieGenreDict = {
|
const tmdbMovieGenreDict: Record<string, string> = {
|
||||||
'28': '动作',
|
'28': '动作',
|
||||||
'12': '冒险',
|
'12': '冒险',
|
||||||
'16': '动画',
|
'16': '动画',
|
||||||
@@ -60,7 +60,7 @@ const tmdbMovieGenreDict = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TMDB电视剧风格字典
|
// TMDB电视剧风格字典
|
||||||
const tmdbTvGenreDict = {
|
const tmdbTvGenreDict: Record<string, string> = {
|
||||||
'10759': '动作冒险',
|
'10759': '动作冒险',
|
||||||
'16': '动画',
|
'16': '动画',
|
||||||
'35': '喜剧',
|
'35': '喜剧',
|
||||||
@@ -104,9 +104,30 @@ watch(type, () => {
|
|||||||
if (!type.value) {
|
if (!type.value) {
|
||||||
type.value = 'movies'
|
type.value = 'movies'
|
||||||
}
|
}
|
||||||
filterParams.with_genres = ''
|
let refresh = true
|
||||||
filterParams.sort_by = 'popularity.desc'
|
if (type.value === 'movies') {
|
||||||
currentKey.value++
|
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++
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 过滤参数变化
|
// 过滤参数变化
|
||||||
|
|||||||
Reference in New Issue
Block a user