feat: 选择Library图片组件如果传入类型,只显示对应类型
This commit is contained in:
2
components.d.ts
vendored
2
components.d.ts
vendored
@@ -18,6 +18,7 @@ declare module 'vue' {
|
||||
AMenu: typeof import('ant-design-vue/es')['Menu']
|
||||
AMenuItem: typeof import('ant-design-vue/es')['MenuItem']
|
||||
AModal: typeof import('ant-design-vue/es')['Modal']
|
||||
APagination: typeof import('ant-design-vue/es')['Pagination']
|
||||
APopover: typeof import('ant-design-vue/es')['Popover']
|
||||
ARangePicker: typeof import('ant-design-vue/es')['RangePicker']
|
||||
ASelect: typeof import('ant-design-vue/es')['Select']
|
||||
@@ -29,6 +30,7 @@ declare module 'vue' {
|
||||
ATabPane: typeof import('ant-design-vue/es')['TabPane']
|
||||
ATabs: typeof import('ant-design-vue/es')['Tabs']
|
||||
AUpload: typeof import('ant-design-vue/es')['Upload']
|
||||
ElCascader: typeof import('element-plus/es')['ElCascader']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
|
||||
@@ -228,7 +228,9 @@
|
||||
ref="selectImages"
|
||||
@select="handleImageSelect"
|
||||
:api="Https.httpUrls.queryLibraryPage"
|
||||
isLibrary/>
|
||||
isLibrary
|
||||
:libraryType="type_.type2"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
|
||||
@@ -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)
|
||||
|
||||
// 检查是否需要自动加载更多数据
|
||||
|
||||
Reference in New Issue
Block a user