feat: 颜色上传可以从library选择&历史列表参数修改

This commit is contained in:
zhangyh
2025-09-24 11:51:22 +08:00
parent 05e9bada5a
commit 3e3b8b17fe
8 changed files with 184 additions and 57 deletions

View File

@@ -8,7 +8,7 @@
<div class="modal-content">
<!-- 分类标签 -->
<div class="image-categories">
<div v-if="showCategories" class="image-categories">
<div
v-for="category in categories"
:key="category"
@@ -88,11 +88,6 @@ import { navTypeList } from '@/tool/listData'
const { t } = useI18n()
const libraryTypeList = [
{ label: t('Canvas.all'), value: '' },
...navTypeList(t).library.list
]
// Props
const props = defineProps({
api: {
@@ -110,35 +105,58 @@ const props = defineProps({
fullData: {
type: Boolean,
default: false
},
level1Type: {
type: String,
default: ''
}
})
// Emits
const emits = defineEmits(['select'])
// 响应式数据
const libraryTypeList = ref([
...navTypeList(t).library.list.filter(item => item.value !== 'MyBrand')
])
// 根据传入的level1Type参数确定默认选中的分类
const getDefaultCategory = () => {
if (props.level1Type) {
// 如果传入了level1Type查找匹配的category
const matchedCategory = libraryTypeList.value.find(
item => item.value === props.level1Type
)
return matchedCategory ? matchedCategory.label : libraryTypeList.value[0]?.label || ''
}
// 如果没有传入参数,选择第一个
return libraryTypeList.value[0]?.label || ''
}
const showPanel = ref(false)
const selectedCategory = ref(t('Canvas.all'))
const selectedCategory = ref(getDefaultCategory())
const selectList = ref([])
const list = ref([])
// 新增:分页和加载状态
const currentPage = ref(1)
const hasMore = ref(true)
const loading = ref(false)
// 内部管理的分页大小
const pageSize = ref(10)
const total = ref(0)
// 计算属性:获取所有分类
const categories = computed(() => {
if (props.isLibrary) {
return libraryTypeList.map(item => item.label)
return libraryTypeList.value.map(item => item.label)
} else {
return []
}
})
// 计算属性:是否显示分类选择器
const showCategories = computed(() => {
return !props.level1Type // 如果没有传入level1Type参数则显示分类选择器
})
// 新增API请求函数
const fetchImages = async (
page = 1,
@@ -148,11 +166,10 @@ const fetchImages = async (
if (!props.api) return
loading.value = true
const type = libraryTypeList.find(item => item.label === category).value
console.log('type', type)
const type = libraryTypeList.value.find(item => item.label === category)?.value
const params = {
classificationIdList: [],
level1Type: 'Printboard',
level1Type: props.level1Type || type,
level2Type: '',
page,
ageGroup: '',