feat: 页面懒加载 #98

Manually merged
remilia merged 7 commits from feat/lazy-load into master 2025-12-19 13:28:25 +08:00
4 changed files with 188 additions and 83 deletions
Showing only changes of commit 537a6b0bd6 - Show all commits

View File

@ -10,31 +10,49 @@
<app-breadcrumb class="breadcrumb" :items="breadcrumbItems" /> <app-breadcrumb class="breadcrumb" :items="breadcrumbItems" />
</div> </div>
<div v-if="!pending" class="page-content"> <div>
<div class="products-container"> <el-skeleton
<el-collapse v-model="activeNames" class="product-collapse"> animated
<el-collapse-item :loading="pending"
v-for="[key, value] in Object.entries(groupedProducts)" :throttle="{ leading: 500, trailing: 500 }"
:key="key" >
:title="key || '未分类'" <template #template>
:name="key || 'no-category'" <div v-for="i in 3" :key="i" class="products-container">
> <el-skeleton-item variant="h1" class="skeleton-collapse" />
<div class="group-list"> <div class="skeleton-group-list">
<product-card <el-skeleton-item
v-for="product in value.data" v-for="j in 3"
:key="product.id" :key="j"
:slug="product.id.toString()" variant="rect"
:image-url="getImageUrl(product.cover.toString())" class="skeleton-card"
:name="product.name"
:description="product.summary || ''"
/> />
</div> </div>
</el-collapse-item> </div>
</el-collapse> </template>
</div> <template #default>
</div> <div class="products-container">
<div v-else> <el-collapse v-model="activeNames" class="product-collapse">
<el-skeleton :rows="6" animated /> <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>
</div> </div>
</template> </template>
@ -151,6 +169,46 @@
justify-content: flex-start; 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) { :deep(.el-collapse-item__header) {
padding: 30px auto; padding: 30px auto;
font-size: 1.5rem; font-size: 1.5rem;

View File

@ -7,7 +7,12 @@
</div> </div>
<div class="page-content"> <div class="page-content">
<el-skeleton :rows="10" :loading="pending" animated> <el-skeleton
:rows="10"
:loading="pending"
animated
:throttle="{ leading: 500, trailing: 500 }"
>
<template #default> <template #default>
<!-- eslint-disable-next-line vue/no-v-html --> <!-- eslint-disable-next-line vue/no-v-html -->
<div class="html-typography" v-html="contactInfo?.content || ''" /> <div class="html-typography" v-html="contactInfo?.content || ''" />