fix: 调整产品列表页渲染机制
- 渲染机制:产品列表页懒加载采用el-skeleton自身模板机制 - 布局调整:调整产品页/骨架屏在竖屏下的布局
This commit is contained in:
@ -10,31 +10,49 @@
|
||||
|
||||
<app-breadcrumb class="breadcrumb" :items="breadcrumbItems" />
|
||||
</div>
|
||||
<div v-if="!pending" class="page-content">
|
||||
<div class="products-container">
|
||||
<el-collapse v-model="activeNames" class="product-collapse">
|
||||
<el-collapse-item
|
||||
v-for="[key, value] in Object.entries(groupedProducts)"
|
||||
:key="key"
|
||||
:title="key || '未分类'"
|
||||
:name="key || 'no-category'"
|
||||
>
|
||||
<div class="group-list">
|
||||
<product-card
|
||||
v-for="product in value.data"
|
||||
:key="product.id"
|
||||
:slug="product.id.toString()"
|
||||
:image-url="getImageUrl(product.cover.toString())"
|
||||
:name="product.name"
|
||||
:description="product.summary || ''"
|
||||
<div>
|
||||
<el-skeleton
|
||||
animated
|
||||
:loading="pending"
|
||||
:throttle="{ leading: 500, trailing: 500 }"
|
||||
>
|
||||
<template #template>
|
||||
<div v-for="i in 3" :key="i" class="products-container">
|
||||
<el-skeleton-item variant="h1" class="skeleton-collapse" />
|
||||
<div class="skeleton-group-list">
|
||||
<el-skeleton-item
|
||||
v-for="j in 3"
|
||||
:key="j"
|
||||
variant="rect"
|
||||
class="skeleton-card"
|
||||
/>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
<el-skeleton :rows="6" animated />
|
||||
</div>
|
||||
</template>
|
||||
<template #default>
|
||||
<div class="products-container">
|
||||
<el-collapse v-model="activeNames" class="product-collapse">
|
||||
<el-collapse-item
|
||||
v-for="[key, value] in Object.entries(groupedProducts)"
|
||||
:key="key"
|
||||
:title="key || '未分类'"
|
||||
:name="key || 'no-category'"
|
||||
>
|
||||
<div class="group-list">
|
||||
<product-card
|
||||
v-for="product in value.data"
|
||||
:key="product.id"
|
||||
:slug="product.id.toString()"
|
||||
:image-url="getImageUrl(product.cover.toString())"
|
||||
:name="product.name"
|
||||
:description="product.summary || ''"
|
||||
/>
|
||||
</div>
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
</template>
|
||||
</el-skeleton>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -151,6 +169,46 @@
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.skeleton-collapse {
|
||||
height: 50px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.skeleton-group-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 40px;
|
||||
justify-content: flex-start;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.skeleton-card {
|
||||
width: 30%;
|
||||
height: 250px;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
.skeleton-card {
|
||||
width: 45%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.group-list {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
.skeleton-group-list {
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.skeleton-card {
|
||||
width: 90%;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-collapse-item__header) {
|
||||
padding: 30px auto;
|
||||
font-size: 1.5rem;
|
||||
|
||||
Reference in New Issue
Block a user