feat: 选择Library图片组件如果传入类型,只显示对应类型

This commit is contained in:
zhangyh
2025-09-24 13:42:27 +08:00
parent bdb3c50650
commit 96ae993ab0
3 changed files with 14 additions and 8 deletions

View File

@@ -228,7 +228,9 @@
ref="selectImages"
@select="handleImageSelect"
:api="Https.httpUrls.queryLibraryPage"
isLibrary/>
isLibrary
:libraryType="type_.type2"
/>
</div>
</template>
<script lang="ts">

View File

@@ -106,7 +106,7 @@ const props = defineProps({
type: Boolean,
default: false
},
level1Type: {
libraryType: {
type: String,
default: ''
}
@@ -119,12 +119,12 @@ const libraryTypeList = ref([
...navTypeList(t).library.list.filter(item => item.value !== 'MyBrand')
])
// 根据传入的level1Type参数确定默认选中的分类
// 根据传入的libraryType参数确定默认选中的分类
const getDefaultCategory = () => {
if (props.level1Type) {
// 如果传入了level1Type查找匹配的category
if (props.libraryType) {
// 如果传入了libraryType查找匹配的category
const matchedCategory = libraryTypeList.value.find(
item => item.value === props.level1Type
item => item.value === props.libraryType
)
return matchedCategory ? matchedCategory.label : libraryTypeList.value[0]?.label || ''
}
@@ -154,7 +154,7 @@ const categories = computed(() => {
// 计算属性:是否显示分类选择器
const showCategories = computed(() => {
return !props.level1Type // 如果没有传入level1Type参数则显示分类选择器
return !props.libraryType // 如果没有传入libraryType参数则显示分类选择器
})
// 新增API请求函数
@@ -169,7 +169,7 @@ const fetchImages = async (
const type = libraryTypeList.value.find(item => item.label === category)?.value
const params = {
classificationIdList: [],
level1Type: props.level1Type || type,
level1Type: props.libraryType || type,
level2Type: '',
page,
ageGroup: '',
@@ -242,6 +242,8 @@ const resetAndLoad = (category = selectedCategory.value) => {
list.value = []
hasMore.value = true
currentPage.value = 0
console.log('默认选择----',getDefaultCategory())
selectedCategory.value = getDefaultCategory()
fetchImages(1, category, true)
// 检查是否需要自动加载更多数据