181 lines
4.2 KiB
Vue
181 lines
4.2 KiB
Vue
<template>
|
|
<div class="page-container">
|
|
<div class="page-header">
|
|
<div>
|
|
<h1 class="page-title">{{ $t('learn-our-solutions') }}</h1>
|
|
<p class="page-subtitle">{{ $t('solutions-desc') }}</p>
|
|
</div>
|
|
|
|
<app-breadcrumb class="breadcrumb" :items="breadcrumbItems" />
|
|
</div>
|
|
<div class="solutions-container">
|
|
<el-skeleton
|
|
:loading="pending"
|
|
animated
|
|
:throttle="{
|
|
leading: 500,
|
|
trailing: 500,
|
|
}"
|
|
>
|
|
<template #template>
|
|
<div class="skeleton-group-list">
|
|
<el-skeleton-item
|
|
v-for="i in 12"
|
|
:key="i"
|
|
variant="rect"
|
|
class="skeleton-card"
|
|
/>
|
|
</div>
|
|
</template>
|
|
<template #default>
|
|
<el-tabs v-model="activeName" class="solutions-tabs">
|
|
<el-tab-pane :label="$t('all')" name="all">
|
|
<div class="solution-list">
|
|
<solution-card
|
|
v-for="solution in solutions"
|
|
:key="solution.id"
|
|
:title="solution.title"
|
|
:summary="solution.summary || ''"
|
|
:cover-url="getImageUrl(solution.cover || '')"
|
|
:document-id="solution.id.toString()"
|
|
/>
|
|
</div>
|
|
</el-tab-pane>
|
|
<el-tab-pane
|
|
v-for="[key, value] in Object.entries(groupedSolutions)"
|
|
:key="key"
|
|
:label="key || '未分类'"
|
|
:name="key || 'no-category'"
|
|
>
|
|
<div class="solution-list">
|
|
<solution-card
|
|
v-for="solution in value.data"
|
|
:key="solution.id"
|
|
:document-id="solution.id.toString()"
|
|
:cover-url="getImageUrl(solution.cover || '')"
|
|
:title="solution.title"
|
|
:summary="solution.summary || ''"
|
|
/>
|
|
</div>
|
|
</el-tab-pane>
|
|
</el-tabs>
|
|
</template>
|
|
</el-skeleton>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
const localePath = useLocalePath();
|
|
const { getImageUrl } = useDirectusImage();
|
|
|
|
const breadcrumbItems = [
|
|
{ label: $t('navigation.home'), to: localePath('/') },
|
|
{ label: $t('navigation.solutions') },
|
|
];
|
|
|
|
const { data, pending, error } = useSolutionList();
|
|
|
|
const solutions = computed(() => data.value ?? []);
|
|
|
|
const activeName = ref<string>('all');
|
|
|
|
// 按类型分组
|
|
const groupedSolutions = computed(() => {
|
|
const groups: Record<string, { data: SolutionListView[]; sort: number }> =
|
|
{};
|
|
for (const sol of solutions.value) {
|
|
const typeKey = sol.solution_type?.name ?? '';
|
|
if (!groups[typeKey]) {
|
|
groups[typeKey] = { data: [], sort: sol.solution_type?.sort ?? 999 };
|
|
}
|
|
groups[typeKey]?.data.push(sol);
|
|
}
|
|
const sortedGroups = Object.fromEntries(
|
|
Object.entries(groups).sort(([, a], [, b]) => a.sort - b.sort)
|
|
);
|
|
return sortedGroups;
|
|
});
|
|
|
|
watch(error, (value) => {
|
|
if (value) {
|
|
logger.error('数据获取失败: ', value);
|
|
}
|
|
});
|
|
|
|
const pageTitle = $t('page-title.solutions');
|
|
usePageSeo({
|
|
title: pageTitle,
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.page-container {
|
|
padding: 2rem;
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.page-header {
|
|
display: flex;
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.page-title {
|
|
font-size: 2rem;
|
|
font-weight: bold;
|
|
color: var(--el-color-primary);
|
|
}
|
|
|
|
.page-subtitle {
|
|
font-size: 0.8rem;
|
|
color: var(--el-text-color-secondary);
|
|
}
|
|
|
|
.breadcrumb {
|
|
margin-left: auto;
|
|
}
|
|
|
|
.solution-list {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
padding: 1rem;
|
|
margin-bottom: 2rem;
|
|
gap: 40px;
|
|
}
|
|
|
|
.skeleton-group-list {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 20px;
|
|
justify-content: flex-start;
|
|
margin-bottom: 2rem;
|
|
}
|
|
|
|
.skeleton-card {
|
|
width: 30%;
|
|
height: 200px;
|
|
}
|
|
|
|
@media (max-width: 1200px) {
|
|
.skeleton-card {
|
|
width: 45%;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.skeleton-group-list {
|
|
justify-content: center;
|
|
align-items: center;
|
|
}
|
|
|
|
.skeleton-card {
|
|
width: 90%;
|
|
}
|
|
|
|
.breadcrumb {
|
|
display: none;
|
|
}
|
|
}
|
|
</style>
|