feat:在ExtraSourceView中添加默认过滤参数支持,确保过滤条件的完整性

This commit is contained in:
jxxghp
2025-02-08 12:53:26 +08:00
parent bd3f24c84b
commit ef5680d5ad

View File

@@ -2,12 +2,16 @@
import { DiscoverSource } from '@/api/types'
import MediaCardListView from '@/views/discover/MediaCardListView.vue'
import FormRender from '@/components/render/FormRender.vue'
import { cloneDeep } from 'lodash'
// 输入参数
const props = defineProps<{
source: DiscoverSource
}>()
// 默认输入参数
const default_params = cloneDeep(props.source.filter_params)
// 过滤参数
const filterParams = reactive(props.source.filter_params)
@@ -16,6 +20,12 @@ const currentKey = ref(0)
// 类型和过滤参数变化后重新刷新列表
watch([filterParams], () => {
// 检查每个值,如果没有值但有默认值时,设置为默认值
for (const key in filterParams) {
if (!filterParams[key] && default_params[key]) {
filterParams[key] = default_params[key]
}
}
currentKey.value++
})
</script>