feat:优化TheMovieDbView组件的watch逻辑,分离类型和过滤参数的监听,确保列表刷新更高效

This commit is contained in:
jxxghp
2025-02-09 22:00:38 +08:00
parent 391a160f97
commit d343d6d54d

View File

@@ -99,11 +99,18 @@ const tmdbLanguageDict = {
// 当前Key
const currentKey = ref(0)
// 类型和过滤参数变化后重新刷新列表
watch([type, filterParams], () => {
// 类型变化
watch(type, () => {
if (!type.value) {
type.value = 'movies'
}
filterParams.with_genres = ''
filterParams.sort_by = 'popularity.desc'
currentKey.value++
})
// 过滤参数变化
watch(filterParams, () => {
if (!filterParams.sort_by) {
filterParams.sort_by = 'popularity.desc'
}