Compare commits
123 Commits
e81532f920
...
feat/icp
| Author | SHA1 | Date | |
|---|---|---|---|
| ef20832761 | |||
| 03a692afb5 | |||
| 7b21def74f | |||
| 783d482e0a | |||
| 62ec215340 | |||
| e02f975217 | |||
| 5530776035 | |||
| 63cdff9c41 | |||
| f1398a5545 | |||
| 36d24a4740 | |||
| c9b5b1fad9 | |||
| 246a0b9d4f | |||
| c3ac7c0985 | |||
| 63c3e2e364 | |||
| 1245df497b | |||
| f081a3b33a | |||
| 3c6bff4d31 | |||
| 5011448902 | |||
| 53f3e99d90 | |||
| 815df40745 | |||
| c27337a145 | |||
| 3fb721f278 | |||
| a4dc28fc97 | |||
| 55a35b5498 | |||
| f4ec82a150 | |||
| c82fea48b8 | |||
| 39a23fb382 | |||
| 871b203a5e | |||
| b746247ccc | |||
| 97069815dc | |||
| 5194c72695 | |||
| dbe75ee080 | |||
| 4471851c62 | |||
| 15a75f965b | |||
| 5a4cef52be | |||
| 30ffc7e557 | |||
| c4b9ed7bae | |||
| fc6c922ac3 | |||
| 54389b32ac | |||
| d8002a8265 | |||
| 51042c395a | |||
| 6cf964e8f7 | |||
| 456f2c69f2 | |||
| 6f005c1404 | |||
| 1ab6d92226 | |||
| 67629ed518 | |||
| fe8a0e7656 | |||
| a82872c1c1 | |||
| 02ecb18147 | |||
| 05c970d1e7 | |||
| 496548afa4 | |||
| 6f08701847 | |||
| 17bb8adee3 | |||
| b2b631ed46 | |||
| ec9a097ef5 | |||
| 3fb28c3f00 | |||
| d7bd034d7d | |||
| 341a9c4066 | |||
| ee1597d2c3 | |||
| 17d10a7d80 | |||
| 54d0e297ea | |||
| 644dfa329c | |||
| 100b79f99b | |||
| f4f7e490b4 | |||
| 6418587738 | |||
| 6983f6568d | |||
| c860621e7a | |||
| 154943815d | |||
| 23f2700c0f | |||
| e215a4d498 | |||
| 50f0779a8e | |||
| 5ee6005ad1 | |||
| a520775a8d | |||
| a5f3895794 | |||
| 58223734a2 | |||
| 9163c7fe9a | |||
| 726c38a75d | |||
| 81caa02d11 | |||
| 8213eec217 | |||
| ac9e7b4436 | |||
| 5ad6133252 | |||
| a07d77dde7 | |||
| 3e7b195002 | |||
| 706b754905 | |||
| 0d77e97ad5 | |||
| ac658e01ae | |||
| a93f508e85 | |||
| 1290189d84 | |||
| 691dd34127 | |||
| 7e7775ccc6 | |||
| b234018f72 | |||
| 7b19f59409 | |||
| 9de6ab8799 | |||
| 86b0c29dcf | |||
| 352be1686a | |||
| 710a0cdc5b | |||
| 4c8dfb5b56 | |||
| 007c8f9ce9 | |||
| 0363a88785 | |||
| 308a080ea4 | |||
| a34cfaff6f | |||
| bd894d6f2e | |||
| b4da838cae | |||
| 660892f9e7 | |||
| 2a021cbaea | |||
| d55fe5cce2 | |||
| 9313700660 | |||
| 9d3276a56a | |||
| 37e89c3eda | |||
| b386d4e60d | |||
| bfdae60910 | |||
| e04b9d57da | |||
| 0265ea4978 | |||
| 1cdc29b1ce | |||
| 58e91ed67c | |||
| 191459ec5c | |||
| 881c0ab61e | |||
| f8c95207c2 | |||
| aba3729335 | |||
| 516ad9fa1c | |||
| 6a3493c7e1 | |||
| a328414b4e | |||
| 082fe9fea8 |
5
.graphqlrc.yaml
Normal file
5
.graphqlrc.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
schema:
|
||||
- 'http://192.168.86.5:8055/graphql':
|
||||
headers:
|
||||
Authorization: 'Bearer ixSWeViHIqwj6_r7NM-uZVR3NNOyBa_W'
|
||||
documents: 'app/graphql/**/*.{graphql,js,ts,jsx,tsx}'
|
||||
12
Dockerfile
12
Dockerfile
@ -32,10 +32,20 @@ WORKDIR /app
|
||||
# COPY .output folder
|
||||
COPY --from=build /app/.output ./
|
||||
|
||||
|
||||
ARG BUILD_TIME
|
||||
ARG GIT_COMMIT
|
||||
|
||||
RUN echo "{\"buildTime\":\"$BUILD_TIME\",\"gitCommit\":\"$GIT_COMMIT\"}" > /app/version.json
|
||||
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENV PORT=3000
|
||||
ENV NITRO_PRESET=node-server
|
||||
ENV HOST=0.0.0.0
|
||||
|
||||
EXPOSE 3000
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD ["node", "/app/server/index.mjs"]
|
||||
|
||||
95
app/assets/css/typography.css
Normal file
95
app/assets/css/typography.css
Normal file
@ -0,0 +1,95 @@
|
||||
.html-typography {
|
||||
padding: 10px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.html-typography h1 {
|
||||
color: var(--el-color-primary);
|
||||
font-size: 1.5em;
|
||||
margin-bottom: 0.5em;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.html-typography h2 {
|
||||
color: var(--el-color-primary);
|
||||
font-size: 1.5em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.html-typography h3 {
|
||||
color: var(--el-color-primary);
|
||||
font-size: 1.2em;
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
|
||||
.html-typography p {
|
||||
text-indent: 2em;
|
||||
text-align: justify;
|
||||
margin: 0.5em 0;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.html-typography ol {
|
||||
list-style-type: decimal;
|
||||
padding-left: 2em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.html-typography ul {
|
||||
list-style-type: disc;
|
||||
padding-left: 2em;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.html-typography hr {
|
||||
border: none;
|
||||
border-top: 1px solid var(--el-border-color);
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
/* 表格基础样式 */
|
||||
.html-typography table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
border: 1px solid var(--el-border-color);
|
||||
margin: 1em 0;
|
||||
table-layout: auto;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* 单元格通用样式 */
|
||||
.html-typography th,
|
||||
.html-typography td {
|
||||
border: 1px solid var(--el-border-color);
|
||||
padding: 8px 12px;
|
||||
text-align: left;
|
||||
vertical-align: middle;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* 表头样式 */
|
||||
.html-typography th {
|
||||
background-color: var(--el-fill-color-light);
|
||||
color: var(--el-text-color-primary);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 行 hover 效果 */
|
||||
.html-typography tbody tr:hover {
|
||||
background-color: var(--el-fill-color-light-hover);
|
||||
}
|
||||
|
||||
/* 交替行背景 */
|
||||
.html-typography tbody tr:nth-child(odd) {
|
||||
background-color: var(--el-fill-color-lighter);
|
||||
}
|
||||
|
||||
/* 表格标题(如有 caption) */
|
||||
.html-typography table caption {
|
||||
caption-side: top;
|
||||
text-align: left;
|
||||
padding: 8px 0;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
107
app/components/pages/about/LearnMoreCard.vue
Normal file
107
app/components/pages/about/LearnMoreCard.vue
Normal file
@ -0,0 +1,107 @@
|
||||
<template>
|
||||
<component
|
||||
:is="wrapperTag"
|
||||
v-bind="wrapperProps"
|
||||
class="learn-more-wrapper"
|
||||
@click="handleAsyncClick"
|
||||
>
|
||||
<el-card class="learn-more-card">
|
||||
<el-icon class="icon" size="80">
|
||||
<component :is="icon" />
|
||||
</el-icon>
|
||||
<br />
|
||||
{{ title }}
|
||||
</el-card>
|
||||
</component>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const props = defineProps({
|
||||
title: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
icon: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
to: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
href: {
|
||||
type: [String, Function],
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
// 包裹器标签
|
||||
const wrapperTag = computed(() => {
|
||||
if (props.to) return resolveComponent('NuxtLink');
|
||||
if (props.href) return 'a';
|
||||
return 'div';
|
||||
});
|
||||
|
||||
// 包裹器属性
|
||||
const wrapperProps = computed(() => {
|
||||
// Nuxt 内部跳转
|
||||
if (props.to) {
|
||||
return { to: props.to };
|
||||
}
|
||||
|
||||
// 外部跳转(字符串)
|
||||
if (typeof props.href === 'string') {
|
||||
return {
|
||||
href: props.href,
|
||||
target: '_blank',
|
||||
rel: 'noopener noreferrer',
|
||||
};
|
||||
}
|
||||
|
||||
// 其他情况:href 是异步函数 → 不在这里处理
|
||||
return { href: '#' };
|
||||
});
|
||||
|
||||
async function handleAsyncClick(event: Event) {
|
||||
if (typeof props.href === 'function') {
|
||||
event.preventDefault();
|
||||
const url = await props.href();
|
||||
window.open(url, '_blank', 'noopener,noreferrer');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.learn-more-card {
|
||||
width: 20%;
|
||||
min-width: 200px;
|
||||
padding: 20px;
|
||||
margin: 0 auto;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.learn-more-card:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.icon {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.learn-more-wrapper {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.learn-more-card {
|
||||
width: 80%;
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -210,6 +210,7 @@
|
||||
|
||||
.recommend-card .el-image {
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 10;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
|
||||
@ -210,6 +210,7 @@
|
||||
|
||||
.recommend-card .el-image {
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 10;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
|
||||
@ -1,16 +1,24 @@
|
||||
<template>
|
||||
<div class="product-detail">
|
||||
<el-tabs v-model="activeName" class="product-tabs" stretch>
|
||||
<el-tab-pane label="产品详情" name="details">
|
||||
<markdown-renderer :content="product.description || ''" />
|
||||
<el-tab-pane :label="$t('product-tab.details')" name="details">
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div class="html-typography" v-html="product?.description || ''" />
|
||||
<!-- <div v-if="!hydrated" v-html="product.description || ''" /> -->
|
||||
<!-- <div v-else> -->
|
||||
<!-- <html-renderer -->
|
||||
<!-- class="html-typography" -->
|
||||
<!-- :html="product.description || ''" -->
|
||||
<!-- /> -->
|
||||
<!-- </div> -->
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="技术规格" name="specs">
|
||||
<el-tab-pane :label="$t('product-tab.specs')" name="specs">
|
||||
<spec-table :data="product.specs" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="常见问题" name="faq">
|
||||
<el-tab-pane :label="$t('product-tab.faq')" name="faq">
|
||||
<question-list :questions="product.faqs" />
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="相关文档" name="documents">
|
||||
<el-tab-pane :label="$t('product-tab.documents')" name="documents">
|
||||
<document-list :documents="product.documents" />
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@ -25,7 +33,13 @@
|
||||
},
|
||||
});
|
||||
|
||||
const hydrated = ref(false);
|
||||
|
||||
const activeName = ref('details'); // 默认选中概览标签
|
||||
|
||||
onMounted(() => {
|
||||
hydrated.value = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -38,6 +38,10 @@
|
||||
<div class="product-info">
|
||||
<h1>{{ product.name }}</h1>
|
||||
<p class="summary">{{ product.summary }}</p>
|
||||
<p v-if="product.status === 'discontinued'" class="discontinued-warning">
|
||||
<el-icon><ElIconWarning /></el-icon>
|
||||
{{ $t('product-discontinued-warning') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@ -105,6 +109,10 @@
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.discontinued-warning {
|
||||
color: var(--el-color-error);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.product-header {
|
||||
grid-template-columns: 1fr;
|
||||
@ -117,6 +125,9 @@
|
||||
.product-image .el-image {
|
||||
height: 300px;
|
||||
}
|
||||
.product-info {
|
||||
padding: 0 1rem;
|
||||
}
|
||||
|
||||
.product-info h1 {
|
||||
font-size: 1.5rem;
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
<style scoped>
|
||||
.spec-collapse ::v-deep(.el-collapse-item__header) {
|
||||
font-size: 1rem;
|
||||
font-weight: 600;
|
||||
padding: 1rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
75
app/components/pages/search/SearchResultCard.vue
Normal file
75
app/components/pages/search/SearchResultCard.vue
Normal file
@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<el-card class="result-card">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<h3 class="result-title">{{ item.title }}</h3>
|
||||
<p v-if="item.summary" class="result-summary">
|
||||
{{ item.summary }}
|
||||
</p>
|
||||
<p v-if="item.sectionType" class="result-type">
|
||||
<span>{{ $t('search.section') }}: </span>
|
||||
<span class="result-type-name">{{ typeLabel }}</span>
|
||||
<span v-if="item.type" class="result-type-name"
|
||||
>({{ item.type }})</span
|
||||
>
|
||||
</p>
|
||||
</el-col>
|
||||
<el-col :span="12" class="image-col">
|
||||
<el-image
|
||||
v-if="item.thumbnail"
|
||||
:src="item.thumbnail"
|
||||
:alt="item.title"
|
||||
style="width: 150px"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
item: SearchItemView;
|
||||
typeLabel: string;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.result-card {
|
||||
border-radius: 12px;
|
||||
transition: box-shadow 0.2s ease;
|
||||
}
|
||||
|
||||
.result-card:hover {
|
||||
box-shadow: 0 12px 24px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.result-title {
|
||||
font-size: 1.2rem;
|
||||
font-weight: 600;
|
||||
color: var(--el-color-primary);
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.result-summary {
|
||||
font-size: 0.95rem;
|
||||
color: var(--el-text-color-regular);
|
||||
margin-bottom: 0.5rem;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.result-type {
|
||||
font-size: 0.8rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.result-type-name {
|
||||
margin-left: 4px;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.image-col {
|
||||
display: flex;
|
||||
justify-content: end;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
@ -3,19 +3,13 @@
|
||||
<div class="search-results">
|
||||
<NuxtLink
|
||||
v-for="hit in paginatedHits"
|
||||
:key="`${hit.type}-${hit.id}`"
|
||||
:key="`${hit.sectionType}-${hit.id}`"
|
||||
:to="localePath(resolveHitLink(hit))"
|
||||
>
|
||||
<el-card class="result-card">
|
||||
<h3 class="result-title">{{ hit.title }}</h3>
|
||||
<p v-if="hit.summary" class="result-summary">
|
||||
{{ hit.summary }}
|
||||
</p>
|
||||
<p v-if="hit.type" class="result-type">
|
||||
<span>内容类型: </span>
|
||||
<span class="result-type-name">{{ getIndexLabel(hit.type) }}</span>
|
||||
</p>
|
||||
</el-card>
|
||||
<search-result-card
|
||||
:item="hit"
|
||||
:type-label="getIndexLabel(hit.sectionType)"
|
||||
/>
|
||||
</NuxtLink>
|
||||
</div>
|
||||
|
||||
@ -72,7 +66,7 @@
|
||||
const items = props.searchItems;
|
||||
const filteredHits = computed(() => {
|
||||
if (props.category) {
|
||||
return items.filter((item) => item.type === props.category);
|
||||
return items.filter((item) => item.sectionType === props.category);
|
||||
} else {
|
||||
return items;
|
||||
}
|
||||
@ -116,19 +110,19 @@
|
||||
|
||||
const slug = String(slugCandidate);
|
||||
|
||||
if (item.type === 'product') {
|
||||
if (item.sectionType === 'product') {
|
||||
return localePath({ path: `/products/${slug}` });
|
||||
}
|
||||
|
||||
if (item.type === 'solution') {
|
||||
if (item.sectionType === 'solution') {
|
||||
return localePath({ path: `/solutions/${slug}` });
|
||||
}
|
||||
|
||||
if (item.type === 'document') {
|
||||
if (item.sectionType === 'document') {
|
||||
return localePath({ path: `/download/${slug}` });
|
||||
}
|
||||
|
||||
if (item.type === 'question') {
|
||||
if (item.sectionType === 'question') {
|
||||
return localePath({ path: `/support/faq`, query: { focus: slug } });
|
||||
}
|
||||
|
||||
|
||||
@ -22,17 +22,17 @@
|
||||
}>();
|
||||
|
||||
const tabs = [
|
||||
{ name: 'all', label: '全部' },
|
||||
{ name: 'product', label: '产品' },
|
||||
{ name: 'solution', label: '解决方案' },
|
||||
{ name: 'question', label: '相关问题' },
|
||||
{ name: 'document', label: '文档资料' },
|
||||
{ name: 'all', label: $t('all') },
|
||||
{ name: 'product', label: $t('search.sections.product') },
|
||||
{ name: 'solution', label: $t('search.sections.solution') },
|
||||
{ name: 'question', label: $t('search.sections.faq') },
|
||||
{ name: 'document', label: $t('search.sections.document') },
|
||||
];
|
||||
|
||||
const resultCount = computed(() => {
|
||||
const map: Record<string, number> = { all: props.searchItems.length };
|
||||
for (const item of props.searchItems) {
|
||||
map[item.type] = (map[item.type] ?? 0) + 1;
|
||||
map[item.sectionType] = (map[item.sectionType] ?? 0) + 1;
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
||||
@ -2,16 +2,15 @@
|
||||
<article class="solution-defail">
|
||||
<header class="solution-header">
|
||||
<h1 class="solution-title">{{ solution.title }}</h1>
|
||||
<dl class="solution-meta">
|
||||
<dt class="visually-hidden">CreatedAt:</dt>
|
||||
<dd class="solution-date">
|
||||
{{ new Date(solution.createAt).toLocaleDateString() }}
|
||||
</dd>
|
||||
</dl>
|
||||
<p class="solution-summary">{{ solution.summary }}</p>
|
||||
</header>
|
||||
<section class="solution-content">
|
||||
<markdown-renderer :content="solution?.content || ''" />
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div class="html-typography" v-html="solution?.content || ''" />
|
||||
<!-- <div v-if="!hydrated" v-html="solution?.content || ''" /> -->
|
||||
<!-- <div v-else> -->
|
||||
<!-- <html-renderer class="html-typography" :html="solution.content || ''" /> -->
|
||||
<!-- </div> -->
|
||||
</section>
|
||||
</article>
|
||||
</template>
|
||||
@ -23,6 +22,12 @@
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
const hydrated = ref(false);
|
||||
|
||||
onMounted(() => {
|
||||
hydrated.value = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
113
app/components/pages/support/DocumentFilter.vue
Normal file
113
app/components/pages/support/DocumentFilter.vue
Normal file
@ -0,0 +1,113 @@
|
||||
<template>
|
||||
<div class="document-category">
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="12" :xs="12">
|
||||
<span class="select-label">{{
|
||||
$t('product-filter.product-type')
|
||||
}}</span>
|
||||
<el-select
|
||||
v-model="model.selectedProductType"
|
||||
:placeholder="$t('product-filter.select-product-type')"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="type in productTypeOptions"
|
||||
:key="type.id"
|
||||
:label="type.name"
|
||||
:value="type.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" :xs="12">
|
||||
<span class="select-label">{{
|
||||
$t('product-filter.product-model')
|
||||
}}</span>
|
||||
<el-select
|
||||
v-model="model.selectedProduct"
|
||||
:placeholder="$t('product-filter.select-product-model')"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="product in productOptions"
|
||||
:key="product.id"
|
||||
:label="product.name"
|
||||
:value="product.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" :xs="24">
|
||||
<span class="select-label">
|
||||
{{ $t('product-filter.document-type') }}
|
||||
</span>
|
||||
<el-select
|
||||
v-model="model.selectedDocumentType"
|
||||
:placeholder="$t('product-filter.select-document-type')"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="questionType in documentTypeOptions"
|
||||
:key="questionType.id"
|
||||
:label="questionType.name"
|
||||
:value="questionType.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12" :xs="24">
|
||||
<span class="select-label">{{ $t('product-filter.keyword') }}</span>
|
||||
<el-input
|
||||
v-model="model.keyword"
|
||||
:placeholder="$t('product-filter.enter-keyword')"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Search } from '@element-plus/icons-vue';
|
||||
|
||||
defineProps({
|
||||
productTypeOptions: {
|
||||
type: Array as () => Array<DocumentListProductType>,
|
||||
default: () => [],
|
||||
},
|
||||
productOptions: {
|
||||
type: Array as () => Array<DocumentListProduct>,
|
||||
default: () => [],
|
||||
},
|
||||
documentTypeOptions: {
|
||||
type: Array as () => Array<DocumentTypeView>,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const model = defineModel<{
|
||||
selectedProduct: string | null;
|
||||
selectedProductType: string | null;
|
||||
selectedDocumentType: string | null;
|
||||
keyword: string;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.document-category {
|
||||
margin-bottom: 1rem;
|
||||
padding: 0 0;
|
||||
}
|
||||
|
||||
.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>
|
||||
@ -1,12 +1,12 @@
|
||||
<template>
|
||||
<div class="question-category">
|
||||
<el-row class="hide-on-mobile" :gutter="12">
|
||||
<el-col :span="8">
|
||||
<el-row :gutter="12">
|
||||
<el-col :span="12" :xs="12">
|
||||
<span class="select-label">{{
|
||||
$t('product-filter.product-type')
|
||||
}}</span>
|
||||
<el-select
|
||||
v-model="model.selectedType"
|
||||
v-model="model.selectedProductType"
|
||||
:placeholder="$t('product-filter.select-product-type')"
|
||||
clearable
|
||||
>
|
||||
@ -19,7 +19,7 @@
|
||||
</el-select>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="8">
|
||||
<el-col :span="12" :xs="12">
|
||||
<span class="select-label">{{
|
||||
$t('product-filter.product-model')
|
||||
}}</span>
|
||||
@ -37,54 +37,25 @@
|
||||
</el-select>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="8">
|
||||
<span class="select-label">{{ $t('product-filter.keyword') }}</span>
|
||||
<el-input
|
||||
v-model="model.keyword"
|
||||
:placeholder="$t('product-filter.enter-keyword')"
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="display-on-mobile" :gutter="12">
|
||||
<el-col :span="12">
|
||||
<span class="select-label">{{
|
||||
$t('product-filter.product-type')
|
||||
}}</span>
|
||||
<el-col :span="12" :xs="24">
|
||||
<span class="select-label">
|
||||
{{ $t('product-filter.question-type') }}
|
||||
</span>
|
||||
<el-select
|
||||
v-model="model.selectedType"
|
||||
:placeholder="$t('product-filter.select-product-type')"
|
||||
v-model="model.selectedQuestionType"
|
||||
:placeholder="$t('product-filter.select-question-type')"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="type in productTypeOptions"
|
||||
:key="type.id"
|
||||
:label="type.name"
|
||||
:value="type.id"
|
||||
v-for="questionType in questionTypeOptions"
|
||||
:key="questionType.id"
|
||||
:label="questionType.name"
|
||||
:value="questionType.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12">
|
||||
<span class="select-label">{{
|
||||
$t('product-filter.product-model')
|
||||
}}</span>
|
||||
<el-select
|
||||
v-model="model.selectedProduct"
|
||||
:placeholder="$t('product-filter.select-product-model')"
|
||||
clearable
|
||||
>
|
||||
<el-option
|
||||
v-for="product in productOptions"
|
||||
:key="product.id"
|
||||
:label="product.name"
|
||||
:value="product.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row class="display-on-mobile">
|
||||
<el-col :span="12" :xs="24">
|
||||
<span class="select-label">{{ $t('product-filter.keyword') }}</span>
|
||||
<el-input
|
||||
v-model="model.keyword"
|
||||
@ -92,6 +63,7 @@
|
||||
clearable
|
||||
:prefix-icon="Search"
|
||||
/>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</div>
|
||||
</template>
|
||||
@ -101,19 +73,24 @@
|
||||
|
||||
defineProps({
|
||||
productTypeOptions: {
|
||||
type: Array as () => Array<{ id: number; name: string }>,
|
||||
type: Array as () => Array<QuestionListProductType>,
|
||||
default: () => [],
|
||||
},
|
||||
productOptions: {
|
||||
type: Array as () => Array<{ id: number; name: string }>,
|
||||
type: Array as () => Array<QuestionListProduct>,
|
||||
default: () => [],
|
||||
},
|
||||
questionTypeOptions: {
|
||||
type: Array as () => Array<QuestionTypeView>,
|
||||
default: () => [],
|
||||
},
|
||||
});
|
||||
|
||||
const model = defineModel<{
|
||||
selectedProduct: string | null;
|
||||
selectedProductType: string | null;
|
||||
selectedQuestionType: string | null;
|
||||
keyword: string;
|
||||
selectedType: number | null;
|
||||
selectedProduct: number | null;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
@ -132,18 +109,4 @@
|
||||
height: 40px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.display-on-mobile {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.hide-on-mobile {
|
||||
display: none;
|
||||
}
|
||||
.display-on-mobile {
|
||||
display: flex;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -7,7 +7,17 @@
|
||||
@click="handleClick(doc.fileId)"
|
||||
>
|
||||
<div class="document-info">
|
||||
<h3>{{ doc.title }}</h3>
|
||||
<div class="document-title">
|
||||
<h3>
|
||||
{{ doc.title }}
|
||||
<span v-if="showCategory && doc.type" class="document-category">
|
||||
|
|
||||
</span>
|
||||
<span v-if="showCategory && doc.type" class="document-category">
|
||||
{{ doc.type.name }}
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="document-content">
|
||||
<span v-if="doc.size" class="document-meta"
|
||||
>{{ $t('document-meta.size') }}: {{ formatFileSize(doc.size) }}
|
||||
@ -28,6 +38,10 @@
|
||||
type: Array as () => Array<ProductDocumentView>,
|
||||
default: () => [],
|
||||
},
|
||||
showCategory: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
});
|
||||
|
||||
const localePath = useLocalePath();
|
||||
@ -63,6 +77,15 @@
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.document-title {
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.document-category {
|
||||
font-size: 0.75rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.download-button {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
@ -122,6 +122,8 @@
|
||||
const errorText = computed(() => error.value?.message ?? null);
|
||||
const fileMeta = computed(() => props.file ?? data.value ?? null);
|
||||
|
||||
logger.debug('FilePreviewer - fileMeta:', fileMeta.value);
|
||||
|
||||
/** 预览源地址:支持在 file.url 上追加额外 query(如临时 token、inline) */
|
||||
const src = computed<string>(() => {
|
||||
if (!fileMeta.value) return '';
|
||||
|
||||
30
app/components/shared/HtmlRenderer.ts
Normal file
30
app/components/shared/HtmlRenderer.ts
Normal file
@ -0,0 +1,30 @@
|
||||
export default defineComponent({
|
||||
name: 'HtmlRenderer',
|
||||
|
||||
props: {
|
||||
html: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
map: {
|
||||
type: Object as () => HtmlRenderMap,
|
||||
default: () => defaultHtmlRenderMap,
|
||||
},
|
||||
allowUnknown: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
},
|
||||
|
||||
setup(props, { attrs }) {
|
||||
const nodes: VNode[] = useHtmlRenderer(props.html, {
|
||||
map: props.map,
|
||||
allowUnknownTags: props.allowUnknown,
|
||||
});
|
||||
|
||||
logger.debug('nodes: ', nodes);
|
||||
|
||||
// 渲染函数:直接返回 VNode 数组
|
||||
return () => h('div', { ...attrs }, nodes);
|
||||
},
|
||||
});
|
||||
@ -48,7 +48,7 @@
|
||||
<ul class="footer-links">
|
||||
<li>
|
||||
<a
|
||||
href="http://cal.jinshen.cn"
|
||||
href="http://cal.3w.jinshen.cn"
|
||||
target="_blank"
|
||||
rel="noopener noreferer"
|
||||
>
|
||||
@ -84,7 +84,12 @@
|
||||
© {{ currentYear }} {{ $t('company-name') }}.
|
||||
{{ $t('all-rights-reserved') }}
|
||||
</p>
|
||||
<p>备案号: 浙ICP备12003709号-5</p>
|
||||
<p>
|
||||
备案号:
|
||||
<a href="https://beian.miit.gov.cn/" target="_blank"
|
||||
>浙ICP备12003709号-5</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
<!-- <div class="footer-links-bottom"> -->
|
||||
<!-- <NuxtLink :to="$localePath('/privacy')">{{ -->
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
class="hide-on-mobile"
|
||||
type="info"
|
||||
:underline="false"
|
||||
href="http://cal.jinshen.cn"
|
||||
href="http://cal.3w.jinshen.cn"
|
||||
target="_blank"
|
||||
>
|
||||
<el-icon class="mdi mdi-calculator action-icon" />
|
||||
@ -67,6 +67,12 @@
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="zh">简体中文</el-dropdown-item>
|
||||
<el-dropdown-item command="en">English</el-dropdown-item>
|
||||
<el-dropdown-item command="es"
|
||||
>Español(Machine Translate)</el-dropdown-item
|
||||
>
|
||||
<el-dropdown-item command="ru"
|
||||
>Русский(Machine Translate)</el-dropdown-item
|
||||
>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
@ -125,7 +131,9 @@
|
||||
mode="vertical"
|
||||
@select="mobileMenuVisible = false"
|
||||
>
|
||||
<el-menu-item @click="openExternalLink('http://cal.jinshen.cn')">
|
||||
<el-menu-item
|
||||
@click="openExternalLink('http://cal.3w.jinshen.cn')"
|
||||
>
|
||||
{{ $t('navigation.calculator') }}
|
||||
</el-menu-item>
|
||||
</el-menu>
|
||||
@ -140,6 +148,12 @@
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item command="zh">简体中文</el-dropdown-item>
|
||||
<el-dropdown-item command="en">English</el-dropdown-item>
|
||||
<el-dropdown-item command="es"
|
||||
>Español(Machine Translate)</el-dropdown-item
|
||||
>
|
||||
<el-dropdown-item command="ru"
|
||||
>Русский(Machine Translate)</el-dropdown-item
|
||||
>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
|
||||
@ -13,22 +13,17 @@
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const contentWithAbsoluteUrls = convertMedia(props.content);
|
||||
|
||||
// 将 Markdown 转换成 HTML
|
||||
const safeHtml = computed(() => renderMarkdown(contentWithAbsoluteUrls));
|
||||
// const safeHtml = computed(() => renderMarkdown(props.content))
|
||||
const safeHtml = computed(() => renderMarkdown(props.content));
|
||||
|
||||
const container = ref<HTMLElement | null>(null);
|
||||
|
||||
onMounted(async () => {
|
||||
await nextTick();
|
||||
if (!safeHtml.value) return;
|
||||
console.log(safeHtml.value);
|
||||
|
||||
// 查找所有 table
|
||||
const tables = container.value.querySelectorAll('table');
|
||||
console.log(tables);
|
||||
tables.forEach((table) => {
|
||||
// 1. 提取表头
|
||||
const headers = Array.from(table.querySelectorAll('thead th')).map(
|
||||
@ -55,8 +50,6 @@
|
||||
app.mount(mountPoint);
|
||||
});
|
||||
});
|
||||
|
||||
// console.log('Rendered HTML:', safeHtml.value);
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
@ -61,7 +61,8 @@
|
||||
}
|
||||
|
||||
.product-card .el-image {
|
||||
height: 150px;
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 10;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,15 @@
|
||||
:title="question.title"
|
||||
:name="question.id"
|
||||
>
|
||||
<markdown-renderer :content="question.content || ''" />
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div class="html-typography" v-html="question.content || ''" />
|
||||
<!-- <div v-if="!hydrated" v-html="question.content" /> -->
|
||||
<!-- <div v-else> -->
|
||||
<!-- <html-renderer -->
|
||||
<!-- class="html-typography" -->
|
||||
<!-- :html="question.content || ''" -->
|
||||
<!-- /> -->
|
||||
<!-- </div> -->
|
||||
</el-collapse-item>
|
||||
</el-collapse>
|
||||
</div>
|
||||
@ -25,6 +33,8 @@
|
||||
|
||||
const activeNames = ref<(string | number)[]>([]);
|
||||
|
||||
const hydrated = ref(false);
|
||||
|
||||
// 当路由变化(包括初次挂载)时,检查是否需要聚焦
|
||||
watch(
|
||||
() => route.query.focus,
|
||||
@ -35,7 +45,7 @@
|
||||
// 确保渲染完成后再操作 DOM
|
||||
await nextTick();
|
||||
|
||||
const target = props.questions.find((q) => q.id === Number(focusId));
|
||||
const target = props.questions.find((q) => q.id === focusId);
|
||||
if (!target) return;
|
||||
|
||||
// 展开目标项
|
||||
@ -47,6 +57,10 @@
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
onMounted(() => {
|
||||
hydrated.value = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -67,7 +67,8 @@
|
||||
}
|
||||
|
||||
.solution-card .el-image {
|
||||
height: 250px;
|
||||
width: 100%;
|
||||
aspect-ratio: 16 / 10;
|
||||
}
|
||||
|
||||
@media (max-width: 1200px) {
|
||||
|
||||
@ -1,29 +1,17 @@
|
||||
import { readSingleton } from '@directus/sdk';
|
||||
|
||||
export const useCompanyProfile = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`company-profile-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readSingleton('company_profile', {
|
||||
fields: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'content'],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: {
|
||||
_eq: locale,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = await $fetch(`/api/cms/companyProfile`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching company profile: ', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,29 +1,17 @@
|
||||
import { readSingleton } from '@directus/sdk';
|
||||
|
||||
export const useContactInfo = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`contact-info-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readSingleton('contact_info', {
|
||||
fields: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'content'],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: {
|
||||
_eq: locale,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = await $fetch('/api/cms/contactInfo', {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching contact info: ', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,19 +1,14 @@
|
||||
export const useDirectusFiles = () => {
|
||||
const config = useRuntimeConfig();
|
||||
const baseUrl = config.public.directus.url;
|
||||
|
||||
const getFileUrl = (
|
||||
id?: string | null,
|
||||
options?: Record<string, string | number | boolean>
|
||||
): string => {
|
||||
if (!id) return '';
|
||||
const query = options
|
||||
? '?' +
|
||||
new URLSearchParams(
|
||||
Object.entries(options).map(([key, value]) => [key, String(value)])
|
||||
).toString()
|
||||
: '';
|
||||
return `${baseUrl}/assets/${id}${query}`;
|
||||
|
||||
const params = new URLSearchParams(
|
||||
options as Record<string, string>
|
||||
).toString();
|
||||
return `/api/assets/${id}${params ? `?${params}` : ''}`;
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@ -1,8 +1,4 @@
|
||||
export const useDirectusImage = () => {
|
||||
const config = useRuntimeConfig();
|
||||
const baseUrl = config.public.directus.url;
|
||||
const token = config.public.directus.token;
|
||||
|
||||
type DirectusAssetParams = {
|
||||
width?: number;
|
||||
height?: number;
|
||||
@ -13,19 +9,11 @@ export const useDirectusImage = () => {
|
||||
|
||||
const getImageUrl = (id?: string | null, options?: DirectusAssetParams) => {
|
||||
if (!id) return '';
|
||||
const queryToken = token ? 'access_token=' + token : '';
|
||||
const queryOptions = options
|
||||
? new URLSearchParams(
|
||||
Object.fromEntries(
|
||||
Object.entries(options).map(([key, value]) => [key, String(value)])
|
||||
)
|
||||
).toString
|
||||
: '';
|
||||
const query =
|
||||
queryToken || queryOptions
|
||||
? `?${[queryToken, queryOptions].filter(Boolean).join('&')}`
|
||||
: '';
|
||||
return `${baseUrl}/assets/${id}${query}`;
|
||||
|
||||
const params = new URLSearchParams(
|
||||
options as Record<string, string>
|
||||
).toString();
|
||||
return `/api/assets/${id}${params ? `?${params}` : ''}`;
|
||||
};
|
||||
|
||||
return { getImageUrl };
|
||||
|
||||
@ -1,67 +1,17 @@
|
||||
import { readItems } from '@directus/sdk';
|
||||
|
||||
export const useDocumentList = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`document-list-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readItems('product_documents', {
|
||||
fields: [
|
||||
'id',
|
||||
{
|
||||
file: ['id', 'filesize', 'filename_download'],
|
||||
},
|
||||
{
|
||||
translations: ['id', 'title'],
|
||||
},
|
||||
{
|
||||
products: [
|
||||
'id',
|
||||
{
|
||||
products_id: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'name'],
|
||||
},
|
||||
{
|
||||
product_type: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'name'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
products: {
|
||||
products_id: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
product_type: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = $fetch(`/api/cms/documentList`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching document list:', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,54 +1,17 @@
|
||||
import { readSingleton } from '@directus/sdk';
|
||||
|
||||
export const useHomepage = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`homepage-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readSingleton('homepage', {
|
||||
fields: [
|
||||
'id',
|
||||
{
|
||||
carousel: ['id', 'directus_files_id'],
|
||||
},
|
||||
{
|
||||
recommend_products: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'name', 'summary'],
|
||||
},
|
||||
'cover',
|
||||
],
|
||||
},
|
||||
{
|
||||
recommend_solutions: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'title', 'summary'],
|
||||
},
|
||||
'cover',
|
||||
],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
recommend_products: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
recommend_solutions: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = $fetch(`/api/cms/homepage`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching homepage:', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,110 +1,17 @@
|
||||
import { readItem } from '@directus/sdk';
|
||||
|
||||
export const useProduct = (id: string) => {
|
||||
const { $directus } = useNuxtApp();
|
||||
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`product-${id}-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readItem('products', id, {
|
||||
fields: [
|
||||
'id',
|
||||
{ translations: ['id', 'name', 'summary', 'description'] },
|
||||
{
|
||||
images: [
|
||||
'id',
|
||||
{
|
||||
product_images_id: [
|
||||
'id',
|
||||
'image',
|
||||
{ translations: ['id', 'caption'] },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
specs: [
|
||||
'id',
|
||||
{
|
||||
translations: ['*'],
|
||||
},
|
||||
{
|
||||
specs: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'key', 'value'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
faqs: [
|
||||
'id',
|
||||
{
|
||||
questions_id: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'title', 'content'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
documents: [
|
||||
'id',
|
||||
{
|
||||
product_documents_id: [
|
||||
'id',
|
||||
{
|
||||
file: ['id', 'filesize', 'filename_download'],
|
||||
},
|
||||
{
|
||||
translations: ['id', 'title'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
images: {
|
||||
product_images_id: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
faqs: {
|
||||
questions_id: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
documents: {
|
||||
documents_id: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = await $fetch(`/api/cms/product/${id}`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching product: ', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,42 +1,17 @@
|
||||
import { readItems } from '@directus/sdk';
|
||||
|
||||
export const useProductList = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`product-list-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readItems('products', {
|
||||
fields: [
|
||||
'id',
|
||||
{ translations: ['id', 'name', 'summary'] },
|
||||
'cover',
|
||||
{
|
||||
product_type: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'name'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
product_type: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = await $fetch(`/api/cms/productList`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching product list: ', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,63 +1,17 @@
|
||||
import { readItems } from '@directus/sdk';
|
||||
|
||||
export const useQuestionList = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`question-list-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readItems('questions', {
|
||||
fields: [
|
||||
'id',
|
||||
{
|
||||
translations: ['*'],
|
||||
},
|
||||
{
|
||||
products: [
|
||||
'id',
|
||||
{
|
||||
products_id: [
|
||||
'id',
|
||||
{
|
||||
product_type: [
|
||||
'id',
|
||||
{
|
||||
translations: ['id', 'name'],
|
||||
},
|
||||
],
|
||||
},
|
||||
{ translations: ['id', 'name'] },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
products: {
|
||||
products_id: {
|
||||
product_type: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = $fetch(`/api/cms/questionList`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching question list:', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,28 +1,17 @@
|
||||
import { readItem } from '@directus/sdk';
|
||||
|
||||
export const useSolution = (id: string) => {
|
||||
const { $directus } = useNuxtApp();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`solution-${id}-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readItem('solutions', id, {
|
||||
fields: [
|
||||
'id',
|
||||
{
|
||||
translations: ['*'],
|
||||
},
|
||||
'create_at',
|
||||
],
|
||||
deep: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = await $fetch(`/api/cms/solution/${id}`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching solution: ', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,38 +1,17 @@
|
||||
import { readItems } from '@directus/sdk';
|
||||
|
||||
export const useSolutionList = () => {
|
||||
const { $directus } = useNuxtApp();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
return useAsyncData(`solution-list-${locale}`, async () => {
|
||||
return await $directus.request(
|
||||
readItems('solutions', {
|
||||
fields: [
|
||||
'id',
|
||||
'cover',
|
||||
{
|
||||
type: ['id', { translations: ['id', 'name'] }],
|
||||
},
|
||||
{
|
||||
translations: ['id', 'title', 'summary'],
|
||||
},
|
||||
],
|
||||
deep: {
|
||||
type: {
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
translations: {
|
||||
_filter: {
|
||||
languages_code: { _eq: locale },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
);
|
||||
try {
|
||||
const data = $fetch(`/api/cms/solutionList`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching solution list:', error);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,3 +1,2 @@
|
||||
export * from './directus';
|
||||
export * from './useLocalizations';
|
||||
export * from './useMeilisearch';
|
||||
|
||||
80
app/composables/useHtmlRenderer.ts
Normal file
80
app/composables/useHtmlRenderer.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import { h, type VNode } from 'vue';
|
||||
import { parseDocument } from 'htmlparser2';
|
||||
import type { Element, Text, Node } from 'domhandler';
|
||||
|
||||
/** 标签映射的类型:key=标签名,value=渲染函数 */
|
||||
export type HtmlRenderMap = Record<
|
||||
string,
|
||||
(node: Element, children: VNode[]) => VNode
|
||||
>;
|
||||
|
||||
export interface HtmlRenderOptions {
|
||||
/** 自定义标签渲染映射 */
|
||||
map?: HtmlRenderMap;
|
||||
|
||||
/** 默认是否将未知标签渲染为原生标签(默认 true) */
|
||||
allowUnknownTags?: boolean;
|
||||
}
|
||||
|
||||
export const useHtmlRenderer = (
|
||||
html: string,
|
||||
options: HtmlRenderOptions = {}
|
||||
) => {
|
||||
const { map = {}, allowUnknownTags = true } = options;
|
||||
|
||||
const doc = parseDocument(html);
|
||||
|
||||
function render(node: Node): VNode | string | null {
|
||||
// 文本节点
|
||||
if (node.type === 'text') {
|
||||
const textNode = node as Text;
|
||||
const content = textNode.data;
|
||||
|
||||
// ❗忽略"纯空白" 文本(换行、空格)
|
||||
if (!content || /^\s+$/.test(content)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
// 标签节点
|
||||
if (node.type === 'tag') {
|
||||
const elem = node as Element;
|
||||
const rawName = elem.name ?? '';
|
||||
const name = rawName.trim().toLowerCase();
|
||||
|
||||
// 标签名有效性校验
|
||||
const isValidTag = /^[a-zA-Z][a-zA-Z0-9-]*$/.test(name);
|
||||
if (!isValidTag) {
|
||||
logger.warn(`Invalid tag name ignored: "${rawName}"`);
|
||||
return null;
|
||||
}
|
||||
|
||||
const children: VNode[] = (elem.children || [])
|
||||
.map((child) => render(child))
|
||||
.filter(Boolean) as VNode[];
|
||||
|
||||
// 自定义映射
|
||||
if (map[name]) {
|
||||
return map[name](elem, children);
|
||||
}
|
||||
|
||||
// 默认将未知标签渲染为原生标签
|
||||
if (allowUnknownTags) {
|
||||
return h(name, elem.attribs || {}, children);
|
||||
}
|
||||
|
||||
// 忽略无法渲染节点
|
||||
return null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
const nodes = doc.children
|
||||
.map((child) => render(child))
|
||||
.filter(Boolean) as VNode[];
|
||||
|
||||
return nodes;
|
||||
};
|
||||
@ -1,15 +1,14 @@
|
||||
import type { StrapiLocale } from '@nuxtjs/strapi';
|
||||
import type { Language as ElementLanguage } from 'element-plus/es/locale';
|
||||
import zhCn from 'element-plus/es/locale/lang/zh-cn';
|
||||
import en from 'element-plus/es/locale/lang/en';
|
||||
import es from 'element-plus/es/locale/lang/es';
|
||||
import ru from 'element-plus/es/locale/lang/ru';
|
||||
|
||||
/**
|
||||
* 应用语言映射结构
|
||||
* 用于统一 Strapi / Directus / Element Plus 的多语言配置
|
||||
*/
|
||||
export interface LocaleMapping {
|
||||
/** 用于StrapiLocale **/
|
||||
strapi: StrapiLocale;
|
||||
/** 用于Directus translations.languages_code **/
|
||||
directus: string;
|
||||
/** Element Plus语言对象 **/
|
||||
@ -24,15 +23,21 @@ export interface LocaleMapping {
|
||||
*/
|
||||
export const localeMap = {
|
||||
zh: {
|
||||
strapi: 'zh-CN',
|
||||
directus: 'zh-CN',
|
||||
element: zhCn,
|
||||
},
|
||||
en: {
|
||||
strapi: 'en',
|
||||
directus: 'en-US',
|
||||
element: en,
|
||||
},
|
||||
es: {
|
||||
directus: 'es-ES',
|
||||
element: es,
|
||||
},
|
||||
ru: {
|
||||
directus: 'ru-RU',
|
||||
element: ru,
|
||||
},
|
||||
} satisfies Record<string, LocaleMapping>;
|
||||
|
||||
/** 应用支持的语言键类型 **/
|
||||
@ -74,8 +79,6 @@ export const useLocalizations = () => {
|
||||
return {
|
||||
/** 当前Nuxt I18n语言(只读) **/
|
||||
locale: readonly(locale),
|
||||
/** 获取Strapi的本地化代码 **/
|
||||
getStrapiLocale: (l?: AppLocale) => getMapping(l).strapi,
|
||||
/** 获取Directus的本地化代码 **/
|
||||
getDirectusLocale: (l?: AppLocale) => getMapping(l).directus,
|
||||
/** 获取Element Plus语言对象 **/
|
||||
|
||||
@ -1,137 +0,0 @@
|
||||
import { MeiliSearch } from 'meilisearch';
|
||||
import type { SearchParams } from 'meilisearch';
|
||||
|
||||
const parseIndexes = (
|
||||
indexes: string | string[] | undefined,
|
||||
locale?: string
|
||||
): string[] => {
|
||||
if (!indexes) {
|
||||
return [];
|
||||
}
|
||||
|
||||
let suffix = '';
|
||||
if (locale) {
|
||||
suffix = `_${locale}`;
|
||||
}
|
||||
|
||||
if (Array.isArray(indexes)) {
|
||||
return indexes.map((item) => `${item.trim()}${suffix}`).filter(Boolean);
|
||||
}
|
||||
return indexes
|
||||
.split(',')
|
||||
.map((item) => `${item.trim()}${suffix}`)
|
||||
.filter(Boolean);
|
||||
};
|
||||
|
||||
export const useMeilisearch = () => {
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
|
||||
const indexes = computed(() =>
|
||||
parseIndexes(runtimeConfig.public?.meili?.indexes)
|
||||
);
|
||||
|
||||
let meiliClient: MeiliSearch | null = null;
|
||||
|
||||
const ensureClient = () => {
|
||||
if (meiliClient) return meiliClient;
|
||||
|
||||
const host = runtimeConfig.public?.meili?.host;
|
||||
if (!host) {
|
||||
console.warn('Meilisearch host is not configured.');
|
||||
return null;
|
||||
}
|
||||
const apiKey = runtimeConfig.public?.meili?.searchKey;
|
||||
meiliClient = new MeiliSearch({
|
||||
host,
|
||||
apiKey: apiKey || undefined,
|
||||
});
|
||||
return meiliClient;
|
||||
};
|
||||
|
||||
/**
|
||||
* 泛型搜索函数
|
||||
* @template T 文档类型, 如 MeiliProductIndex
|
||||
* ---
|
||||
* @param query 搜索关键词
|
||||
* @param params 其他搜索参数
|
||||
* @returns 搜索结果数组
|
||||
*/
|
||||
async function search<
|
||||
K extends MeiliSearchItemType = MeiliSearchItemType,
|
||||
T extends MeiliIndexMap[K] = MeiliIndexMap[K],
|
||||
>(
|
||||
query: string,
|
||||
params: SearchParams = {},
|
||||
searchLocale?: string
|
||||
): Promise<SearchSection<T>[]> {
|
||||
const trimmedQuery = query.trim();
|
||||
if (!trimmedQuery) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const client = ensureClient();
|
||||
if (!client) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const activeIndexes = indexes.value as K[];
|
||||
if (!activeIndexes.length) {
|
||||
console.warn('No Meilisearch indexes configured.');
|
||||
return [];
|
||||
}
|
||||
const rawIndexMap = Object.fromEntries(
|
||||
activeIndexes.map((index) => [`${index}_${searchLocale}`, index])
|
||||
);
|
||||
const indexesWithLocale = activeIndexes.map(
|
||||
(index) => index + (searchLocale ? `_${searchLocale}` : '')
|
||||
);
|
||||
|
||||
console.log(indexesWithLocale);
|
||||
|
||||
const requests = indexesWithLocale.map(async (indexUid) => {
|
||||
const response = await client.index(indexUid).search<T>(trimmedQuery, {
|
||||
limit: params.limit ?? 10,
|
||||
...params,
|
||||
});
|
||||
return {
|
||||
indexUid,
|
||||
response,
|
||||
} satisfies RawSearchSection<T>;
|
||||
});
|
||||
|
||||
const settled = await Promise.allSettled(requests);
|
||||
|
||||
console.log('Meilisearch settled results:', settled);
|
||||
|
||||
settled
|
||||
.filter(
|
||||
(result): result is PromiseRejectedResult =>
|
||||
result.status === 'rejected'
|
||||
)
|
||||
.forEach((result) => {
|
||||
console.error('Meilisearch query failed', result.reason);
|
||||
});
|
||||
|
||||
return settled
|
||||
.filter(
|
||||
(result): result is PromiseFulfilledResult<RawSearchSection<T>> =>
|
||||
result.status === 'fulfilled'
|
||||
)
|
||||
.map((result) => {
|
||||
const { indexUid, response } = result.value;
|
||||
return {
|
||||
indexUid: indexUid,
|
||||
rawIndex: rawIndexMap[indexUid],
|
||||
hits: response.hits,
|
||||
estimatedTotalHits:
|
||||
response.estimatedTotalHits ?? response.hits.length,
|
||||
processingTimeMs: response.processingTimeMs ?? 0,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
search,
|
||||
indexes,
|
||||
};
|
||||
};
|
||||
47
app/composables/usePageSeo.ts
Normal file
47
app/composables/usePageSeo.ts
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* 设置页面级 SEO 元数据(包含 title、description、OG/Twitter 等常用字段)。
|
||||
*
|
||||
* 该函数基于 `useSeoMeta` 封装,可用于 Nuxt 3 / Nuxt 4
|
||||
* 配合 SSR/CSR 动态更新,可安全用于异步数据场景(如 CMS 内容页)。
|
||||
*
|
||||
* @param {Object} meta - 页面 SEO 配置对象
|
||||
* @param {string} meta.title - 页面标题(会同时应用到 title / og:title)
|
||||
* @param {string} [meta.description] - 页面描述(会应用到 description / og:description)
|
||||
* @param {string} [meta.image] - 用于分享卡片的预览图(og:image / twitter:image)
|
||||
*
|
||||
* @example
|
||||
* // 用于普通页面
|
||||
* usePageSeo({
|
||||
* title: '产品中心 - 金申机械',
|
||||
* description: '查看全系列纸管机械产品',
|
||||
* image: '/images/og/products.png'
|
||||
* })
|
||||
*
|
||||
* @example
|
||||
* // 用于动态内容(如产品详情页)
|
||||
* const product = await fetchProduct()
|
||||
* usePageSeo({
|
||||
* title: product.name,
|
||||
* description: product.summary,
|
||||
* image: product.coverImage
|
||||
* })
|
||||
*
|
||||
* @remarks
|
||||
* - 自动生成以下 meta:`title`, `description`, `og:title`, `og:description`, `og:image`, `twitter:card`
|
||||
* - 默认使用 `summary_large_image` 作为 Twitter 卡片类型
|
||||
* - 推荐与 `useHead()` 配合增加 canonical / alternate hreflang 等额外 SEO 标签
|
||||
*/
|
||||
export function usePageSeo(meta: {
|
||||
title: string;
|
||||
description?: string;
|
||||
image?: string;
|
||||
}) {
|
||||
useSeoMeta({
|
||||
title: meta.title,
|
||||
ogTitle: meta.title,
|
||||
description: meta.description,
|
||||
ogDescription: meta.description,
|
||||
ogImage: meta.image,
|
||||
twitterCard: 'summary_large_image',
|
||||
});
|
||||
}
|
||||
@ -12,6 +12,17 @@
|
||||
</el-container>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { t } = useI18n();
|
||||
|
||||
useHead(() => {
|
||||
const siteTitle = t('company-name');
|
||||
return {
|
||||
titleTemplate: (title) => (title ? `${title} - ${siteTitle}` : siteTitle),
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.app-container {
|
||||
display: flex;
|
||||
|
||||
@ -3,3 +3,14 @@
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { t } = useI18n();
|
||||
|
||||
useHead(() => {
|
||||
const siteTitle = `${$t('page-title.preview')} - ${t('company-name')}`;
|
||||
return {
|
||||
title: siteTitle,
|
||||
};
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,106 +0,0 @@
|
||||
import { describe, test, expect } from 'vitest';
|
||||
|
||||
/**
|
||||
* 单元测试: toProductDocumentView
|
||||
*/
|
||||
describe('toProductDocumentView', () => {
|
||||
test('convert raw data with fileId to ProductDocumentView correctly', () => {
|
||||
const rawData: ProductDocument = {
|
||||
id: 1,
|
||||
file: 'rand-om__-uuid-1234',
|
||||
translations: [{ id: 10, title: 'Document Title' }],
|
||||
};
|
||||
|
||||
expect(toProductDocumentView(rawData)).toEqual({
|
||||
id: 1,
|
||||
fileId: 'rand-om__-uuid-1234',
|
||||
filename: undefined,
|
||||
title: 'Document Title',
|
||||
url: 'http://localhost:8055/assets/rand-om__-uuid-1234',
|
||||
size: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with fileMeta to ProductDocumentView correctly', () => {
|
||||
const rawData: ProductDocument = {
|
||||
id: 1,
|
||||
file: {
|
||||
id: 'rand-om__-uuid-1234',
|
||||
filename_download: 'document.pdf',
|
||||
filesize: 2048,
|
||||
},
|
||||
translations: [{ id: 10, title: 'Document Title' }],
|
||||
};
|
||||
|
||||
expect(toProductDocumentView(rawData)).toEqual({
|
||||
id: 1,
|
||||
fileId: 'rand-om__-uuid-1234',
|
||||
filename: 'document.pdf',
|
||||
title: 'Document Title',
|
||||
url: 'http://localhost:8055/assets/rand-om__-uuid-1234',
|
||||
size: 2048,
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: ProductDocument = {
|
||||
id: 1,
|
||||
file: 'rand-om__-uuid-1234',
|
||||
translations: [],
|
||||
};
|
||||
|
||||
expect(toProductDocumentView(rawData)).toEqual({
|
||||
id: 1,
|
||||
fileId: 'rand-om__-uuid-1234',
|
||||
filename: undefined,
|
||||
title: '',
|
||||
url: 'http://localhost:8055/assets/rand-om__-uuid-1234',
|
||||
size: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 单元测试: toDocumentListView
|
||||
*/
|
||||
describe('toProductDocumentView', () => {
|
||||
test('convert raw data with fileId to DocumentListView correctly', () => {
|
||||
const rawData: ProductDocument = {
|
||||
id: 1,
|
||||
file: 'rand-om__-uuid-1234',
|
||||
translations: [{ id: 10, title: 'Document Title' }],
|
||||
products: [
|
||||
{
|
||||
id: 10,
|
||||
products_id: {
|
||||
id: 1,
|
||||
translations: [{ id: 1, name: 'Product A' }],
|
||||
product_type: {
|
||||
id: 1,
|
||||
translations: [{ id: 1, name: 'Type A' }],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(toDocumentListView(rawData)).toEqual({
|
||||
id: 1,
|
||||
fileId: 'rand-om__-uuid-1234',
|
||||
filename: undefined,
|
||||
title: 'Document Title',
|
||||
url: 'http://localhost:8055/assets/rand-om__-uuid-1234',
|
||||
size: undefined,
|
||||
products: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Product A',
|
||||
type: {
|
||||
id: 1,
|
||||
name: 'Type A',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,79 +0,0 @@
|
||||
/**
|
||||
* 将 Directus 返回的 Document 数据转换为 ProductDocumentView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Document 数据
|
||||
* @returns 转换后的 ProductDocumentView 对象
|
||||
*
|
||||
* @example
|
||||
* const view = toProductDocumentView(rawDocument);
|
||||
*/
|
||||
export function toProductDocumentView(
|
||||
raw: ProductDocument
|
||||
): ProductDocumentView {
|
||||
const trans = raw.translations?.[0] ?? {
|
||||
title: '',
|
||||
};
|
||||
|
||||
const fileId = typeof raw.file === 'string' ? raw.file : raw.file?.id;
|
||||
const file = raw.file as DirectusFile;
|
||||
|
||||
const { getFileUrl } = useDirectusFiles();
|
||||
|
||||
const url = getFileUrl(fileId);
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
fileId: fileId,
|
||||
filename: file.filename_download,
|
||||
title: trans.title,
|
||||
url: url,
|
||||
size: file.filesize,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 Document 数据转换为 DocumentListView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Document 数据
|
||||
* @returns 转换后的 DocumentListView 对象
|
||||
*
|
||||
* @example
|
||||
* const view = toDocumentListView(rawDocument);
|
||||
*/
|
||||
export function toDocumentListView(raw: ProductDocument): DocumentListView {
|
||||
const trans = raw.translations?.[0] ?? { title: '' };
|
||||
|
||||
const fileId = typeof raw.file === 'string' ? raw.file : raw.file?.id;
|
||||
const file = raw.file as DirectusFile;
|
||||
|
||||
const { getFileUrl } = useDirectusFiles();
|
||||
const url = getFileUrl(fileId);
|
||||
|
||||
const related_products: DocumentListProduct[] = raw.products
|
||||
?.filter(isObject<ProductsProductDocument>)
|
||||
.map((item) => item.products_id)
|
||||
.filter(isObject<Product>)
|
||||
.map((item) => {
|
||||
const productType =
|
||||
isObject<ProductType>(item.product_type) &&
|
||||
({
|
||||
id: item.product_type.id,
|
||||
name: item.product_type.translations?.[0]?.name,
|
||||
} satisfies DocumentListProductType);
|
||||
return {
|
||||
id: item.id,
|
||||
name: item.translations?.[0]?.name,
|
||||
type: productType,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
fileId: fileId,
|
||||
filename: file.filename_download,
|
||||
title: trans.title,
|
||||
url: url,
|
||||
size: file.filesize,
|
||||
products: related_products,
|
||||
};
|
||||
}
|
||||
@ -1,168 +0,0 @@
|
||||
import { describe, test, expect } from 'vitest';
|
||||
|
||||
/**
|
||||
* 单元测试: toProductListView
|
||||
*/
|
||||
describe('toProductListView', () => {
|
||||
test('convert raw data to ProductListView correctly', () => {
|
||||
const rawData: Product = {
|
||||
id: 1,
|
||||
translations: [
|
||||
{ id: 10, name: 'Product Name', summary: 'Product Summary' },
|
||||
],
|
||||
cover: 'cover-file-uuid-1234',
|
||||
product_type: {
|
||||
id: 1,
|
||||
translations: [{ id: 20, name: 'Type Name' }],
|
||||
},
|
||||
};
|
||||
|
||||
expect(toProductListView(rawData)).toEqual({
|
||||
id: 1,
|
||||
name: 'Product Name',
|
||||
summary: 'Product Summary',
|
||||
cover: 'cover-file-uuid-1234',
|
||||
product_type: 'Type Name',
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: Product = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
cover: 'cover-file-uuid-1234',
|
||||
product_type: {
|
||||
id: 20,
|
||||
translations: [],
|
||||
},
|
||||
};
|
||||
|
||||
expect(toProductListView(rawData)).toEqual({
|
||||
id: 1,
|
||||
name: '',
|
||||
summary: '',
|
||||
cover: 'cover-file-uuid-1234',
|
||||
product_type: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 单元测试: toProductSpecView
|
||||
*/
|
||||
describe('toProductSpecView', () => {
|
||||
test('convert raw data to ProductSpecView correctly', () => {
|
||||
const rawData: ProductSpec = {
|
||||
id: 1,
|
||||
translations: [{ id: 1, key: 'Key', value: 'Value' }],
|
||||
};
|
||||
|
||||
expect(toProductSpecView(rawData)).toEqual({
|
||||
id: 1,
|
||||
key: 'Key',
|
||||
value: 'Value',
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: ProductSpec = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
};
|
||||
|
||||
expect(toProductSpecView(rawData)).toEqual({
|
||||
id: 1,
|
||||
key: '',
|
||||
value: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 单元测试: toProductSpecGroupView
|
||||
*/
|
||||
describe('toProductSpecGroupView', () => {
|
||||
test('convert raw data to ProductSpecGroupView correctly', () => {
|
||||
const rawData: ProductSpecGroup = {
|
||||
id: 1,
|
||||
translations: [{ id: 1, name: 'Group Name' }],
|
||||
specs: [
|
||||
{ id: 1, translations: [{ id: 1, key: 'Key1', value: 'Value1' }] },
|
||||
{ id: 2, translations: [{ id: 2, key: 'Key2', value: 'Value2' }] },
|
||||
],
|
||||
};
|
||||
|
||||
expect(toProductSpecGroupView(rawData)).toEqual({
|
||||
id: 1,
|
||||
name: 'Group Name',
|
||||
specs: [
|
||||
{ id: 1, key: 'Key1', value: 'Value1' },
|
||||
{ id: 2, key: 'Key2', value: 'Value2' },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: ProductSpecGroup = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
specs: [],
|
||||
};
|
||||
|
||||
expect(toProductSpecGroupView(rawData)).toEqual({
|
||||
id: 1,
|
||||
name: '',
|
||||
specs: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 单元测试: toProductView
|
||||
*/
|
||||
describe('toProductView', () => {
|
||||
test('convert raw data to ProductView correctly', () => {
|
||||
const rawData: Product = {
|
||||
id: 1,
|
||||
translations: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Product Name',
|
||||
summary: 'Product Summary',
|
||||
description: 'Product Description',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(toProductView(rawData)).toEqual({
|
||||
id: 1,
|
||||
name: 'Product Name',
|
||||
summary: 'Product Summary',
|
||||
description: 'Product Description',
|
||||
product_type: '',
|
||||
images: [],
|
||||
documents: [],
|
||||
faqs: [],
|
||||
specs: [],
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: Product = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
};
|
||||
|
||||
expect(toProductView(rawData)).toEqual({
|
||||
id: 1,
|
||||
name: '',
|
||||
summary: '',
|
||||
description: '',
|
||||
product_type: '',
|
||||
images: [],
|
||||
documents: [],
|
||||
faqs: [],
|
||||
specs: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,136 +0,0 @@
|
||||
/**
|
||||
* 将 Directus返回的 Product 数据转换为 ProductListView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Product 数据
|
||||
* @returns 转换后的 ProductListView 对象
|
||||
*
|
||||
* @example
|
||||
* const view = toProductListView(rawProduct);
|
||||
*/
|
||||
export function toProductListView(raw: Product): ProductListView {
|
||||
const trans = raw.translations?.[0] ?? { name: '', summary: '' };
|
||||
|
||||
const type = isObject<ProductType>(raw.product_type)
|
||||
? raw.product_type.translations.length === 0
|
||||
? ''
|
||||
: raw.product_type.translations[0].name
|
||||
: '';
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
product_type: type,
|
||||
name: trans.name,
|
||||
summary: trans.summary,
|
||||
cover: raw.cover.toString(),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 ProductSpecGroup 数据转换为 ProductSpecGroupView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 ProductSpecGroup 数据
|
||||
* @returns 转换后的 ProductSpecGroupView 对象
|
||||
*
|
||||
* @example
|
||||
* const view = toProductSpecGroupView(rawSpecGroup);
|
||||
*/
|
||||
export function toProductSpecGroupView(
|
||||
raw: ProductSpecGroup
|
||||
): ProductSpecGroupView {
|
||||
const trans = raw.translations?.[0] ?? {
|
||||
name: '',
|
||||
};
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
name: trans.name,
|
||||
specs: raw.specs
|
||||
.filter(isObject<ProductSpec>)
|
||||
.map((item) => toProductSpecView(item)),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 ProductSpec 数据转换为 ProductSpecView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 ProductSpec 数据
|
||||
* @returns 转换后的 ProductSpecView 对象
|
||||
*
|
||||
* @example
|
||||
* const view = toProductSpecView(rawSpecGroup);
|
||||
*/
|
||||
export function toProductSpecView(raw: ProductSpec): ProductSpecView {
|
||||
const trans = raw.translations?.[0] ?? {
|
||||
key: '',
|
||||
value: '',
|
||||
};
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
key: trans.key,
|
||||
value: trans.value,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 Product 数据转换为 ProductView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Product 数据
|
||||
* @returns 转换后的 ProductView 对象
|
||||
*
|
||||
* @example
|
||||
* const view = toProductView(rawProduct);
|
||||
*/
|
||||
export function toProductView(raw: Product): ProductView {
|
||||
const trans = raw.translations?.[0] ?? {
|
||||
name: '',
|
||||
summary: '',
|
||||
description: '',
|
||||
};
|
||||
|
||||
const images = (raw.images ?? [])
|
||||
.filter(isObject<ProductsProductImage>)
|
||||
.map((item) => item.product_images_id)
|
||||
.filter(isObject<ProductImage>)
|
||||
.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
image: item.image.toString(),
|
||||
caption: item.translations?.[0]?.caption || '',
|
||||
};
|
||||
});
|
||||
|
||||
const specs = (raw.specs ?? [])
|
||||
.filter(isObject<ProductSpecGroup>)
|
||||
.map((item) => toProductSpecGroupView(item));
|
||||
|
||||
const faqs = (raw.faqs ?? [])
|
||||
.filter(isObject<ProductsQuestion>)
|
||||
.map((item) => item.questions_id)
|
||||
.filter(isObject<Question>)
|
||||
.map((item) => toProductQuestionView(item));
|
||||
|
||||
const documents = (raw.documents ?? [])
|
||||
.filter(isObject<ProductsProductDocument>)
|
||||
.map((item) => item.product_documents_id)
|
||||
.filter(isObject<ProductDocument>)
|
||||
.map((item) => toProductDocumentView(item));
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
|
||||
product_type:
|
||||
typeof raw.product_type === 'string'
|
||||
? raw.product_type
|
||||
: typeof raw.product_type === 'object' && raw.product_type
|
||||
? raw.product_type.translations[0].name || ''
|
||||
: '',
|
||||
name: trans.name,
|
||||
summary: trans.summary,
|
||||
images: images,
|
||||
description: trans.description,
|
||||
specs: specs,
|
||||
faqs: faqs,
|
||||
documents: documents,
|
||||
};
|
||||
}
|
||||
@ -1,113 +0,0 @@
|
||||
import { describe, expect, test } from 'vitest';
|
||||
|
||||
/**
|
||||
* 单元测试: toProductQuestionView
|
||||
*/
|
||||
describe('toProductQuestionView', () => {
|
||||
test('convert raw data to ProductQuestionView correctly', () => {
|
||||
const rawData: Question = {
|
||||
id: 1,
|
||||
translations: [
|
||||
{ id: 1, title: 'Question Title', content: 'Question Answer' },
|
||||
],
|
||||
};
|
||||
|
||||
expect(toProductQuestionView(rawData)).toEqual({
|
||||
id: 1,
|
||||
title: 'Question Title',
|
||||
content: 'Question Answer',
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: Question = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
};
|
||||
|
||||
expect(toProductQuestionView(rawData)).toEqual({
|
||||
id: 1,
|
||||
title: '',
|
||||
content: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 单元测试: toQuestionListView
|
||||
*/
|
||||
describe('toQuestionListView', () => {
|
||||
test('convert raw data to QuestionListView correctly', () => {
|
||||
const rawData: Question = {
|
||||
id: 1,
|
||||
translations: [
|
||||
{ id: 1, title: 'Question Title', content: 'Question Answer' },
|
||||
],
|
||||
products: [
|
||||
{
|
||||
id: 1,
|
||||
products_id: {
|
||||
id: 1,
|
||||
translations: [{ id: 1, name: 'Product Name' }],
|
||||
product_type: {
|
||||
id: 1,
|
||||
translations: [{ id: 1, name: 'Type Name' }],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(toQuestionListView(rawData)).toEqual({
|
||||
id: 1,
|
||||
title: 'Question Title',
|
||||
content: 'Question Answer',
|
||||
products: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Product Name',
|
||||
type: {
|
||||
id: 1,
|
||||
name: 'Type Name',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: Question = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
products: [
|
||||
{
|
||||
id: 1,
|
||||
products_id: {
|
||||
id: 1,
|
||||
translations: [],
|
||||
product_type: {
|
||||
id: 1,
|
||||
translations: [],
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
expect(toQuestionListView(rawData)).toEqual({
|
||||
id: 1,
|
||||
title: '',
|
||||
content: '',
|
||||
products: [
|
||||
{
|
||||
id: 1,
|
||||
name: '',
|
||||
type: {
|
||||
id: 1,
|
||||
name: '',
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,59 +0,0 @@
|
||||
/**
|
||||
* 将 Directus 返回的 Question 数据转换为 ProductQuestionView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Question 数据
|
||||
* @returns 转换后的 ProductQuestionView 对象
|
||||
*
|
||||
* @example
|
||||
* const view = toProductQuestionView(rawQuestion);
|
||||
*/
|
||||
export function toProductQuestionView(raw: Question): ProductQuestionView {
|
||||
const trans = raw.translations?.[0] ?? { title: '', content: '' };
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
title: trans.title,
|
||||
content: trans.content,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 Question 数据转换为 QuestionListView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Question 数据
|
||||
* @returns 转换后的 QuestionListView 对象
|
||||
* ---
|
||||
* @example
|
||||
* const view = toQuestionListView(rawQuestion);
|
||||
*/
|
||||
export function toQuestionListView(raw: Question): QuestionListView {
|
||||
const trans = raw.translations?.[0] ?? { title: '', content: '' };
|
||||
|
||||
const related_products: QuestionListProduct[] = (raw.products ?? [])
|
||||
.filter(isObject<ProductsQuestion>)
|
||||
.map((item) => item.products_id)
|
||||
.filter(isObject<Product>)
|
||||
.map((item) => {
|
||||
const translations = item.translations[0] ?? { name: '' };
|
||||
|
||||
const product_type =
|
||||
isObject<ProductType>(item.product_type) &&
|
||||
({
|
||||
id: item.product_type.id,
|
||||
name: item.product_type.translations[0]?.name ?? '',
|
||||
} satisfies QuestionListProductType);
|
||||
|
||||
return {
|
||||
id: item.id,
|
||||
name: translations.name,
|
||||
type: product_type,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
title: trans.title,
|
||||
content: trans.content,
|
||||
products: related_products,
|
||||
};
|
||||
}
|
||||
@ -1,88 +0,0 @@
|
||||
import { describe, test, expect } from 'vitest';
|
||||
|
||||
/**
|
||||
* 单元测试: toSolutionListView
|
||||
*/
|
||||
describe('toSolutionListView', () => {
|
||||
test('convert raw data to SolutionListView correctly', () => {
|
||||
const rawData: Solution = {
|
||||
id: 1,
|
||||
translations: [
|
||||
{ id: 1, title: 'Solution Title', summary: 'Solution Summary' },
|
||||
],
|
||||
type: {
|
||||
id: 1,
|
||||
translations: [{ id: 1, name: 'Type Name' }],
|
||||
},
|
||||
};
|
||||
|
||||
expect(toSolutionListView(rawData)).toEqual({
|
||||
id: 1,
|
||||
title: 'Solution Title',
|
||||
summary: 'Solution Summary',
|
||||
solution_type: 'Type Name',
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: Solution = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
type: {
|
||||
id: 1,
|
||||
translations: [],
|
||||
},
|
||||
};
|
||||
|
||||
expect(toSolutionListView(rawData)).toEqual({
|
||||
id: 1,
|
||||
title: '',
|
||||
summary: '',
|
||||
solution_type: '',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 单元测试: toSolutionView
|
||||
*/
|
||||
describe('toSolutionView', () => {
|
||||
test('convert raw data to SolutionView correctly', () => {
|
||||
const rawData: Solution = {
|
||||
id: 1,
|
||||
translations: [
|
||||
{
|
||||
id: 1,
|
||||
title: 'Solution Title',
|
||||
summary: 'Solution Summary',
|
||||
content: 'Solution Content',
|
||||
},
|
||||
],
|
||||
create_at: '2023-01-01T00:00:00Z',
|
||||
};
|
||||
|
||||
expect(toSolutionView(rawData)).toEqual({
|
||||
id: 1,
|
||||
title: 'Solution Title',
|
||||
summary: 'Solution Summary',
|
||||
content: 'Solution Content',
|
||||
createAt: '2023-01-01T00:00:00Z',
|
||||
});
|
||||
});
|
||||
|
||||
test('convert raw data with missing translations', () => {
|
||||
const rawData: Solution = {
|
||||
id: 1,
|
||||
translations: [],
|
||||
create_at: '2023-01-01T00:00:00Z',
|
||||
};
|
||||
|
||||
expect(toSolutionView(rawData)).toEqual({
|
||||
id: 1,
|
||||
title: '',
|
||||
summary: '',
|
||||
content: '',
|
||||
createAt: '2023-01-01T00:00:00Z',
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,58 +0,0 @@
|
||||
/**
|
||||
* 将 Directus 返回的 Solution 数据转换为 SolutionListView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Solution 数据
|
||||
* @returns 转换后的 SolutionListView 对象
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* @example
|
||||
* const view = toSolutionListView(rawSolution);
|
||||
*/
|
||||
export function toSolutionListView(raw: Solution): SolutionListView {
|
||||
const trans = raw.translations?.[0] ?? {
|
||||
title: '',
|
||||
summary: '',
|
||||
};
|
||||
|
||||
const type = isObject<SolutionType>(raw.type)
|
||||
? raw.type.translations.length === 0
|
||||
? ''
|
||||
: raw.type.translations[0].name
|
||||
: '';
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
title: trans.title,
|
||||
summary: trans.summary,
|
||||
solution_type: type,
|
||||
cover: isObject<DirectusFile>(raw.cover) ? raw.cover.id : raw.cover,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Directus 返回的 Solution 数据转换为 SolutionView 视图模型
|
||||
*
|
||||
* @param raw: 原始的 Solution 数据
|
||||
* @returns 转换后的 SolutionView 对象
|
||||
*
|
||||
* ---
|
||||
*
|
||||
* @example
|
||||
* const view = toSolutionView(rawSolution);
|
||||
*/
|
||||
export function toSolutionView(raw: Solution): SolutionView {
|
||||
const trans = raw.translations?.[0] ?? {
|
||||
title: '',
|
||||
summary: '',
|
||||
content: '',
|
||||
};
|
||||
|
||||
return {
|
||||
id: raw.id,
|
||||
title: trans.title,
|
||||
summary: trans.summary,
|
||||
content: trans.content,
|
||||
createAt: raw.create_at,
|
||||
};
|
||||
}
|
||||
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* 文档视图模型
|
||||
* 用于文档列表渲染的数据结构
|
||||
*/
|
||||
export interface ProductDocumentView {
|
||||
/** 唯一标识符 **/
|
||||
id: number;
|
||||
|
||||
/** 文件UUID **/
|
||||
fileId: string;
|
||||
|
||||
/** 文件名 **/
|
||||
filename: string;
|
||||
|
||||
/** 文档标题 **/
|
||||
title: string;
|
||||
|
||||
/** 文档大小 **/
|
||||
size: number;
|
||||
|
||||
/** 文档链接 **/
|
||||
url: string;
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* 常见问题视图模型
|
||||
* 用于产品页常见问题渲染的数据结构
|
||||
*/
|
||||
export interface ProductQuestionView {
|
||||
/** 唯一标识符 **/
|
||||
id: number;
|
||||
|
||||
/** 问题标题 **/
|
||||
title: string;
|
||||
|
||||
/** 问题内容 **/
|
||||
content: string;
|
||||
}
|
||||
@ -1,29 +0,0 @@
|
||||
/**
|
||||
* 产品规格模型
|
||||
* 用于产品规格渲染的数据结构
|
||||
*/
|
||||
export interface ProductSpecView {
|
||||
/** 唯一标识符 **/
|
||||
id: number;
|
||||
|
||||
/** 规格名称 **/
|
||||
key: string;
|
||||
|
||||
/** 规格值 **/
|
||||
value: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品规格表模型
|
||||
* 用于产品规格表渲染的数据结构
|
||||
*/
|
||||
export interface ProductSpecGroupView {
|
||||
/** 唯一标识符 **/
|
||||
id: number;
|
||||
|
||||
/** 规格组名称 **/
|
||||
name: string;
|
||||
|
||||
/** 规格组 **/
|
||||
specs: ProductSpecView[];
|
||||
}
|
||||
@ -1,38 +0,0 @@
|
||||
interface ImageView {
|
||||
id: number;
|
||||
image: string;
|
||||
caption: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 产品视图模型
|
||||
* 用于产品详情页(/products/[slug])渲染的数据结构
|
||||
*/
|
||||
export interface ProductView {
|
||||
/** 唯一标识符 **/
|
||||
id: number;
|
||||
|
||||
/** 产品名称 **/
|
||||
name: string;
|
||||
|
||||
/** 产品简介 **/
|
||||
summary: string;
|
||||
|
||||
/** 产品类型 **/
|
||||
product_type: string;
|
||||
|
||||
/** 产品图片 **/
|
||||
images: ImageView[];
|
||||
|
||||
/** 产品详情 **/
|
||||
description: string;
|
||||
|
||||
/** 产品规格 **/
|
||||
specs: ProductSpecGroupView[];
|
||||
|
||||
/** 产品常见问题 **/
|
||||
faqs: QuestionView[];
|
||||
|
||||
/** 产品文档 **/
|
||||
documents: ProductDocumentView[];
|
||||
}
|
||||
@ -4,20 +4,29 @@
|
||||
<app-breadcrumb class="breadcrumb" :items="breadcrumbItems" />
|
||||
|
||||
<div class="content">
|
||||
<markdown-renderer :content="content.content || ''" />
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div class="html-typography" v-html="companyProfile.content || ''" />
|
||||
<!-- <div v-if="!hydrated" v-html="companyProfile.content || ''" /> -->
|
||||
<!-- <div v-else> -->
|
||||
<!-- <html-renderer -->
|
||||
<!-- class="html-typography" -->
|
||||
<!-- :html="companyProfile.content || ''" -->
|
||||
<!-- /> -->
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
|
||||
<el-divider content-position="left">{{ $t('learn-more') }}</el-divider>
|
||||
<div class="button-group">
|
||||
<NuxtLink :to="$localePath('/support/contact-us')">
|
||||
<el-card class="card-button">
|
||||
<el-icon class="icon" size="80">
|
||||
<ElIconService />
|
||||
</el-icon>
|
||||
<br />
|
||||
{{ $t('navigation.contact-info') }}
|
||||
</el-card>
|
||||
</NuxtLink>
|
||||
<learn-more-card
|
||||
:title="$t('navigation.contact-info')"
|
||||
:icon="ElIconService"
|
||||
:to="$localePath('/support/contact-us')"
|
||||
/>
|
||||
<learn-more-card
|
||||
:title="$t('navigation.address')"
|
||||
:icon="ElIconMapLocation"
|
||||
@click="openMap"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="loading">
|
||||
@ -28,19 +37,31 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
const localePath = useLocalePath();
|
||||
const hydrated = ref(false);
|
||||
const breadcrumbItems = [
|
||||
{ label: $t('navigation.home'), to: localePath('/') },
|
||||
{ label: $t('navigation.about-us') },
|
||||
];
|
||||
const { data, pending, error } = await useCompanyProfile();
|
||||
const { data: companyProfile, pending, error } = await useCompanyProfile();
|
||||
|
||||
const content = computed(() => toCompanyProfileView(data.value));
|
||||
const openMap = () => {
|
||||
window.open(localePath('/locate'));
|
||||
};
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
const pageTitle = computed(() => $t('page-title.about-us'));
|
||||
useHead({
|
||||
title: pageTitle,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
hydrated.value = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -59,14 +80,6 @@
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
:deep(.markdown-body p) {
|
||||
text-indent: 2em;
|
||||
}
|
||||
|
||||
:deep(.markdown-body h2) {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
:deep(.el-divider__text) {
|
||||
color: var(--el-color-info);
|
||||
font-size: 1em;
|
||||
@ -77,25 +90,7 @@
|
||||
justify-content: left;
|
||||
margin-top: 2rem;
|
||||
margin-left: 2rem;
|
||||
}
|
||||
|
||||
.card-button {
|
||||
width: 20%;
|
||||
min-width: 200px;
|
||||
padding: 20px;
|
||||
margin: 0 auto;
|
||||
cursor: pointer;
|
||||
text-align: center;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
.card-button:hover {
|
||||
transform: translateY(-4px);
|
||||
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.icon {
|
||||
padding: 10px;
|
||||
gap: 2rem;
|
||||
}
|
||||
|
||||
.loading {
|
||||
@ -104,4 +99,12 @@
|
||||
align-items: center;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.button-group {
|
||||
align-items: center;
|
||||
margin-left: 0;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -19,7 +19,9 @@
|
||||
|
||||
const breadcrumbItems = [
|
||||
{ label: $t('navigation.home'), to: localePath('/') },
|
||||
{ label: $t('navigation.downloads'), to: localePath('/downloads') },
|
||||
{ label: $t('navigation.support'), to: localePath('/support') },
|
||||
{ label: $t('navigation.documents'), to: localePath('/support/documents') },
|
||||
{ label: $t('navigation.downloads') },
|
||||
];
|
||||
|
||||
const id = route.params.id as string;
|
||||
@ -36,6 +38,11 @@
|
||||
statusMessage: '文件未找到',
|
||||
});
|
||||
}
|
||||
|
||||
const pageTitle = $t('page-title.download');
|
||||
usePageSeo({
|
||||
title: file.value.filename_download || pageTitle,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -1,27 +1,24 @@
|
||||
<template>
|
||||
<div class="homepage">
|
||||
<homepage-carousel :homepage-data="homepageData" :pending="pending" />
|
||||
<homepage-product-section
|
||||
:homepage-data="homepageData"
|
||||
:pending="pending"
|
||||
/>
|
||||
<homepage-solution-section
|
||||
:homepage-data="homepageData"
|
||||
:pending="pending"
|
||||
/>
|
||||
<homepage-carousel :homepage-data="data" :pending="pending" />
|
||||
<homepage-product-section :homepage-data="data" :pending="pending" />
|
||||
<homepage-solution-section :homepage-data="data" :pending="pending" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
const { data, pending, error } = await useHomepage();
|
||||
|
||||
const homepageData = computed(() => {
|
||||
return toHomepageView(data.value);
|
||||
});
|
||||
const pageTilte = $t('page-title.homepage');
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
useSeoMeta({
|
||||
title: pageTilte,
|
||||
description: $t('company-description'),
|
||||
});
|
||||
</script>
|
||||
|
||||
12
app/pages/locate.vue
Normal file
12
app/pages/locate.vue
Normal file
@ -0,0 +1,12 @@
|
||||
<template>
|
||||
<div>redirecting...</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
onMounted(async () => {
|
||||
const platform = await getAutoMappedService();
|
||||
|
||||
// // ✔ 移动端能正常跳转
|
||||
window.location.href = platform;
|
||||
});
|
||||
</script>
|
||||
@ -35,17 +35,9 @@
|
||||
const localePath = useLocalePath();
|
||||
|
||||
// 获取路由参数
|
||||
const id = computed(() => route.params.slug as string);
|
||||
const id = route.params.slug as string;
|
||||
|
||||
const { data, pending, error } = await useProduct(id.value);
|
||||
|
||||
const rawProduct = computed(() => data.value ?? null);
|
||||
const product = computed(() => {
|
||||
if (rawProduct.value === null) {
|
||||
return null;
|
||||
}
|
||||
return toProductView(rawProduct.value);
|
||||
});
|
||||
const { data: product, pending, error } = await useProduct(id);
|
||||
|
||||
const breadcrumbItems = computed(() => [
|
||||
{ label: $t('navigation.home'), to: localePath('/') },
|
||||
@ -55,19 +47,14 @@
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
// SEO
|
||||
useHead({
|
||||
title: computed(() => product.value?.name || 'Product Detail'),
|
||||
meta: [
|
||||
{
|
||||
name: 'description',
|
||||
content: computed(() => product.value?.summary || ''),
|
||||
},
|
||||
],
|
||||
usePageSeo({
|
||||
title: product.value?.name || $t('page-title.products'),
|
||||
description: product.value?.summary || '',
|
||||
});
|
||||
</script>
|
||||
|
||||
@ -1,21 +1,27 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h1 class="page-title">{{ $t('our-products') }}</h1>
|
||||
<p class="page-subtitle">
|
||||
{{ $t('products-desc') }}{{ $t('find-discontinued-products') }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<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="(group, type) in groupedProducts"
|
||||
:key="type"
|
||||
:title="type || '未分类'"
|
||||
:name="type || 'no-category'"
|
||||
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 group"
|
||||
v-for="product in value.data"
|
||||
:key="product.id"
|
||||
:slug="product.id.toString()"
|
||||
:image-url="getImageUrl(product.cover.toString())"
|
||||
@ -37,7 +43,7 @@
|
||||
const localePath = useLocalePath();
|
||||
const { getImageUrl } = useDirectusImage();
|
||||
|
||||
const { data, pending, error } = useProductList();
|
||||
const { data: products, pending, error } = await useProductList();
|
||||
|
||||
const activeNames = ref<string[]>([]);
|
||||
|
||||
@ -46,31 +52,21 @@
|
||||
{ label: $t('navigation.products') },
|
||||
];
|
||||
|
||||
const productsRaw = computed(() => data.value ?? []);
|
||||
const products = computed(() =>
|
||||
productsRaw.value.map((item) => toProductListView(item))
|
||||
);
|
||||
|
||||
// 按类型分组
|
||||
// 兼容 product_type 既可能为对象也可能为字符串
|
||||
const groupedProducts = computed(() => {
|
||||
const groups: Record<string, ProductListView[]> = {};
|
||||
const groups: Record<string, { data: ProductListView[]; sort: number }> =
|
||||
{};
|
||||
for (const prod of products.value) {
|
||||
let typeKey = '';
|
||||
if (typeof prod.product_type === 'string') {
|
||||
typeKey = prod.product_type;
|
||||
} else if (
|
||||
prod.product_type &&
|
||||
typeof prod.product_type === 'object' &&
|
||||
'name' in prod.product_type
|
||||
) {
|
||||
typeKey = prod.product_type || '';
|
||||
const typeKey = prod.product_type?.name ?? '';
|
||||
if (!groups[typeKey]) {
|
||||
groups[typeKey] = { data: [], sort: prod.product_type?.sort ?? 999 };
|
||||
}
|
||||
if (!groups[typeKey]) groups[typeKey] = [];
|
||||
groups[typeKey]?.push(prod);
|
||||
groups[typeKey]?.data.push(prod);
|
||||
}
|
||||
console.log(groups);
|
||||
return groups;
|
||||
const sortedGroups = Object.fromEntries(
|
||||
Object.entries(groups).sort(([, a], [, b]) => a.sort - b.sort)
|
||||
);
|
||||
return sortedGroups;
|
||||
});
|
||||
|
||||
watch(groupedProducts, () => {
|
||||
@ -84,13 +80,7 @@
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
watch(pending, (value) => {
|
||||
if (!value) {
|
||||
console.log('AsyncData: ', data.value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
@ -102,6 +92,11 @@
|
||||
];
|
||||
}
|
||||
});
|
||||
|
||||
const pageTitle = $t('page-title.products');
|
||||
usePageSeo({
|
||||
title: pageTitle,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -113,13 +108,18 @@
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
color: var(--el-color-primary);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.page-subtitle {
|
||||
font-size: 0.8rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
|
||||
@ -21,58 +21,36 @@
|
||||
// i18n相关
|
||||
const { t } = useI18n();
|
||||
const { getDirectusLocale } = useLocalizations();
|
||||
const directusLocale = getDirectusLocale();
|
||||
const locale = getDirectusLocale();
|
||||
|
||||
// 路由相关
|
||||
const route = useRoute();
|
||||
|
||||
// 搜索相关
|
||||
const { search } = useMeilisearch();
|
||||
const keyword = ref('');
|
||||
|
||||
if (typeof route.query.query === 'string' && route.query.query.trim()) {
|
||||
keyword.value = route.query.query;
|
||||
}
|
||||
|
||||
const {
|
||||
data: sections,
|
||||
data: searchItems,
|
||||
pending: loading,
|
||||
error,
|
||||
refresh,
|
||||
} = await useAsyncData(
|
||||
() => `search-${directusLocale}-${route.query.query ?? ''}`,
|
||||
async () => {
|
||||
const q = String(route.query.query ?? '').trim();
|
||||
if (!q) return [];
|
||||
return await search(q, { limit: 12 }, directusLocale);
|
||||
} = useAsyncData(`meilisearch-${keyword.value}-${locale}`, async () => {
|
||||
try {
|
||||
const data = await $fetch(`/api/search?query=${keyword.value}`, {
|
||||
headers: { 'x-locale': locale },
|
||||
});
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.error('Error fetching search results: ', error);
|
||||
throw error;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
// 空Section过滤
|
||||
const filteredSections = computed(() =>
|
||||
sections.value.filter((section) => section.hits.length > 0)
|
||||
);
|
||||
|
||||
const typeMap = {
|
||||
products: 'products',
|
||||
solutions: 'solutions',
|
||||
questions: 'questions',
|
||||
product_documents: 'product_documents',
|
||||
} as const;
|
||||
// 展平hits
|
||||
const hits = computed(() =>
|
||||
filteredSections.value.flatMap((section) => {
|
||||
const type = typeMap[section.rawIndex as keyof typeof typeMap];
|
||||
if (!type) return [];
|
||||
return section.hits.map((hit) => ({ type, content: hit }));
|
||||
})
|
||||
);
|
||||
|
||||
const searchItems = computed(() =>
|
||||
hits.value.map((hit) => {
|
||||
return toSearchItemView(hit.content, hit.type);
|
||||
})
|
||||
);
|
||||
|
||||
const hasResults = computed(() =>
|
||||
filteredSections.value.some((section) => section.hits.length > 0)
|
||||
);
|
||||
const hasResults = computed(() => searchItems.value.length > 0);
|
||||
|
||||
watch(
|
||||
() => route.query.query,
|
||||
@ -84,9 +62,16 @@
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => locale,
|
||||
async () => {
|
||||
await refresh();
|
||||
}
|
||||
);
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -26,17 +26,10 @@
|
||||
const route = useRoute();
|
||||
const localePath = useLocalePath();
|
||||
|
||||
// 获取路由参数(documentId)
|
||||
const id = computed(() => route.params.slug as string);
|
||||
// 获取路由参数
|
||||
const id = route.params.slug as string;
|
||||
|
||||
const { data, pending, error } = await useSolution(id.value);
|
||||
|
||||
const solution = computed(() => {
|
||||
if (!data.value) {
|
||||
return null;
|
||||
}
|
||||
return toSolutionView(data.value);
|
||||
});
|
||||
const { data: solution, pending, error } = await useSolution(id);
|
||||
|
||||
const breadcrumbItems = computed(() => [
|
||||
{ label: $t('navigation.home'), to: localePath('/') },
|
||||
@ -46,9 +39,14 @@
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
usePageSeo({
|
||||
title: solution.value?.title || $t('page-title.solutions'),
|
||||
description: solution.value?.summary || '',
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -1,7 +1,11 @@
|
||||
<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 v-if="!pending" class="solutions-container">
|
||||
@ -19,14 +23,14 @@
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane
|
||||
v-for="(group, type) in groupedSolutions"
|
||||
:key="type"
|
||||
:label="type || '未分类'"
|
||||
:name="type || 'no-category'"
|
||||
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 group"
|
||||
v-for="solution in value.data"
|
||||
:key="solution.id"
|
||||
:document-id="solution.id.toString()"
|
||||
:cover-url="getImageUrl(solution.cover || '')"
|
||||
@ -52,40 +56,37 @@
|
||||
{ label: $t('navigation.solutions') },
|
||||
];
|
||||
|
||||
const { data, pending, error } = await useSolutionList();
|
||||
|
||||
const solutionsRaw = computed(() => data.value ?? []);
|
||||
const solutions = computed(() =>
|
||||
solutionsRaw.value.map((item) => toSolutionListView(item))
|
||||
);
|
||||
const { data: solutions, pending, error } = await useSolutionList();
|
||||
|
||||
const activeName = ref<string>('all');
|
||||
|
||||
// 按类型分组
|
||||
const groupedSolutions = computed(() => {
|
||||
const gourps: Record<string, SolutionListView[]> = {};
|
||||
const groups: Record<string, { data: SolutionListView[]; sort: number }> =
|
||||
{};
|
||||
for (const sol of solutions.value) {
|
||||
let typeKey = '';
|
||||
if (typeof sol.solution_type === 'string') {
|
||||
typeKey = sol.solution_type;
|
||||
} else if (
|
||||
sol.solution_type &&
|
||||
typeof sol.solution_type === 'object' &&
|
||||
'type' in sol.solution_type
|
||||
) {
|
||||
typeKey = sol.solution_type || '';
|
||||
const typeKey = sol.solution_type?.name ?? '';
|
||||
if (!groups[typeKey]) {
|
||||
groups[typeKey] = { data: [], sort: sol.solution_type?.sort ?? 999 };
|
||||
}
|
||||
if (!gourps[typeKey]) gourps[typeKey] = [];
|
||||
gourps[typeKey]?.push(sol);
|
||||
groups[typeKey]?.data.push(sol);
|
||||
}
|
||||
return gourps;
|
||||
const sortedGroups = Object.fromEntries(
|
||||
Object.entries(groups).sort(([, a], [, b]) => a.sort - b.sort)
|
||||
);
|
||||
return sortedGroups;
|
||||
});
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
const pageTitle = $t('page-title.solutions');
|
||||
usePageSeo({
|
||||
title: pageTitle,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -97,15 +98,20 @@
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--el-color-primary);
|
||||
}
|
||||
|
||||
.page-subtitle {
|
||||
font-size: 0.8rem;
|
||||
color: var(--el-text-color-secondary);
|
||||
}
|
||||
|
||||
.breadcrumb {
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
@ -7,7 +7,15 @@
|
||||
</div>
|
||||
|
||||
<div v-if="!pending" class="page-content">
|
||||
<markdown-renderer :content="content.content || ''" />
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div class="html-typography" v-html="contactInfo?.content || ''" />
|
||||
<!-- <div v-if="!hydrated" v-html="contactInfo?.content || ''" /> -->
|
||||
<!-- <div v-else> -->
|
||||
<!-- <html-renderer -->
|
||||
<!-- class="html-typography" -->
|
||||
<!-- :html="contactInfo?.content || ''" -->
|
||||
<!-- /> -->
|
||||
<!-- </div> -->
|
||||
</div>
|
||||
<div v-else class="loading">
|
||||
<el-skeleton :rows="5" animated />
|
||||
@ -17,20 +25,28 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
const localePath = useLocalePath();
|
||||
const hydrated = ref(false);
|
||||
const breadcrumbItems = [
|
||||
{ label: $t('navigation.home'), to: localePath('/') },
|
||||
{ label: $t('navigation.support'), to: localePath('/support') },
|
||||
{ label: $t('navigation.contact-info') },
|
||||
];
|
||||
const { data, pending, error } = await useContactInfo();
|
||||
|
||||
const content = computed(() => toContactInfoView(data.value));
|
||||
const { data: contactInfo, pending, error } = await useContactInfo();
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
const pageTitle = $t('page-title.contact-us');
|
||||
usePageSeo({
|
||||
title: pageTitle,
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
hydrated.value = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -10,12 +10,29 @@
|
||||
<app-breadcrumb class="breadcrumb" :items="breadcrumbItems" />
|
||||
</div>
|
||||
<div class="page-content">
|
||||
<product-filter
|
||||
<document-filter
|
||||
v-model="filters"
|
||||
:product-type-options="productTypeOptions"
|
||||
:product-options="productOptions"
|
||||
:document-type-options="documentTypeOptions"
|
||||
/>
|
||||
|
||||
<document-list
|
||||
:documents="paginatedDocuments"
|
||||
:show-category="
|
||||
filters.selectedDocumentType === null ||
|
||||
filters.selectedDocumentType === undefined
|
||||
"
|
||||
/>
|
||||
|
||||
<el-pagination
|
||||
v-model:current-page="page"
|
||||
class="justify-center pagination-container"
|
||||
layout="prev, pager, next"
|
||||
hide-on-single-page
|
||||
:page-size="documentsPerPage"
|
||||
:total="filteredDocuments.length"
|
||||
/>
|
||||
<document-list :documents="filteredDocuments" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -30,16 +47,34 @@
|
||||
];
|
||||
|
||||
const filters = reactive({
|
||||
selectedType: null as number | null,
|
||||
selectedProduct: null as number | null,
|
||||
selectedDocumentType: null as string | null,
|
||||
selectedProductType: null as string | null,
|
||||
selectedProduct: null as string | null,
|
||||
keyword: '',
|
||||
});
|
||||
|
||||
const { data, pending, error } = await useDocumentList();
|
||||
const page = ref(1);
|
||||
const documentsPerPage = 10;
|
||||
|
||||
const documents = computed(
|
||||
() => data?.value.map((item) => toDocumentListView(item)) ?? []
|
||||
);
|
||||
const { data: documents, pending, error } = await useDocumentList();
|
||||
|
||||
const documentTypeOptions = computed(() => {
|
||||
const types: DocumentTypeView[] = [];
|
||||
documents.value.forEach((doc: DocumentListView) => {
|
||||
if (!types.some((item) => item.id === doc.type.id)) {
|
||||
if (doc.type.id === '-1') {
|
||||
types.push({
|
||||
id: '-1',
|
||||
name: $t('product-filter.misc'),
|
||||
});
|
||||
} else {
|
||||
types.push(doc.type);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return types;
|
||||
});
|
||||
|
||||
const productTypeOptions = computed(() => {
|
||||
const types: DocumentListProductType[] = [];
|
||||
@ -56,13 +91,13 @@
|
||||
});
|
||||
|
||||
const productOptions = computed(() => {
|
||||
if (!filters.selectedType) return [];
|
||||
if (!filters.selectedProductType) return [];
|
||||
const products: DocumentListProduct[] = [];
|
||||
|
||||
documents.value.forEach((doc: DocumentListView) => {
|
||||
doc.products?.forEach((product: DocumentListProduct) => {
|
||||
if (
|
||||
product.type.id === filters.selectedType &&
|
||||
product.type.id === filters.selectedProductType &&
|
||||
!products.some((item) => item.id === product.id)
|
||||
) {
|
||||
products.push(product);
|
||||
@ -73,44 +108,57 @@
|
||||
return products;
|
||||
});
|
||||
|
||||
const filteredDocuments = computed(() =>
|
||||
documents.value.filter((doc: DocumentListView) => {
|
||||
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
|
||||
: filters.selectedProductType
|
||||
? doc.products?.some(
|
||||
(product: DocumentListProduct) =>
|
||||
product.type?.id === filters.selectedType
|
||||
product.type?.id === filters.selectedProductType
|
||||
)
|
||||
: true;
|
||||
|
||||
const matchKeyword = filters.keyword
|
||||
? doc.title && doc.title.includes(filters.keyword)
|
||||
const matchDocumentType = filters.selectedDocumentType
|
||||
? doc.type.id === filters.selectedDocumentType
|
||||
: true;
|
||||
|
||||
return matchProduct && matchKeyword;
|
||||
})
|
||||
return matchProduct && matchDocumentType;
|
||||
});
|
||||
});
|
||||
|
||||
const paginatedDocuments = computed(() => {
|
||||
return filteredDocuments.value.slice(
|
||||
(page.value - 1) * documentsPerPage,
|
||||
page.value * documentsPerPage
|
||||
);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => filters.selectedType,
|
||||
() => filters.selectedProductType,
|
||||
() => {
|
||||
filters.selectedProduct = null;
|
||||
}
|
||||
);
|
||||
|
||||
watch(documents, (value) => {
|
||||
console.log(value);
|
||||
});
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
const pageTitle = $t('page-title.documents');
|
||||
usePageSeo({
|
||||
title: pageTitle,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -135,12 +183,6 @@
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.document-category {
|
||||
padding: 0rem 2rem;
|
||||
gap: 4px;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.page-content {
|
||||
padding: 1rem 2rem 2rem;
|
||||
}
|
||||
@ -155,4 +197,35 @@
|
||||
height: 40px;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
:deep(.el-pagination) {
|
||||
.btn-prev,
|
||||
.btn-next {
|
||||
.el-icon {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.el-pager {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.el-pager li {
|
||||
font-size: 1rem;
|
||||
/* border: 1px solid #409eff; */
|
||||
border-radius: 50%;
|
||||
|
||||
&:hover {
|
||||
background-color: #ecf5ff;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background-color: var(--el-color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -11,13 +11,23 @@
|
||||
</div>
|
||||
|
||||
<div class="page-content">
|
||||
<product-filter
|
||||
<question-filter
|
||||
v-model="filters"
|
||||
:product-type-options="productTypeOptions"
|
||||
:product-options="productOptions"
|
||||
:question-type-options="questionTypeOptions"
|
||||
/>
|
||||
|
||||
<question-list :questions="filteredQuestions" />
|
||||
<question-list :questions="paginatedQuestions" />
|
||||
|
||||
<el-pagination
|
||||
v-model:current-page="page"
|
||||
class="justify-center pagination-container"
|
||||
layout="prev, pager, next"
|
||||
hide-on-single-page
|
||||
:page-size="questionsPerPage"
|
||||
:total="filteredQuestions.length"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -25,24 +35,46 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
const localePath = useLocalePath();
|
||||
const route = useRoute();
|
||||
|
||||
const filters = reactive({
|
||||
selectedType: null as number | null,
|
||||
selectedProduct: null as number | null,
|
||||
selectedQuestionType: null as string | null,
|
||||
selectedProduct: null as string | null,
|
||||
selectedProductType: null as string | null,
|
||||
keyword: '',
|
||||
});
|
||||
|
||||
const page = ref(1);
|
||||
const questionsPerPage = 10;
|
||||
|
||||
const focusQuestionId = ref<string | null>(
|
||||
route.query.focus as string | null
|
||||
);
|
||||
|
||||
const breadcrumbItems = [
|
||||
{ label: $t('navigation.home'), to: localePath('/') },
|
||||
{ label: $t('navigation.support'), to: localePath('/support') },
|
||||
{ label: $t('navigation.faq') },
|
||||
];
|
||||
|
||||
const { data, pending, error } = await useQuestionList();
|
||||
const { data: questions, pending, error } = await useQuestionList();
|
||||
|
||||
const questions = computed(
|
||||
() => data.value.map((item) => toQuestionListView(item)) ?? null
|
||||
);
|
||||
const questionTypeOptions = computed(() => {
|
||||
const types: QuestionTypeView[] = [];
|
||||
questions.value.forEach((q: QuestionListView) => {
|
||||
if (!types.some((t) => t.id === q.type.id)) {
|
||||
if (q.type.id === '-1') {
|
||||
types.push({
|
||||
id: '-1',
|
||||
name: $t('product-filter.misc'),
|
||||
});
|
||||
} else {
|
||||
types.push(q.type);
|
||||
}
|
||||
}
|
||||
});
|
||||
return types;
|
||||
});
|
||||
|
||||
const productTypeOptions = computed(() => {
|
||||
const types: QuestionListProductType[] = [];
|
||||
@ -58,12 +90,12 @@
|
||||
});
|
||||
|
||||
const productOptions = computed(() => {
|
||||
if (!filters.selectedType) return [];
|
||||
if (!filters.selectedProductType) return [];
|
||||
const products: QuestionListProduct[] = [];
|
||||
questions.value.forEach((q: QuestionListView) => {
|
||||
q.products.forEach((product: QuestionListProduct) => {
|
||||
if (
|
||||
product.type.id === filters.selectedType &&
|
||||
product.type.id === filters.selectedProductType &&
|
||||
!products.some((p) => p.id === product.id)
|
||||
) {
|
||||
products.push(product);
|
||||
@ -74,44 +106,77 @@
|
||||
});
|
||||
|
||||
const filteredQuestions = computed(() => {
|
||||
return questions.value.filter((question: QuestionListView) => {
|
||||
const fuzzyMatchedQuestions = fuzzyMatch(questions.value, {
|
||||
keyword: filters.keyword,
|
||||
keys: ['title'],
|
||||
threshold: 0.6,
|
||||
});
|
||||
return fuzzyMatchedQuestions.filter((question: QuestionListView) => {
|
||||
const matchProduct = filters.selectedProduct
|
||||
? question.products?.some(
|
||||
(product: QuestionListProduct) =>
|
||||
product.id === filters.selectedProduct
|
||||
)
|
||||
: filters.selectedType
|
||||
: filters.selectedProductType
|
||||
? question.products?.some(
|
||||
(product: QuestionListProduct) =>
|
||||
product.type.id === filters.selectedType
|
||||
product.type.id === filters.selectedProductType
|
||||
)
|
||||
: true;
|
||||
|
||||
const matchKeyword = filters.keyword
|
||||
? (question.title && question.title.includes(filters.keyword)) ||
|
||||
(question.content && question.content.includes(filters.keyword))
|
||||
const matchQuestionType = filters.selectedQuestionType
|
||||
? question.type.id === filters.selectedQuestionType
|
||||
: true;
|
||||
|
||||
return matchProduct && matchKeyword;
|
||||
return matchProduct && matchQuestionType;
|
||||
});
|
||||
});
|
||||
|
||||
const paginatedQuestions = computed(() => {
|
||||
const start = (page.value - 1) * questionsPerPage;
|
||||
const end = page.value * questionsPerPage;
|
||||
return filteredQuestions.value.slice(start, end);
|
||||
});
|
||||
|
||||
watch(
|
||||
() => filters.selectedType,
|
||||
focusQuestionId,
|
||||
async (focusId) => {
|
||||
if (!focusId) return;
|
||||
if (!import.meta.client) return;
|
||||
|
||||
await nextTick();
|
||||
|
||||
const question = filteredQuestions.value.find((q) => q.id === focusId);
|
||||
if (!question) return;
|
||||
|
||||
const targetIndex = filteredQuestions.value.indexOf(question);
|
||||
const targetPage = Math.floor(targetIndex / questionsPerPage) + 1;
|
||||
onMounted(() => {
|
||||
if (page.value !== targetPage) {
|
||||
page.value = targetPage;
|
||||
}
|
||||
});
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => filters.selectedProductType,
|
||||
() => {
|
||||
filters.selectedProduct = null;
|
||||
}
|
||||
);
|
||||
|
||||
watch(data, (newVal) => {
|
||||
console.log('useAsyncData updated:', newVal);
|
||||
});
|
||||
|
||||
watch(error, (value) => {
|
||||
if (value) {
|
||||
console.error('数据获取失败: ', value);
|
||||
logger.error('数据获取失败: ', value);
|
||||
}
|
||||
});
|
||||
|
||||
const pageTitle = $t('page-title.faq');
|
||||
usePageSeo({
|
||||
title: pageTitle,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
@ -139,4 +204,34 @@
|
||||
.page-content {
|
||||
padding: 1rem 2rem 2rem;
|
||||
}
|
||||
.pagination-container {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
:deep(.el-pagination) {
|
||||
.btn-prev,
|
||||
.btn-next {
|
||||
.el-icon {
|
||||
font-size: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
.el-pager {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.el-pager li {
|
||||
font-size: 1rem;
|
||||
/* border: 1px solid #409eff; */
|
||||
border-radius: 50%;
|
||||
|
||||
&:hover {
|
||||
background-color: #ecf5ff;
|
||||
}
|
||||
|
||||
&.is-active {
|
||||
background-color: var(--el-color-primary);
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -52,6 +52,11 @@
|
||||
iconComponent: ElIconService,
|
||||
},
|
||||
];
|
||||
|
||||
const pageTitle = $t('page-title.support');
|
||||
usePageSeo({
|
||||
title: pageTitle,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import { createDirectus, rest, staticToken } from '@directus/sdk';
|
||||
import { createDirectus, rest, staticToken, graphql } from '@directus/sdk';
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
const config = useRuntimeConfig();
|
||||
|
||||
const directus = createDirectus<Schema>(config.public.directus.url)
|
||||
.with(rest())
|
||||
.with(graphql())
|
||||
.with(staticToken(config.public.directus.token || ''));
|
||||
return {
|
||||
provide: { directus },
|
||||
|
||||
45
app/utils/autoMap.ts
Normal file
45
app/utils/autoMap.ts
Normal file
@ -0,0 +1,45 @@
|
||||
async function testSpeed(url: string, timeout = 1500) {
|
||||
const start = performance.now();
|
||||
|
||||
try {
|
||||
await Promise.race([
|
||||
fetch(url, { method: 'HEAD', mode: 'no-cors' }),
|
||||
new Promise((_, reject) => setTimeout(() => reject('timeout'), timeout)),
|
||||
]);
|
||||
|
||||
return performance.now() - start;
|
||||
} catch {
|
||||
return Infinity; // unreachable or timed out
|
||||
}
|
||||
}
|
||||
|
||||
async function selectBestMap() {
|
||||
const testTargets = {
|
||||
// amap: 'https://www.amap.com/favicon.ico',
|
||||
baidu: 'https://map.baidu.com/favicon.ico',
|
||||
google: 'https://maps.google.com/favicon.ico',
|
||||
};
|
||||
|
||||
const results: Record<string, number> = {};
|
||||
|
||||
for (const key in testTargets) {
|
||||
results[key] = await testSpeed(testTargets[key]);
|
||||
}
|
||||
|
||||
logger.debug(results);
|
||||
|
||||
// 根据延迟排序,选择最稳最快的平台
|
||||
return Object.entries(results).sort((a, b) => a[1] - b[1])[0][0];
|
||||
}
|
||||
|
||||
export async function getAutoMappedService(): Promise<string> {
|
||||
const target = {
|
||||
// amap: 'https://surl.amap.com/2dYNorIJ1dgoN',
|
||||
baidu: 'https://j.map.baidu.com/f9/c3x',
|
||||
google: 'https://maps.app.goo.gl/9LqvMwEq7VaRkqnM6',
|
||||
};
|
||||
|
||||
const fastestMap = await selectBestMap();
|
||||
|
||||
return target[fastestMap];
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
import { expect, test, describe } from 'vitest';
|
||||
import { formatFileSize, getFileExtension, formatFileExtension } from './file';
|
||||
|
||||
/**
|
||||
* 单元测试: formatFileSize
|
||||
|
||||
108
app/utils/fuzzyFilter.ts
Normal file
108
app/utils/fuzzyFilter.ts
Normal file
@ -0,0 +1,108 @@
|
||||
import Fuse from 'fuse.js';
|
||||
|
||||
interface FuzzyFilterOptions<T> {
|
||||
/** 匹配关键字 */
|
||||
keyword: string;
|
||||
|
||||
/** 搜索字段 */
|
||||
keys: Array<FuzzyKeyOf<T>>;
|
||||
|
||||
/** 模糊程度 (0~1,越低越严格) */
|
||||
threshold?: number;
|
||||
|
||||
/** 最小匹配字符数 */
|
||||
minMatchCharLength?: number;
|
||||
|
||||
/** 当前语言 */
|
||||
locale?: string;
|
||||
}
|
||||
|
||||
/** 限定 keys 只能选择字符串字段 */
|
||||
type FuzzyKeyOf<T> = {
|
||||
[K in keyof T]: T[K] extends string ? K : never;
|
||||
}[keyof T];
|
||||
|
||||
export function fuzzyMatch<T extends object>(
|
||||
source: T[],
|
||||
options: FuzzyFilterOptions<T>
|
||||
): T[] {
|
||||
const { keyword, keys, threshold = 0.35, minMatchCharLength = 1 } = options;
|
||||
|
||||
// --- 文本标准化函数 ---
|
||||
const normalizeText = (text: string): string => {
|
||||
const normalizedText = text.normalize('NFKC').toLowerCase().trim();
|
||||
return normalizedText;
|
||||
};
|
||||
|
||||
/**
|
||||
* 类型安全的对象取值函数
|
||||
*/
|
||||
function getPropertyByPath<T>(
|
||||
obj: T,
|
||||
path: string | string[]
|
||||
): string | undefined {
|
||||
const keys = Array.isArray(path) ? path : path.split('.');
|
||||
let value: unknown = obj;
|
||||
for (const key of keys) {
|
||||
if (value && typeof value === 'object' && key in value) {
|
||||
value = (value as Record<string, unknown>)[key];
|
||||
} else {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
return typeof value === 'string' ? value : undefined;
|
||||
}
|
||||
|
||||
// --- fallback 模糊匹配算法 ---
|
||||
const fallbackFuzzyMatch = (text: string, pattern: string): boolean => {
|
||||
const normalizedText = normalizeText(text);
|
||||
const normalizedPattern = normalizeText(pattern);
|
||||
let i = 0;
|
||||
for (const char of normalizedPattern) {
|
||||
i = normalizedText.indexOf(char, i);
|
||||
if (i === -1) return false;
|
||||
i++;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const k = keyword.trim();
|
||||
|
||||
if (!k) {
|
||||
return source;
|
||||
}
|
||||
|
||||
if (import.meta.client) {
|
||||
// 客户端使用Fuze.js进行模糊匹配
|
||||
const fuse = new Fuse<T>(source, {
|
||||
keys: keys as string[],
|
||||
threshold,
|
||||
minMatchCharLength,
|
||||
ignoreLocation: true,
|
||||
findAllMatches: true,
|
||||
isCaseSensitive: false,
|
||||
getFn: (obj, path) => {
|
||||
const value = getPropertyByPath(obj, path);
|
||||
if (typeof value === 'string') {
|
||||
const normalized = value
|
||||
.normalize('NFKC')
|
||||
.replace(/\s+/g, '')
|
||||
.toLowerCase()
|
||||
.trim();
|
||||
return normalized;
|
||||
}
|
||||
return value;
|
||||
},
|
||||
});
|
||||
|
||||
const result = fuse.search(k);
|
||||
return result.map((result) => result.item);
|
||||
}
|
||||
|
||||
return source.filter((item) =>
|
||||
keys.some((key) => {
|
||||
const value = item[key];
|
||||
return typeof value === 'string' ? fallbackFuzzyMatch(value, k) : false;
|
||||
})
|
||||
);
|
||||
}
|
||||
30
app/utils/htmlDefaultMap.ts
Normal file
30
app/utils/htmlDefaultMap.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import type { HtmlRenderMap } from '@/composables/useHtmlRenderer';
|
||||
import { h } from 'vue';
|
||||
import MarkdownTable from '@/components/shared/MarkdownTable.vue';
|
||||
|
||||
export const defaultHtmlRenderMap: HtmlRenderMap = {
|
||||
h1: (_, children) => h('h1', {}, children),
|
||||
|
||||
h2: (_, children) => h('h2', {}, children),
|
||||
|
||||
p: (_, children) => h('p', {}, children),
|
||||
|
||||
// table: (_, children) => h('div', {}, [h('table', {}, children)]),
|
||||
table: (node) => {
|
||||
const { headers, rows } = parseHtmlTable(node);
|
||||
|
||||
return h(
|
||||
'div',
|
||||
{},
|
||||
h(MarkdownTable, {
|
||||
headers,
|
||||
rows,
|
||||
})
|
||||
);
|
||||
},
|
||||
|
||||
img: (node) =>
|
||||
h('img', {
|
||||
src: node.attribs?.src,
|
||||
}),
|
||||
};
|
||||
@ -18,17 +18,3 @@ export function renderMarkdown(content: string): string {
|
||||
|
||||
return dirtyHtml;
|
||||
}
|
||||
|
||||
export function convertMedia(content: string): string {
|
||||
// 通过正则表达式替换Markdown中的图片链接
|
||||
//  -> )
|
||||
|
||||
if (!content) return '';
|
||||
|
||||
const contentWithAbsoluteUrls = content.replace(
|
||||
/!\[([^\]]*)\]\((\/uploads\/[^)]+)\)/g,
|
||||
(_, alt, url) => `})`
|
||||
);
|
||||
|
||||
return contentWithAbsoluteUrls;
|
||||
}
|
||||
|
||||
90
app/utils/parseTable.ts
Normal file
90
app/utils/parseTable.ts
Normal file
@ -0,0 +1,90 @@
|
||||
import type { Element, Node } from 'domhandler';
|
||||
|
||||
export interface ParsedTable {
|
||||
headers: string[];
|
||||
rows: Record<string, string>[];
|
||||
}
|
||||
|
||||
const isElement = (n: Node): n is Element => n.type === 'tag';
|
||||
|
||||
export function parseHtmlTable(table: Element): ParsedTable {
|
||||
if (table.name !== 'table') {
|
||||
throw new Error('parseHtmlTable: node is not <table>');
|
||||
}
|
||||
// 获取 table 下的所有 tag 子节点
|
||||
const getChildren = (node: Node): Element[] =>
|
||||
isElement(node) ? node.children.filter(isElement) : [];
|
||||
|
||||
// ---- 找 thead / tbody ----
|
||||
const children = getChildren(table);
|
||||
const thead = children.find((n) => n.name === 'thead');
|
||||
const tbody = children.find((n) => n.name === 'tbody');
|
||||
|
||||
if (!tbody) {
|
||||
return { headers: [], rows: [] };
|
||||
}
|
||||
|
||||
const bodyRows = getChildren(tbody).filter((n) => n.name === 'tr');
|
||||
|
||||
if (bodyRows.length === 0) {
|
||||
return { headers: [], rows: [] };
|
||||
}
|
||||
// ---- 1. 表头 ----
|
||||
let headerCells: Element[] = [];
|
||||
|
||||
if (thead) {
|
||||
// 如果 Directus 有 thead(一般不会)
|
||||
const headerRow = getChildren(thead).find((n) => n.name === 'tr');
|
||||
headerCells = headerRow
|
||||
? getChildren(headerRow).filter((n) => n.name === 'th' || n.name === 'td')
|
||||
: [];
|
||||
} else {
|
||||
// Directus 情况:没有 thead → 用 tbody 第一行作为 header
|
||||
headerCells = getChildren(bodyRows[0]).filter(
|
||||
(n) => n.name === 'th' || n.name === 'td'
|
||||
);
|
||||
}
|
||||
|
||||
logger.info(headerCells);
|
||||
|
||||
const headers = headerCells.map((cell, i) => {
|
||||
const text = cell.children
|
||||
.filter((c) => c.type === 'text')
|
||||
.map((t) => t.data.trim())
|
||||
.filter(Boolean)
|
||||
.join('');
|
||||
return text || `列${i + 1}`;
|
||||
});
|
||||
|
||||
// ---- 2. 数据行 ----
|
||||
// 如果没有 thead,则跳过第一行(它是 header)
|
||||
const dataRows = thead ? bodyRows : bodyRows.slice(1);
|
||||
|
||||
const rows = dataRows.map((row) => {
|
||||
const cells = getChildren(row).filter(
|
||||
(n) => n.name === 'td' || n.name === 'th'
|
||||
);
|
||||
|
||||
const record: Record<string, string> = {};
|
||||
|
||||
headers.forEach((header, i) => {
|
||||
const cell = cells[i];
|
||||
if (!cell) {
|
||||
record[header] = '';
|
||||
} else {
|
||||
const text = cell.children
|
||||
.filter((c) => c.type === 'text')
|
||||
.map((t) => t.data.trim())
|
||||
.filter(Boolean)
|
||||
.join('');
|
||||
record[header] = text;
|
||||
}
|
||||
});
|
||||
|
||||
return record;
|
||||
});
|
||||
|
||||
logger.info(headers, rows);
|
||||
|
||||
return { headers, rows };
|
||||
}
|
||||
63
docker-build.sh
Executable file
63
docker-build.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ========== 脚本配置 ==========
|
||||
#
|
||||
IMAGE_NAME="git.jinshen.cn/remilia/jinshen-website" # 含仓库前缀的镜像名称
|
||||
DOCKERFILE="Dockerfile" # Dockerfile 文件路径
|
||||
BUILD_CONTEXT="." # 构建上下文路径
|
||||
PUSH_IMAGE=true # 是否推送镜像到远程仓库
|
||||
DOCKER_LOGIN=false # 是否需要登录 Docker 仓库
|
||||
REGISTRY_USER="" #Docker 仓库用户名
|
||||
REGISTRY_PASSWORD="" #Docker 仓库密码
|
||||
|
||||
# ==============================
|
||||
|
||||
# 生成时间戳TAG
|
||||
TIMESTAMP_TAG=$(date +'%Y%m%d%H%M%S')
|
||||
BUILD_TIME=$(date +"%Y-%m-%d %H:%M:%S")
|
||||
GIT_COMMIT=$(git rev-parse --short HEAD || echo "unknown")
|
||||
|
||||
echo "📦 构建镜像: ${IMAGE_NAME}"
|
||||
echo "⏱️ 时间戳标签: ${TIMESTAMP_TAG}"
|
||||
echo "🔖 Git 提交: ${GIT_COMMIT}"
|
||||
echo "⭐ 同时构建 latest 标签"
|
||||
|
||||
# docker login(如果启用)
|
||||
if [ "$DOCKER_LOGIN" = true ]; then
|
||||
if [ -z "$REGISTRY_PASSWORD" ]; then
|
||||
echo "❌ 登录失败:启用了 DOCKER_LOGIN,但 REGISTRY_PASSWORD 为空"
|
||||
exit 1
|
||||
fi
|
||||
echo "🔐 正在登录 Docker Registry..."
|
||||
echo "$REGISTRY_PASSWORD" | docker login "$(echo "$IMAGE_NAME" | cut -d'/' -f1)" \
|
||||
--username "$REGISTRY_USER" --password-stdin
|
||||
fi
|
||||
|
||||
# 根据是否推送决定 buildx 参数
|
||||
if [ "$PUSH_IMAGE" = true ]; then
|
||||
BUILDX_MODE="--push"
|
||||
echo "🚀 将构建并推送镜像到仓库"
|
||||
else
|
||||
BUILDX_MODE="--load"
|
||||
echo "🛠️ 仅本地构建镜像(不推送)"
|
||||
fi
|
||||
|
||||
# 构建镜像(带 version metadata)
|
||||
docker buildx build \
|
||||
-t "${IMAGE_NAME}:${TIMESTAMP_TAG}" \
|
||||
-t "${IMAGE_NAME}:latest" \
|
||||
--build-arg BUILD_TIME="$BUILD_TIME" \
|
||||
--build-arg GIT_COMMIT="$GIT_COMMIT" \
|
||||
-f "$DOCKERFILE" "$BUILD_CONTEXT" \
|
||||
$BUILDX_MODE
|
||||
|
||||
|
||||
echo "🎉 镜像构建完成!"
|
||||
echo "📌 可用镜像:"
|
||||
echo " - ${IMAGE_NAME}:${TIMESTAMP_TAG}"
|
||||
echo " - ${IMAGE_NAME}:latest"
|
||||
|
||||
if [ "$PUSH_IMAGE" = false ]; then
|
||||
echo "⚠️ 镜像未推送(PUSH_IMAGE=false)"
|
||||
fi
|
||||
13
docker-compose.test.yml
Normal file
13
docker-compose.test.yml
Normal file
@ -0,0 +1,13 @@
|
||||
services:
|
||||
website:
|
||||
image: git.jinshen.cn/remilia/jinshen-website
|
||||
container_name: webService
|
||||
restart: unless-stopped
|
||||
env_file: .env
|
||||
environment:
|
||||
NUXT_PUBLIC_DIRECTUS_URL: ${DIRECTUS_URL}
|
||||
NUXT_PUBLIC_DIRECTUS_TOKEN: ${DIRECTUS_TOKEN}
|
||||
NUXT_PUBLIC_MEILI_HOST: ${MEILI_HOST}
|
||||
NUXT_PUBLIC_MEILI_SEARCH_KEY: ${MEILI_MASTER_KEY}
|
||||
ports:
|
||||
- 3200:3000
|
||||
9
entrypoint.sh
Normal file
9
entrypoint.sh
Normal file
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
echo "Starting Nuxt App..."
|
||||
if [ -f "/app/version.json" ]; then
|
||||
echo "Version info:"
|
||||
cat /app/version.json
|
||||
else
|
||||
echo "⚠️ version.json not found!"
|
||||
fi
|
||||
exec "$@"
|
||||
@ -13,6 +13,7 @@ export default withNuxt(
|
||||
},
|
||||
},
|
||||
],
|
||||
'no-console': 'warn',
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
"result-count": "{count} results",
|
||||
"no-results": "No results found for \"{query}\".",
|
||||
"no-query": "Enter a keyword to start searching.",
|
||||
"section": "Section",
|
||||
"untitled": "Untitled",
|
||||
"sections": {
|
||||
"product": "Products",
|
||||
@ -22,8 +23,8 @@
|
||||
"company-name": "Jinshen Machinary Manufacturing Co., Ltd.",
|
||||
"company-description": "We specialize in manufacturing a range of paper tube and can equipment, integrating design, manufacturing, sales, and service.",
|
||||
"learn-more": "Learn More",
|
||||
"products-desc": "We provide high-quality product solutions to meet various business needs.",
|
||||
"solutions-desc": "Providing customized technology solutions for enterprises to accelerate digital transformation.",
|
||||
"products-desc": "We provide the latest products an instant service support to meet various business needs of our customers.",
|
||||
"solutions-desc": "We offer diversified technical solutions for enterprises, supporting various fields such as industry and packaging.",
|
||||
"support-desc": "24/7 professional technical support to ensure stable operation of your business.",
|
||||
"quick-links": "Quick Links",
|
||||
"utilities": "Utilities",
|
||||
@ -37,7 +38,8 @@
|
||||
"downloads": "Downloads",
|
||||
"faq": "FAQ",
|
||||
"documents": "Documents",
|
||||
"calculator": "Calculator"
|
||||
"calculator": "Calculator",
|
||||
"address": "Company Address"
|
||||
},
|
||||
"contact-info": "Contact Us",
|
||||
"telephone": "Telephone",
|
||||
@ -61,7 +63,9 @@
|
||||
"back-to-home": "Back to Home",
|
||||
"no-content-available": "No detailed information available",
|
||||
"loading": "Loading...",
|
||||
"our-products": "Our Products",
|
||||
"our-products": "Our Latest Products",
|
||||
"find-discontinued-products": "To find discontinued products, please use the search function.",
|
||||
"product-discontinued-warning": "Product is discontinued and may no longer receive immediate support or updates",
|
||||
"learn-our-solutions": "Learn Our Solutions",
|
||||
"all": "All",
|
||||
"support-page-desc": "Zhejiang Jinshen Machinery Manufacturing Co., Ltd is committed to providing high-quality products and services to our customers. For products such as paper tube machines, slitting machines, and paper straw equipment, we offer comprehensive after-sales support to ensure our customers can use our products with confidence.",
|
||||
@ -77,7 +81,12 @@
|
||||
"keyword": "Keyword",
|
||||
"select-product-type": "Select product type",
|
||||
"select-product-model": "Select product model",
|
||||
"enter-keyword": "Enter keyword"
|
||||
"enter-keyword": "Enter keyword",
|
||||
"question-type": "Question Type",
|
||||
"select-question-type": "Select question type",
|
||||
"document-type": "Document Type",
|
||||
"select-document-type": "Select document type",
|
||||
"misc": "Misc"
|
||||
},
|
||||
"document-meta": {
|
||||
"size": "Size",
|
||||
@ -100,5 +109,23 @@
|
||||
"recommended-products-desc": "Explore our curated selection of products to meet your diverse needs. Whether it's innovative technology or classic designs, we offer quality choices for you.",
|
||||
"recommended-solutions": "Recommended Solutions",
|
||||
"recommended-solutions-desc": "Learn about our tailored solutions designed to help your business thrive in a competitive market."
|
||||
},
|
||||
"page-title": {
|
||||
"homepage": "Homepage",
|
||||
"products": "Products",
|
||||
"solutions": "Solutions",
|
||||
"support": "Support",
|
||||
"faq": "FAQ",
|
||||
"documents": "Documents",
|
||||
"contact-us": "Contact Us",
|
||||
"download": "Downloads",
|
||||
"preview": "Preview",
|
||||
"about-us": "About Us"
|
||||
},
|
||||
"product-tab": {
|
||||
"details": "Details",
|
||||
"specs": "Specifications",
|
||||
"faq": "FAQ",
|
||||
"documents": "Documents"
|
||||
}
|
||||
}
|
||||
|
||||
130
i18n/locales/es.json
Normal file
130
i18n/locales/es.json
Normal file
@ -0,0 +1,130 @@
|
||||
{
|
||||
"back": "Volver",
|
||||
"not-found": "Página no encontrada",
|
||||
"search-placeholder": "Buscar...",
|
||||
"search": {
|
||||
"title": "Búsqueda en el sitio",
|
||||
"head-title": "Búsqueda",
|
||||
"search-button": "Buscar",
|
||||
"results-for": "Resultados de la búsqueda para \"{query}\"",
|
||||
"result-count": "{count} resultados",
|
||||
"no-results": "No se encontraron coincidencias para \"{query}\".",
|
||||
"no-query": "Ingrese una palabra clave para comenzar a buscar.",
|
||||
"section": "sección",
|
||||
"untitled": "sin título",
|
||||
"sections": {
|
||||
"product": "Productos",
|
||||
"solution": "Soluciones",
|
||||
"faq": "FAQ",
|
||||
"document": "Documentaciones",
|
||||
"default": "Otros contenidos"
|
||||
}
|
||||
},
|
||||
"company-name": "Jinshen Machinary Manufacturing Co., Ltd.",
|
||||
"company-description": "Especializado en la producción de una serie de equipos de tubos y latas de papel, integrando diseño, fabricación, ventas y servicio.",
|
||||
"learn-more": "Saber más",
|
||||
"products-desc": "Ofrecemos los últimos productos y un servicio de asistencia instantáneo para satisfacer las diversas necesidades comerciales de nuestros clientes.",
|
||||
"solutions-desc": "Ofrecemos soluciones técnicas diversificadas para empresas, prestando apoyo en diversos campos, como la industria y el embalaje.",
|
||||
"support-desc": "Soporte técnico profesional 24/7, asegurando la estabilidad de su negocio.",
|
||||
"quick-links": "Enlaces rápidos",
|
||||
"utilities": "Herramientas útiles",
|
||||
"navigation": {
|
||||
"home": "Inicio",
|
||||
"products": "Productos",
|
||||
"solutions": "Soluciones",
|
||||
"support": "Soporte",
|
||||
"about-us": "Sobre nosotros",
|
||||
"contact-info": "Información de contacto",
|
||||
"downloads": "Descargas",
|
||||
"faq": "FAQ",
|
||||
"documents": "Documentaciones",
|
||||
"calculator": "Herramienta de cálculo de tubos de papel",
|
||||
"address": "Dirección de la empresa"
|
||||
},
|
||||
"contact-info": "Contáctenos",
|
||||
"telephone": "Teléfono",
|
||||
"email": "Correo electrónico",
|
||||
"address": "Dirección",
|
||||
"company-address": "No. 689 Qiushi Road, Wutong Industrial Zone, Tongxiang City, Zhejiang Province, China",
|
||||
"follow-us": "Síguenos",
|
||||
"all-rights-reserved": "All rights reserved",
|
||||
"privacy-policy": "Política de privacidad",
|
||||
"terms-of-service": "Términos del servicio",
|
||||
"sitemap": "Mapa del sitio",
|
||||
"product-details": "Detalles del producto",
|
||||
"product-not-found": "Producto no encontrado",
|
||||
"product-not-found-desc": "Lo sentimos, el producto que busca no existe o ha sido eliminado.",
|
||||
"back-to-products": "Volver a la lista de productos",
|
||||
"solution-not-found": "Solución no encontrada",
|
||||
"solution-not-found-desc": "Lo sentimos, la solución que busca no existe o ha sido eliminada.",
|
||||
"back-to-solutions": "Volver a la lista de soluciones",
|
||||
"page-not-found": "Página no encontrada",
|
||||
"page-not-found-desc": "Lo sentimos, la página que busca no existe o ha sido eliminada.",
|
||||
"back-to-home": "Volver al inicio",
|
||||
"no-content-available": "No hay información disponible",
|
||||
"loading": "Cargando...",
|
||||
"our-products": "Nuestros últimos productos",
|
||||
"find-discontinued-products": "Para encontrar productos descatalogados, utilice la función de búsqueda.",
|
||||
"product-discontinued-warning": "Este producto ha sido descontinuado y puede que ya no reciba soporte o actualizaciones inmediatas.",
|
||||
"learn-our-solutions": "Aprenda sobre nuestras soluciones",
|
||||
"all": "Todo",
|
||||
"support-page-desc": "Zhejiang Jinshen Machinery Manufacturing Co., Ltd se dedica a proporcionar productos y servicios de alta calidad a los clientes. Para máquinas de tubos de papel, máquinas de corte y pajitas de papel, ofrecemos un servicio postventa integral para garantizar que los clientes puedan usar nuestros productos con confianza.",
|
||||
"support-card-desc": {
|
||||
"faq": "Hemos compilado respuestas a preguntas frecuentes para ayudarle a resolver dudas rápidamente.",
|
||||
"documents": "Proporcionamos manuales de productos, especificaciones técnicas y otros documentos para la comodidad del usuario.",
|
||||
"contact-info": "Contáctenos por teléfono o correo electrónico, y le brindaremos servicio presencial."
|
||||
},
|
||||
"product-filter": {
|
||||
"product-type": "Tipo de producto",
|
||||
"product-model": "Modelo del producto",
|
||||
"keyword": "Palabra clave",
|
||||
"select-product-type": "Seleccione el tipo de producto",
|
||||
"select-product-model": "Seleccione modelo de producto",
|
||||
"enter-keyword": "Ingrese palabra clave",
|
||||
"misc": "Varios",
|
||||
"document-type": "Tipo de documento",
|
||||
"select-document-type": "Seleccionar tipo de documento",
|
||||
"question-type": "Tipo de pregunta",
|
||||
"select-question-type": "Seleccionar tipo de pregunta"
|
||||
},
|
||||
"document-meta": {
|
||||
"size": "Tamaño",
|
||||
"format": "Formato",
|
||||
"type": "Tipo",
|
||||
"upload-at": "Fecha de carga"
|
||||
},
|
||||
"document-action": {
|
||||
"download": "Descargar",
|
||||
"open-in-new-tab": "Abrir en una nueva pestaña",
|
||||
"preview": "Vista previa"
|
||||
},
|
||||
"mobile-menu": {
|
||||
"title": "Menú",
|
||||
"navigation": "Navegación del sitio",
|
||||
"utilities": "Herramientas útiles"
|
||||
},
|
||||
"homepage": {
|
||||
"recommended-products": "Productos recomendados",
|
||||
"recommended-products-desc": "Explore nuestros productos seleccionados para satisfacer sus diversas necesidades. Ya sea tecnología innovadora o diseño clásico, ofrecemos opciones de calidad para usted.",
|
||||
"recommended-solutions": "Soluciones recomendadas",
|
||||
"recommended-solutions-desc": "Aprenda sobre nuestras soluciones personalizadas, que le ayudarán a optimizar sus procesos de negocio y mejorar la eficiencia."
|
||||
},
|
||||
"page-title": {
|
||||
"homepage": "Página principal",
|
||||
"products": "Productos",
|
||||
"solutions": "Soluciones",
|
||||
"support": "Soporte",
|
||||
"faq": "FAQ",
|
||||
"documents": "Documentos",
|
||||
"contact-us": "Contáctenos",
|
||||
"download": "Descarga de documentos",
|
||||
"preview": "Vista previa de documentos",
|
||||
"about-us": "Sobre nosotros"
|
||||
},
|
||||
"product-tab": {
|
||||
"details": "Detalles",
|
||||
"specs": "Especificaciones",
|
||||
"faq": "FAQ",
|
||||
"documents": "Documentos"
|
||||
}
|
||||
}
|
||||
130
i18n/locales/ru.json
Normal file
130
i18n/locales/ru.json
Normal file
@ -0,0 +1,130 @@
|
||||
{
|
||||
"back": "Назад",
|
||||
"not-found": "Страница не найдена",
|
||||
"search-placeholder": "Поиск...",
|
||||
"search": {
|
||||
"title": "Поиск на сайте",
|
||||
"head-title": "Поиск",
|
||||
"search-button": "Поиск",
|
||||
"results-for": "Результаты поиска для \"{query}\"",
|
||||
"result-count": "Всего {count} результатов",
|
||||
"no-results": "Ничего не найдено по запросу \"{query}\".",
|
||||
"no-query": "Введите ключевые слова для начала поиска.",
|
||||
"section": "раздел",
|
||||
"untitled": "Без названия",
|
||||
"sections": {
|
||||
"product": "Продукты",
|
||||
"solution": "Решения",
|
||||
"faq": "Часто задаваемые вопросы",
|
||||
"document": "Документация",
|
||||
"default": "Другие материалы"
|
||||
}
|
||||
},
|
||||
"company-name": "Jinshen Machinary Manufacturing Co., Ltd.",
|
||||
"company-description": "Профессионально производим оборудование для бумажных трубок и канистр, услуги по проектированию, производству, продаже и сервисному обслуживанию.",
|
||||
"learn-more": "Узнать больше",
|
||||
"products-desc": "Мы предоставляем новейшие продукты и мгновенную сервисную поддержку для удовлетворения различных бизнес-потребностей наших клиентов.",
|
||||
"solutions-desc": "Мы предлагаем разнообразные технические решения для предприятий, поддерживая различные области, такие как промышленность и упаковка.",
|
||||
"support-desc": "Профессиональная техническая поддержка 24/7, обеспечивающая стабильную работу вашего бизнеса.",
|
||||
"quick-links": "Быстрые ссылки",
|
||||
"utilities": "Полезные инструменты",
|
||||
"navigation": {
|
||||
"home": "Главная",
|
||||
"products": "Центр продуктов",
|
||||
"solutions": "Решения",
|
||||
"support": "Поддержка",
|
||||
"about-us": "О нас",
|
||||
"contact-info": "Контактная информация",
|
||||
"downloads": "Файлы для скачивания",
|
||||
"faq": "Часто задаваемые вопросы",
|
||||
"documents": "Документация",
|
||||
"calculator": "Калькулятор бумажных трубок",
|
||||
"address": "Адрес компании"
|
||||
},
|
||||
"contact-info": "Свяжитесь с нами",
|
||||
"telephone": "Телефон",
|
||||
"email": "Электронная почта",
|
||||
"address": "Адрес",
|
||||
"company-address": "No. 689 Qiushi Road, Wutong Industrial Zone, Tongxiang City, Zhejiang Province, China",
|
||||
"follow-us": "Следуйте за нами",
|
||||
"all-rights-reserved": "All rights reserved",
|
||||
"privacy-policy": "Политика конфиденциальности",
|
||||
"terms-of-service": "Условия обслуживания",
|
||||
"sitemap": "Карта сайта",
|
||||
"product-details": "Детали продукта",
|
||||
"product-not-found": "Продукт не найден",
|
||||
"product-not-found-desc": "Извините, продукт, который вы ищете, не существует или был удален.",
|
||||
"back-to-products": "Вернуться к списку продуктов",
|
||||
"solution-not-found": "Решение не найдено",
|
||||
"solution-not-found-desc": "Извините, решение, которое вы ищете, не существует или было удалено.",
|
||||
"back-to-solutions": "Вернуться к списку решений",
|
||||
"page-not-found": "Страница не найдена",
|
||||
"page-not-found-desc": "Извините, страница, которую вы ищете, не существует или была удалена.",
|
||||
"back-to-home": "Вернуться на главную",
|
||||
"no-content-available": "Нет доступной информации",
|
||||
"loading": "Загрузка...",
|
||||
"our-products": "Наши последние продукты",
|
||||
"find-discontinued-products": "Чтобы найти другие продукты, используйте функцию поиска.",
|
||||
"product-discontinued-warning": "Этот продукт снят с производства и может больше не получать мгновенную поддержку или обновления",
|
||||
"learn-our-solutions": "Узнайте о наших решениях",
|
||||
"all": "Все",
|
||||
"support-page-desc": "Zhejiang Jinshen Machinery Manufacturing Co., Ltd Стремится предоставлять клиентам высококачественные продукты и услуги. Мы предлагаем послепродажное обслуживание для таких продуктов, как машины для бумажных трубок и соломинок, обеспечивая уверенность клиентов в использовании нашей продукции.",
|
||||
"support-card-desc": {
|
||||
"faq": "Мы собрали ответы на часто задаваемые вопросы, чтобы помочь вам быстро решить свои проблемы.",
|
||||
"documents": "Предоставляем документацию, такую как руководства по продуктам, технические спецификации, для удобства пользователей.",
|
||||
"contact-info": "Свяжитесь с нами по телефону или электронной почте, и мы оперативно вам поможем."
|
||||
},
|
||||
"product-filter": {
|
||||
"product-type": "Тип продукта",
|
||||
"product-model": "Модель продукта",
|
||||
"keyword": "Ключевое слово",
|
||||
"select-product-type": "Выберите тип продукта",
|
||||
"select-product-model": "Выберите модель продукта",
|
||||
"enter-keyword": "Введите ключевое слово",
|
||||
"misc": "разное",
|
||||
"document-type": "Тип документа",
|
||||
"question-type": "Тип вопроса",
|
||||
"select-document-type": "Выберите тип документа",
|
||||
"select-question-type": "Выберите тип вопроса"
|
||||
},
|
||||
"document-meta": {
|
||||
"size": "Размер",
|
||||
"format": "Формат",
|
||||
"type": "Тип",
|
||||
"upload-at": "Дата загрузки"
|
||||
},
|
||||
"document-action": {
|
||||
"download": "Скачать",
|
||||
"open-in-new-tab": "Открыть в новой вкладке",
|
||||
"preview": "Предварительный просмотр"
|
||||
},
|
||||
"mobile-menu": {
|
||||
"title": "Меню",
|
||||
"navigation": "Навигация по сайту",
|
||||
"utilities": "Полезные инструменты"
|
||||
},
|
||||
"homepage": {
|
||||
"recommended-products": "Рекомендуемые продукты",
|
||||
"recommended-products-desc": "Исследуйте наши тщательно отобранные продукты, которые удовлетворят все ваши потребности. Мы предлагаем как инновационные технологии, так и классические решения.",
|
||||
"recommended-solutions": "Рекомендуемые решения",
|
||||
"recommended-solutions-desc": "Узнайте о наших индивидуальных решениях, чтобы оптимизировать бизнес-процессы и повысить эффективность."
|
||||
},
|
||||
"page-title": {
|
||||
"homepage": "Главная",
|
||||
"products": "Центр продуктов",
|
||||
"solutions": "Решения",
|
||||
"support": "Поддержка",
|
||||
"faq": "Часто задаваемые вопросы",
|
||||
"documents": "Документация",
|
||||
"contact-us": "Свяжитесь с нами",
|
||||
"download": "Скачать докумен",
|
||||
"preview": "Просмотр документа",
|
||||
"about-us": "О нас"
|
||||
},
|
||||
"product-tab": {
|
||||
"details": "Детали продукта",
|
||||
"specs": "Технические спецификации",
|
||||
"faq": "Часто задаваемые вопросы",
|
||||
"documents": "Связанные документы"
|
||||
}
|
||||
}
|
||||
@ -10,6 +10,7 @@
|
||||
"result-count": "共 {count} 条结果",
|
||||
"no-results": "没有找到与 “{query}” 匹配的内容。",
|
||||
"no-query": "请输入关键字开始搜索。",
|
||||
"section": "内容类型",
|
||||
"untitled": "未命名条目",
|
||||
"sections": {
|
||||
"product": "产品",
|
||||
@ -22,8 +23,8 @@
|
||||
"company-name": "金申机械制造有限公司",
|
||||
"company-description": "专业生产一系列纸管、纸罐设备,集设计、制造、销售、服务于一体。",
|
||||
"learn-more": "了解更多",
|
||||
"products-desc": "我们提供高质量的产品解决方案,满足各种业务需求。",
|
||||
"solutions-desc": "为企业提供定制化的技术解决方案,助力数字化转型。",
|
||||
"products-desc": "我们提供最新的产品与即时的服务支持,满足客户的各类业务需求。",
|
||||
"solutions-desc": "我们为企业提供多样化的技术解决方案,在工业、包装等多种领域提供支持。",
|
||||
"support-desc": "7x24小时专业技术支持,确保您的业务稳定运行。",
|
||||
"quick-links": "快速链接",
|
||||
"utilities": "实用工具",
|
||||
@ -37,7 +38,8 @@
|
||||
"downloads": "文件下载",
|
||||
"faq": "常见问题",
|
||||
"documents": "文档资料",
|
||||
"calculator": "纸管计算工具"
|
||||
"calculator": "纸管计算工具",
|
||||
"address": "公司地址"
|
||||
},
|
||||
"contact-info": "联系我们",
|
||||
"telephone": "电话",
|
||||
@ -61,10 +63,12 @@
|
||||
"back-to-home": "返回首页",
|
||||
"no-content-available": "暂无详细信息",
|
||||
"loading": "加载中...",
|
||||
"our-products": "我们的产品",
|
||||
"our-products": "我们的最新产品",
|
||||
"find-discontinued-products": "如需查找其他产品,请使用搜索功能",
|
||||
"product-discontinued-warning": "本产品已停产,可能不再提供即时的支持或更新",
|
||||
"learn-our-solutions": "了解我们的解决方案",
|
||||
"all": "全部",
|
||||
"support-page-desc": "金申机械制造有限公司致力于为客户提供优质的产品与服务。针对纸管机、分纸机、纸吸管等产品,我们提供全方位的售后服务,确保客户能够安心地使用我们的产品。公司名可用占位符代替",
|
||||
"support-page-desc": "金申机械制造有限公司致力于为客户提供优质的产品与服务。针对纸管机、分纸机、纸吸管等产品,我们提供全方位的售后服务,确保客户能够安心地使用我们的产品。",
|
||||
"support-card-desc": {
|
||||
"faq": "我们为用户整理了常见问题的答案,帮助您快速解决疑惑。",
|
||||
"documents": "提供产品手册、技术规格等文档资料,方便用户查阅。",
|
||||
@ -76,7 +80,12 @@
|
||||
"keyword": "关键词",
|
||||
"select-product-type": "选择产品类型",
|
||||
"select-product-model": "选择产品系列",
|
||||
"enter-keyword": "输入关键词"
|
||||
"enter-keyword": "输入关键词",
|
||||
"question-type": "问题类型",
|
||||
"select-question-type": "选择问题类型",
|
||||
"document-type": "文档类型",
|
||||
"select-document-type": "选择文档类型",
|
||||
"misc": "其他"
|
||||
},
|
||||
"document-meta": {
|
||||
"size": "大小",
|
||||
@ -99,5 +108,23 @@
|
||||
"recommended-products-desc": "探索我们的精选产品,满足您的各种需求。无论是创新技术还是经典设计,我们都为您提供优质选择。",
|
||||
"recommended-solutions": "推荐解决方案",
|
||||
"recommended-solutions-desc": "了解我们的定制解决方案,帮助您优化业务流程,提高效率。"
|
||||
},
|
||||
"page-title": {
|
||||
"homepage": "首页",
|
||||
"products": "产品中心",
|
||||
"solutions": "解决方案",
|
||||
"support": "服务支持",
|
||||
"faq": "常见问题",
|
||||
"documents": "文档资料",
|
||||
"contact-us": "联系我们",
|
||||
"download": "文档下载",
|
||||
"preview": "文档预览",
|
||||
"about-us": "关于我们"
|
||||
},
|
||||
"product-tab": {
|
||||
"details": "产品详情",
|
||||
"specs": "技术规格",
|
||||
"faq": "常见问题",
|
||||
"documents": "相关文档"
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||
import GraphQLLoader from 'vite-plugin-graphql-loader';
|
||||
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: '2025-07-15',
|
||||
devtools: { enabled: true },
|
||||
@ -6,14 +8,18 @@ export default defineNuxtConfig({
|
||||
app: {
|
||||
// head
|
||||
head: {
|
||||
title: '金申机械制造有限公司',
|
||||
titleTemplate: '金申机械制造有限公司',
|
||||
meta: [
|
||||
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
|
||||
{
|
||||
name: 'description',
|
||||
content: 'Jinshen Website',
|
||||
content:
|
||||
'浙江金申机械制造有限公司,专业生产一系列纸管、纸罐设备,是一家集设计、制造、销售、服务于一体的企业。公司主要 产品有原纸分切机、数控纸管机、纸管精切机及纸管后加工设备等 三十多个品种,产品在造纸、印刷、包装、纺织及文具等行业得到 广泛应用。公司依靠科技进步,引进高新技术,致力于新产品开发及技术改造,并配备完善的销售网络和售后服务体系,产品销往全国各地及全球上百个国家和地区,真正做到让客户买的放心,用的安心。',
|
||||
},
|
||||
],
|
||||
htmlAttrs: {
|
||||
lang: 'zh',
|
||||
},
|
||||
link: [{ rel: 'icon', type: 'image/x-icon', href: '/jinshen-logo.ico' }],
|
||||
},
|
||||
},
|
||||
@ -38,6 +44,10 @@ export default defineNuxtConfig({
|
||||
},
|
||||
directus: {
|
||||
url: process.env.DIRECTUS_URL || 'http://localhost:8055',
|
||||
publicUrl:
|
||||
process.env.DIRECTUS_PUBLIC_URL ||
|
||||
process.env.DIRECTUS_URL ||
|
||||
'http://localhost:8055',
|
||||
token: process.env.DIRECTUS_TOKEN || undefined,
|
||||
},
|
||||
},
|
||||
@ -62,6 +72,7 @@ export default defineNuxtConfig({
|
||||
'@unocss/reset/tailwind.css',
|
||||
'~/assets/scss/index.scss',
|
||||
'~/assets/css/fonts.css',
|
||||
'~/assets/css/typography.css',
|
||||
'@mdi/font/css/materialdesignicons.min.css',
|
||||
],
|
||||
|
||||
@ -86,6 +97,7 @@ export default defineNuxtConfig({
|
||||
},
|
||||
},
|
||||
},
|
||||
plugins: [GraphQLLoader()],
|
||||
},
|
||||
|
||||
devServer: {
|
||||
@ -100,6 +112,7 @@ export default defineNuxtConfig({
|
||||
},
|
||||
|
||||
i18n: {
|
||||
baseUrl: process.env.BASE_URL || 'http://localhost:3000',
|
||||
detectBrowserLanguage: {
|
||||
useCookie: true,
|
||||
cookieKey: 'i18n_redirected',
|
||||
@ -109,6 +122,8 @@ export default defineNuxtConfig({
|
||||
locales: [
|
||||
{ code: 'en', language: 'en-US', name: 'English', file: 'en.json' },
|
||||
{ code: 'zh', language: 'zh-CN', name: '简体中文', file: 'zh.json' },
|
||||
{ code: 'es', language: 'es-ES', name: 'Español', file: 'es.json' },
|
||||
{ code: 'ru', language: 'ru-RU', name: 'Русский', file: 'ru.json' },
|
||||
],
|
||||
defaultLocale: 'zh',
|
||||
strategy: 'prefix_except_default',
|
||||
|
||||
@ -22,14 +22,20 @@
|
||||
"@types/markdown-it": "^14.1.2",
|
||||
"@unocss/nuxt": "^66.4.2",
|
||||
"@vueuse/nuxt": "^13.6.0",
|
||||
"dom-serializer": "^2.0.0",
|
||||
"domhandler": "^5.0.3",
|
||||
"dompurify": "^3.2.6",
|
||||
"element-plus": "^2.10.7",
|
||||
"fuse.js": "^7.1.0",
|
||||
"graphql": "^16.12.0",
|
||||
"htmlparser2": "^10.0.0",
|
||||
"markdown-it": "^14.1.0",
|
||||
"meilisearch": "^0.53.0",
|
||||
"nuxt": "^4.0.3",
|
||||
"nuxt-directus": "5.7.0",
|
||||
"sass": "^1.90.0",
|
||||
"sharp": "^0.34.3",
|
||||
"vite-plugin-graphql-loader": "^4.0.4",
|
||||
"vue": "^3.5.18",
|
||||
"vue-router": "^4.5.1"
|
||||
},
|
||||
|
||||
60
pnpm-lock.yaml
generated
60
pnpm-lock.yaml
generated
@ -41,12 +41,27 @@ importers:
|
||||
'@vueuse/nuxt':
|
||||
specifier: ^13.6.0
|
||||
version: 13.9.0(magicast@0.3.5)(nuxt@4.1.2(@parcel/watcher@2.5.1)(@types/node@24.4.0)(@vue/compiler-sfc@3.5.21)(db0@0.3.2)(eslint@9.35.0(jiti@2.5.1))(ioredis@5.7.0)(magicast@0.3.5)(optionator@0.9.4)(rollup@4.50.2)(sass@1.92.1)(terser@5.44.0)(typescript@5.9.2)(vite@7.1.5(@types/node@24.4.0)(jiti@2.5.1)(sass@1.92.1)(terser@5.44.0)(yaml@2.8.1))(yaml@2.8.1))(vue@3.5.21(typescript@5.9.2))
|
||||
dom-serializer:
|
||||
specifier: ^2.0.0
|
||||
version: 2.0.0
|
||||
domhandler:
|
||||
specifier: ^5.0.3
|
||||
version: 5.0.3
|
||||
dompurify:
|
||||
specifier: ^3.2.6
|
||||
version: 3.2.6
|
||||
element-plus:
|
||||
specifier: ^2.10.7
|
||||
version: 2.11.2(vue@3.5.21(typescript@5.9.2))
|
||||
fuse.js:
|
||||
specifier: ^7.1.0
|
||||
version: 7.1.0
|
||||
graphql:
|
||||
specifier: ^16.12.0
|
||||
version: 16.12.0
|
||||
htmlparser2:
|
||||
specifier: ^10.0.0
|
||||
version: 10.0.0
|
||||
markdown-it:
|
||||
specifier: ^14.1.0
|
||||
version: 14.1.0
|
||||
@ -65,6 +80,9 @@ importers:
|
||||
sharp:
|
||||
specifier: ^0.34.3
|
||||
version: 0.34.3
|
||||
vite-plugin-graphql-loader:
|
||||
specifier: ^4.0.4
|
||||
version: 4.0.4
|
||||
vue:
|
||||
specifier: ^3.5.18
|
||||
version: 3.5.21(typescript@5.9.2)
|
||||
@ -3081,6 +3099,10 @@ packages:
|
||||
resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==}
|
||||
engines: {node: '>=0.12'}
|
||||
|
||||
entities@6.0.1:
|
||||
resolution: {integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==}
|
||||
engines: {node: '>=0.12'}
|
||||
|
||||
env-paths@2.2.1:
|
||||
resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==}
|
||||
engines: {node: '>=6'}
|
||||
@ -3495,6 +3517,16 @@ packages:
|
||||
graphemer@1.4.0:
|
||||
resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==}
|
||||
|
||||
graphql-tag@2.12.6:
|
||||
resolution: {integrity: sha512-FdSNcu2QQcWnM2VNvSCCDCVS5PpPqpzgFT8+GXzqJuoDd0CBncxCY278u4mhRO7tMgo2JjgJA5aZ+nWSQ/Z+xg==}
|
||||
engines: {node: '>=10'}
|
||||
peerDependencies:
|
||||
graphql: ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0
|
||||
|
||||
graphql@16.12.0:
|
||||
resolution: {integrity: sha512-DKKrynuQRne0PNpEbzuEdHlYOMksHSUI8Zc9Unei5gTsMNA2/vMpoMz/yKba50pejK56qj98qM0SjYxAKi13gQ==}
|
||||
engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0}
|
||||
|
||||
gzip-size@6.0.0:
|
||||
resolution: {integrity: sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==}
|
||||
engines: {node: '>=10'}
|
||||
@ -3525,6 +3557,9 @@ packages:
|
||||
hookable@5.5.3:
|
||||
resolution: {integrity: sha512-Yc+BQe8SvoXH1643Qez1zqLRmbA5rCL+sSmk6TVos0LWVfNIB7PGncdlId77WzLGSIB5KaWgTaNTs2lNVEI6VQ==}
|
||||
|
||||
htmlparser2@10.0.0:
|
||||
resolution: {integrity: sha512-TwAZM+zE5Tq3lrEHvOlvwgj1XLWQCtaaibSN11Q+gGBAS7Y1uZSWwXXRe4iF6OXnaq1riyQAPFOBtYc77Mxq0g==}
|
||||
|
||||
http-errors@2.0.0:
|
||||
resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
@ -5385,6 +5420,9 @@ packages:
|
||||
vue-tsc:
|
||||
optional: true
|
||||
|
||||
vite-plugin-graphql-loader@4.0.4:
|
||||
resolution: {integrity: sha512-lYnpQ2luV2fcuXmOJADljuktfMbDW00Y+6QS+Ek8Jz1Vdzlj/51LSGJwZqyjJ24a5YQ+o29Hr6el/5+nlZetvg==}
|
||||
|
||||
vite-plugin-inspect@11.3.3:
|
||||
resolution: {integrity: sha512-u2eV5La99oHoYPHE6UvbwgEqKKOQGz86wMg40CCosP6q8BkB6e5xPneZfYagK4ojPJSj5anHCrnvC20DpwVdRA==}
|
||||
engines: {node: '>=14'}
|
||||
@ -8991,6 +9029,8 @@ snapshots:
|
||||
|
||||
entities@4.5.0: {}
|
||||
|
||||
entities@6.0.1: {}
|
||||
|
||||
env-paths@2.2.1: {}
|
||||
|
||||
environment@1.1.0: {}
|
||||
@ -9476,6 +9516,13 @@ snapshots:
|
||||
|
||||
graphemer@1.4.0: {}
|
||||
|
||||
graphql-tag@2.12.6(graphql@16.12.0):
|
||||
dependencies:
|
||||
graphql: 16.12.0
|
||||
tslib: 2.8.1
|
||||
|
||||
graphql@16.12.0: {}
|
||||
|
||||
gzip-size@6.0.0:
|
||||
dependencies:
|
||||
duplexer: 0.1.2
|
||||
@ -9512,6 +9559,13 @@ snapshots:
|
||||
|
||||
hookable@5.5.3: {}
|
||||
|
||||
htmlparser2@10.0.0:
|
||||
dependencies:
|
||||
domelementtype: 2.3.0
|
||||
domhandler: 5.0.3
|
||||
domutils: 3.2.2
|
||||
entities: 6.0.1
|
||||
|
||||
http-errors@2.0.0:
|
||||
dependencies:
|
||||
depd: 2.0.0
|
||||
@ -11722,6 +11776,12 @@ snapshots:
|
||||
optionator: 0.9.4
|
||||
typescript: 5.9.2
|
||||
|
||||
vite-plugin-graphql-loader@4.0.4:
|
||||
dependencies:
|
||||
graphql: 16.12.0
|
||||
graphql-tag: 2.12.6(graphql@16.12.0)
|
||||
magic-string: 0.30.19
|
||||
|
||||
vite-plugin-inspect@11.3.3(@nuxt/kit@3.19.2(magicast@0.3.5))(vite@7.1.5(@types/node@24.4.0)(jiti@2.5.1)(sass@1.92.1)(terser@5.44.0)(yaml@2.8.1)):
|
||||
dependencies:
|
||||
ansis: 4.1.0
|
||||
|
||||
36
server/api/assets/[id].ts
Normal file
36
server/api/assets/[id].ts
Normal file
@ -0,0 +1,36 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = getRouterParam(event, 'id');
|
||||
if (!id)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'ID parameter is required',
|
||||
});
|
||||
|
||||
const url = new URL(`${useRuntimeConfig().public.directus.url}/assets/${id}`);
|
||||
|
||||
const query = getQuery(event);
|
||||
Object.entries(query).forEach(([key, value]) => {
|
||||
url.searchParams.set(key, String(value));
|
||||
});
|
||||
|
||||
const token = useRuntimeConfig().public.directus.token || '';
|
||||
const res = await fetch(url.toString(), {
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw createError({
|
||||
statusCode: res.status,
|
||||
statusMessage: `Failed to fetch asset: ${res.statusText}`,
|
||||
});
|
||||
}
|
||||
|
||||
const contentType =
|
||||
res.headers.get('Content-Type') || 'application/octet-stream';
|
||||
setHeader(event, 'Content-Type', contentType);
|
||||
setHeader(event, 'Cache-Control', 'public, max-age=86400, immutable');
|
||||
|
||||
return res.body;
|
||||
});
|
||||
15
server/api/cms/companyProfile.get.ts
Normal file
15
server/api/cms/companyProfile.get.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { companyProfileService } from '~~/server/services/cms/companyProfileService';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
const companyProfile = await companyProfileService.getCompanyProfile(locale);
|
||||
|
||||
companyProfile.content = rewriteAssetUrls(
|
||||
companyProfile.content,
|
||||
useRuntimeConfig().public.directus.publicUrl,
|
||||
'/api/assets'
|
||||
);
|
||||
|
||||
return companyProfile;
|
||||
});
|
||||
15
server/api/cms/contactInfo.get.ts
Normal file
15
server/api/cms/contactInfo.get.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { contactInfoService } from '~~/server/services/cms/contactInfoService';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
const contactInfo = await contactInfoService.getContactInfo(locale);
|
||||
|
||||
contactInfo.content = rewriteAssetUrls(
|
||||
contactInfo.content,
|
||||
useRuntimeConfig().public.directus.publicUrl,
|
||||
'/api/assets'
|
||||
);
|
||||
|
||||
return contactInfo;
|
||||
});
|
||||
7
server/api/cms/documentList.get.ts
Normal file
7
server/api/cms/documentList.get.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { documentService } from '~~/server/services/cms/documentService';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
return documentService.getDocumentList(locale);
|
||||
});
|
||||
7
server/api/cms/homepage.get.ts
Normal file
7
server/api/cms/homepage.get.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { homepageService } from '~~/server/services/cms/homepageService';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
return homepageService.getHomepage(locale);
|
||||
});
|
||||
21
server/api/cms/product/[id].get.ts
Normal file
21
server/api/cms/product/[id].get.ts
Normal file
@ -0,0 +1,21 @@
|
||||
import { productService } from '~~/server/services/cms/productService';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = getRouterParam(event, 'id');
|
||||
if (!id)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'Product ID is required',
|
||||
});
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
const product = await productService.getProductById(id, locale);
|
||||
|
||||
product.description = rewriteAssetUrls(
|
||||
product.description,
|
||||
useRuntimeConfig().public.directus.publicUrl,
|
||||
'/api/assets'
|
||||
);
|
||||
|
||||
return product;
|
||||
});
|
||||
6
server/api/cms/productList.get.ts
Normal file
6
server/api/cms/productList.get.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { productService } from '~~/server/services/cms/productService';
|
||||
export default defineEventHandler(async (event) => {
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
return productService.getProductList(locale);
|
||||
});
|
||||
16
server/api/cms/questionList.get.ts
Normal file
16
server/api/cms/questionList.get.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { questionService } from '~~/server/services/cms/questionService';
|
||||
export default defineEventHandler(async (event) => {
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
const questions = await questionService.getQuestionList(locale);
|
||||
|
||||
questions.forEach((question) => {
|
||||
question.content = rewriteAssetUrls(
|
||||
question.content,
|
||||
useRuntimeConfig().public.directus.publicUrl,
|
||||
'/api/assets'
|
||||
);
|
||||
});
|
||||
|
||||
return questions;
|
||||
});
|
||||
22
server/api/cms/solution/[id].get.ts
Normal file
22
server/api/cms/solution/[id].get.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import { solutionService } from '~~/server/services/cms/solutionService';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const id = getRouterParam(event, 'id');
|
||||
if (!id)
|
||||
throw createError({
|
||||
statusCode: 400,
|
||||
statusMessage: 'Solution ID is required',
|
||||
});
|
||||
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
const solution = await solutionService.getSolutionById(id, locale);
|
||||
|
||||
solution.content = rewriteAssetUrls(
|
||||
solution.content,
|
||||
useRuntimeConfig().public.directus.publicUrl,
|
||||
'/api/assets'
|
||||
);
|
||||
|
||||
return solution;
|
||||
});
|
||||
7
server/api/cms/solutionList.get.ts
Normal file
7
server/api/cms/solutionList.get.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { solutionService } from '~~/server/services/cms/solutionService';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
return solutionService.getSolutionList(locale);
|
||||
});
|
||||
37
server/api/search.get.ts
Normal file
37
server/api/search.get.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import { toSearchItemView } from '../mappers/searchItemMapper';
|
||||
import { getMeiliService } from '../services/search';
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const query = getQuery(event);
|
||||
const q = String(query.query || '');
|
||||
const locale = getHeader(event, 'x-locale') || 'zh-CN';
|
||||
|
||||
logger.info(`Search query: "${q}" for locale: "${locale}"`);
|
||||
|
||||
if (!q) return [];
|
||||
|
||||
const meili = getMeiliService();
|
||||
const sections = await meili.search(q, { limit: 12 }, locale);
|
||||
|
||||
// 空Section过滤
|
||||
const filteredSections = sections.filter(
|
||||
(section) => section.hits.length > 0
|
||||
);
|
||||
|
||||
const typeMap = {
|
||||
products: 'products',
|
||||
solutions: 'solutions',
|
||||
questions: 'questions',
|
||||
product_documents: 'product_documents',
|
||||
} as const;
|
||||
|
||||
const hits = filteredSections.flatMap((section) => {
|
||||
const type = typeMap[section.rawIndex as keyof typeof typeMap];
|
||||
if (!type) return [];
|
||||
return section.hits.map((hit) => ({ type, content: hit }));
|
||||
});
|
||||
|
||||
return hits.map((hit) => {
|
||||
return toSearchItemView(hit.content, hit.type);
|
||||
});
|
||||
});
|
||||
16
server/api/version.ts
Normal file
16
server/api/version.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { existsSync, readFileSync } from 'fs';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
export default defineEventHandler(() => {
|
||||
const path = process.cwd() + '/version.json';
|
||||
|
||||
if (existsSync(path)) {
|
||||
return JSON.parse(readFileSync(path, 'utf-8'));
|
||||
}
|
||||
|
||||
return {
|
||||
buildTime: new Date().toISOString(),
|
||||
gitCommit: execSync('git rev-parse --short HEAD').toString().trim(),
|
||||
generated: true,
|
||||
};
|
||||
});
|
||||
9
server/assets/graphql/companyProfile.graphql
Normal file
9
server/assets/graphql/companyProfile.graphql
Normal file
@ -0,0 +1,9 @@
|
||||
query GetCompanyProfile($locale: String!) {
|
||||
company_profile {
|
||||
id
|
||||
translations(filter: { languages_code: { code: { _eq: $locale } } }) {
|
||||
id
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
9
server/assets/graphql/contactInfo.graphql
Normal file
9
server/assets/graphql/contactInfo.graphql
Normal file
@ -0,0 +1,9 @@
|
||||
query GetContactInfo($locale: String!) {
|
||||
contact_info {
|
||||
id
|
||||
translations(filter: { languages_code: { code: { _eq: $locale } } }) {
|
||||
id
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
38
server/assets/graphql/documentList.graphql
Normal file
38
server/assets/graphql/documentList.graphql
Normal file
@ -0,0 +1,38 @@
|
||||
query GetDocumentList($locale: String!) {
|
||||
product_documents(filter: { status: { _eq: "published" } }) {
|
||||
id
|
||||
file {
|
||||
id
|
||||
filesize
|
||||
filename_download
|
||||
}
|
||||
translations(filter: { languages_code: { code: { _eq: $locale } } }) {
|
||||
id
|
||||
title
|
||||
}
|
||||
type {
|
||||
id
|
||||
translations(filter: { languages_code: { code: { _eq: $locale } } }) {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
products {
|
||||
id
|
||||
products_id {
|
||||
id
|
||||
translations(filter: { languages_code: { code: { _eq: $locale } } }) {
|
||||
id
|
||||
name
|
||||
}
|
||||
product_type {
|
||||
id
|
||||
translations(filter: { languages_code: { code: { _eq: $locale } } }) {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user