Some checks failed
deploy to server / build-and-deploy (push) Has been cancelled
- 将阈值有0.3调整至0.6
161 lines
3.7 KiB
Vue
161 lines
3.7 KiB
Vue
<template>
|
|
<div class="page-container">
|
|
<div v-if="pending">
|
|
<el-skeleton :rows="5" animated />
|
|
</div>
|
|
<div v-else>
|
|
<support-tabs model-value="documents" />
|
|
<div class="page-header">
|
|
<h1 class="page-title">{{ $t('navigation.documents') }}</h1>
|
|
<app-breadcrumb class="breadcrumb" :items="breadcrumbItems" />
|
|
</div>
|
|
<div class="page-content">
|
|
<product-filter
|
|
v-model="filters"
|
|
:product-type-options="productTypeOptions"
|
|
:product-options="productOptions"
|
|
/>
|
|
<document-list :documents="filteredDocuments" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
const localePath = useLocalePath();
|
|
const breadcrumbItems = [
|
|
{ label: $t('navigation.home'), to: localePath('/') },
|
|
{ label: $t('navigation.support'), to: localePath('/support') },
|
|
{ label: $t('navigation.documents') },
|
|
];
|
|
|
|
const filters = reactive({
|
|
selectedType: null as number | null,
|
|
selectedProduct: null as number | null,
|
|
keyword: '',
|
|
});
|
|
|
|
const { data, pending, error } = await useDocumentList();
|
|
|
|
const documents = computed(
|
|
() => data?.value.map((item) => toDocumentListView(item)) ?? []
|
|
);
|
|
|
|
const productTypeOptions = computed(() => {
|
|
const types: DocumentListProductType[] = [];
|
|
documents.value.forEach((doc: DocumentListView) => {
|
|
doc.products?.forEach((product: DocumentListProduct) => {
|
|
const productType = product.type;
|
|
if (!types.some((item) => item.id === productType.id)) {
|
|
types.push(productType);
|
|
}
|
|
});
|
|
});
|
|
|
|
return types;
|
|
});
|
|
|
|
const productOptions = computed(() => {
|
|
if (!filters.selectedType) return [];
|
|
const products: DocumentListProduct[] = [];
|
|
|
|
documents.value.forEach((doc: DocumentListView) => {
|
|
doc.products?.forEach((product: DocumentListProduct) => {
|
|
if (
|
|
product.type.id === filters.selectedType &&
|
|
!products.some((item) => item.id === product.id)
|
|
) {
|
|
products.push(product);
|
|
}
|
|
});
|
|
});
|
|
|
|
return products;
|
|
});
|
|
|
|
const filteredDocuments = computed(() => {
|
|
const fuzzyMatchedDocuments = fuzzyMatch(documents.value, {
|
|
keyword: filters.keyword,
|
|
keys: ['title'],
|
|
threshold: 0.6,
|
|
});
|
|
return fuzzyMatchedDocuments.filter((doc: DocumentListView) => {
|
|
const matchProduct = filters.selectedProduct
|
|
? doc.products?.some(
|
|
(product: DocumentListProduct) =>
|
|
product.id === filters.selectedProduct
|
|
)
|
|
: filters.selectedType
|
|
? doc.products?.some(
|
|
(product: DocumentListProduct) =>
|
|
product.type?.id === filters.selectedType
|
|
)
|
|
: true;
|
|
|
|
return matchProduct;
|
|
});
|
|
});
|
|
|
|
watch(
|
|
() => filters.selectedType,
|
|
() => {
|
|
filters.selectedProduct = null;
|
|
}
|
|
);
|
|
|
|
watch(error, (value) => {
|
|
if (value) {
|
|
logger.error('数据获取失败: ', value);
|
|
}
|
|
});
|
|
|
|
const pageTitle = $t('page-title.documents');
|
|
usePageSeo({
|
|
title: pageTitle,
|
|
});
|
|
</script>
|
|
|
|
<style scoped>
|
|
.page-container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.page-header {
|
|
display: flex;
|
|
padding: 2rem 2rem 0rem;
|
|
}
|
|
|
|
.page-title {
|
|
font-size: 2rem;
|
|
font-weight: bold;
|
|
color: var(--el-color-primary);
|
|
margin-bottom: 1rem;
|
|
}
|
|
|
|
.breadcrumb {
|
|
margin-left: auto;
|
|
}
|
|
|
|
.document-category {
|
|
padding: 0rem 2rem;
|
|
gap: 4px;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
|
|
.page-content {
|
|
padding: 1rem 2rem 2rem;
|
|
}
|
|
|
|
.select-label {
|
|
color: var(--el-text-color-secondary);
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
:deep(.el-select__wrapper),
|
|
:deep(.el-input__wrapper) {
|
|
height: 40px;
|
|
font-size: 0.9rem;
|
|
}
|
|
</style>
|