本次提交主要进行了以下修改: 1. 在styles.css中调整了链接和代码块的样式,使用CSS变量提升可维护性。 2. 在faq.vue中优化了FAQ内容的渲染结构,增强了可读性。 3. 在index.vue和products/[id].vue中移除了多余的console.log语句,提升了代码整洁性。 这些改动旨在提升代码的可维护性和用户体验,同时减少不必要的调试信息。master
@@ -150,13 +150,25 @@ html[lang="ja"] body { | |||
text-decoration-thickness: 1px; | |||
text-underline-offset: 2px; | |||
transition: color 0.2s; | |||
pointer-events: none; | |||
color: var(--color-primary); | |||
} | |||
.prose a:hover { | |||
color: rgb(147 197 253); | |||
} | |||
.prose h1 a, | |||
.prose h2 a, | |||
.prose h3 a, | |||
.prose h4 a, | |||
.prose h5 a, | |||
.prose h6 a { | |||
color: var(--color-text); | |||
pointer-events: none; | |||
} | |||
.prose ul, | |||
.prose ol { | |||
margin: 1rem 0; | |||
@@ -193,12 +205,11 @@ html[lang="ja"] body { | |||
} | |||
.prose code { | |||
background-color: rgb(39, 39, 42); | |||
background-color: rgba(0, 0, 0, 0.5); | |||
padding: 0.125rem 0.375rem; | |||
border-radius: 0.25rem; | |||
font-size: 0.875rem; | |||
font-family: ui-monospace, monospace; | |||
color: rgb(147 197 253); | |||
color: var(--color-text); | |||
} | |||
.prose pre { |
@@ -17,9 +17,11 @@ | |||
>{{ t("common.home") }}</nuxt-link | |||
> | |||
<span class="text-white/60 text-base font-normal px-2"> / </span> | |||
<nuxt-link :to="`${homepagePath}/faq`" class="text-white text-base font-normal">{{ | |||
t("faq.title") | |||
}}</nuxt-link> | |||
<nuxt-link | |||
:to="`${homepagePath}/faq`" | |||
class="text-white text-base font-normal" | |||
>{{ t("faq.title") }}</nuxt-link | |||
> | |||
</div> | |||
</div> | |||
<div | |||
@@ -115,9 +117,12 @@ | |||
</div> | |||
<div | |||
v-if="isFaqExpanded(faq)" | |||
class="mt-4 text-white/80 text-base font-normal leading-relaxed" | |||
class="mt-4" | |||
> | |||
<ContentRenderer class="text-white" :value="{ body: faq.content }" /> | |||
<ContentRenderer | |||
class="prose w-full max-w-none" | |||
:value="{ body: faq.content }" | |||
/> | |||
</div> | |||
</div> | |||
<div | |||
@@ -156,12 +161,10 @@ interface FAQ { | |||
id?: string; | |||
} | |||
const homepagePath = computed(() => { | |||
return locale.value === "zh" ? "" : `/${locale.value}`; | |||
}); | |||
// 从content目录读取FAQ数据 | |||
const faqs = ref<FAQ[]>([]); | |||
const categoriesList = ref<string[]>([]); | |||
@@ -179,8 +182,6 @@ const { data: faqData } = await useAsyncData( | |||
.where("path", "LIKE", `/faq/${locale.value}/%`) | |||
.all(); | |||
console.log("Raw FAQ content:", content); | |||
if (!content || !Array.isArray(content)) { | |||
console.error("No FAQ content found or invalid format:", content); | |||
return []; | |||
@@ -188,7 +189,6 @@ const { data: faqData } = await useAsyncData( | |||
// 转换数据格式 | |||
const faqItems = content.map((item: any) => { | |||
console.log("Processing FAQ item:", item); | |||
return { | |||
category: item.meta?.category || "", | |||
title: item.title || "", | |||
@@ -197,7 +197,6 @@ const { data: faqData } = await useAsyncData( | |||
}; | |||
}); | |||
console.log("Processed FAQ items:", faqItems); | |||
return faqItems.sort((a, b) => a.sort - b.sort); | |||
} catch (error) { | |||
console.error("Error loading FAQ content:", error); | |||
@@ -217,8 +216,6 @@ watchEffect(() => { | |||
if (faqData.value) { | |||
isLoading.value = true; | |||
try { | |||
console.log("Processing FAQ data:", faqData.value); | |||
// 设置分类列表和默认选中的分类 | |||
const allOption: string = | |||
locale.value === "en" | |||
@@ -234,8 +231,6 @@ watchEffect(() => { | |||
.filter((category) => category) | |||
.sort(); // 过滤掉空分类并排序 | |||
console.log("Unique categories:", uniqueCategories); | |||
// 设置分类列表和默认选中的分类 | |||
categoriesList.value = [allOption, ...uniqueCategories]; | |||
selectedCategory.value = categoriesList.value[0]; | |||
@@ -258,12 +253,11 @@ const searchInputRef = ref<HTMLInputElement | null>(null); | |||
// 过滤后的FAQ列表 | |||
const filteredFaqs = computed(() => { | |||
if (!faqData.value) { | |||
console.log("No FAQ data available"); | |||
return []; | |||
} | |||
let result = faqData.value; | |||
// 分类过滤 | |||
if (selectedCategory.value !== categoriesList.value[0]) { | |||
result = result.filter( |
@@ -159,7 +159,7 @@ | |||
</div> | |||
</div> | |||
</SwiperSlide> | |||
<SwiperSlide> | |||
<SwiperSlide v-if="!isMobile"> | |||
<div class="max-w-screen-2xl mx-auto h-full relative"> | |||
<video | |||
:src="homeA3Webp" | |||
@@ -250,7 +250,7 @@ | |||
:key="usage.id" | |||
class="cursor-pointer select-none px-4 sm:px-7 py-2 sm:py-3 rounded-full border border-zinc-700 text-white transition-all duration-300 relative group" | |||
:class="{ | |||
'bg-cyan-400/10 border-cyan-400 text-cyan-400': | |||
'bg-gradient-to-r from-blue-700 to-blue-400 text-white border-zinc-900 pointer-events-none': | |||
activeIndex === index, | |||
'hover:border-zinc-600': activeIndex !== index, | |||
}" | |||
@@ -751,8 +751,6 @@ const loadUsageData = async () => { | |||
// 处理数据 | |||
usageList.value = usageData | |||
.map((usage: any) => { | |||
console.log(`处理用途: ${usage.id} - ${usage.title}`, usage); | |||
// 为每种用途找到对应的产品 | |||
const usageProducts = []; | |||
@@ -765,10 +763,6 @@ const loadUsageData = async () => { | |||
product.usage.includes(usage.title) | |||
); | |||
console.log( | |||
`用途"${usage.title}"匹配到 ${matchedProducts.length} 个产品` | |||
); | |||
// 将匹配的产品添加到列表 | |||
if (matchedProducts.length > 0) { | |||
matchedProducts.forEach((product: any) => { | |||
@@ -782,7 +776,6 @@ const loadUsageData = async () => { | |||
}); | |||
} else { | |||
// 如果没有找到匹配的产品,添加一个占位产品 | |||
console.log(`用途 ${usage.title} 没有匹配到任何产品,添加占位产品`); | |||
usageProducts.push({ | |||
id: `placeholder-${usage.id}`, | |||
@@ -828,7 +821,6 @@ const loadCategoryData = async () => { | |||
} | |||
const data = await response.json(); | |||
console.log("Raw category data:", data); | |||
// 处理数据 | |||
categoryList.value = data | |||
@@ -866,20 +858,8 @@ watch(locale, () => { | |||
loadCategoryData(); | |||
}); | |||
// 处理数据变化 | |||
watchEffect(() => { | |||
if (usageList.value) { | |||
console.log("Updated usage list:", usageList.value); | |||
} | |||
if (categoryList.value) { | |||
console.log("Updated category list:", categoryList.value); | |||
} | |||
}); | |||
// 计算当前用途列表 | |||
const typedUsageList = computed(() => { | |||
console.log("Typed Usage List:", usageList.value); | |||
return usageList.value as Usage[]; | |||
}); | |||
@@ -894,17 +874,6 @@ const activeProducts = computed(() => { | |||
const currentUsage = typedUsageList.value.find( | |||
(item: Usage) => item.id === activeUsageId.value | |||
); | |||
if (currentUsage?.products) { | |||
console.log( | |||
"Products:", | |||
currentUsage.products.map((p: Product) => ({ | |||
id: p.id, | |||
title: p.title, | |||
image: p.image, | |||
link: p.link, | |||
})) | |||
); | |||
} | |||
return currentUsage?.products || []; | |||
}); | |||
@@ -916,14 +885,9 @@ const imageErrors = ref<Record<number, boolean>>({}); | |||
watch( | |||
activeProducts, | |||
(newProducts: Product[]) => { | |||
console.log("Active Products Changed:", newProducts); | |||
if (process.client) { | |||
newProducts.forEach((product: Product) => { | |||
if (product.image) { | |||
console.log( | |||
`Checking image for product ${product.id}:`, | |||
product.image | |||
); | |||
const img = new window.Image(); | |||
img.onload = () => handleImageLoad(product.id); | |||
img.onerror = () => handleImageError(product.id); | |||
@@ -938,7 +902,6 @@ watch( | |||
// 处理图片加载 | |||
const handleImageLoad = (id: number) => { | |||
if (process.client) { | |||
console.log(`Image loaded for product ${id}`); | |||
isImageLoaded.value[id] = true; | |||
imageErrors.value[id] = false; | |||
} | |||
@@ -956,7 +919,6 @@ const handleImageError = (id: number) => { | |||
// 处理用途点击 | |||
const handleUsageClick = (id: number) => { | |||
if (process.client) { | |||
console.log("Usage clicked:", id); | |||
// 重置图片加载状态 | |||
isImageLoaded.value = {}; | |||
imageErrors.value = {}; |
@@ -27,7 +27,9 @@ | |||
<span class="text-white/60 text-base font-normal px-2"> / </span> | |||
<nuxt-link | |||
v-if="product?.category" | |||
:to="`${homepagePath}/products?category=${encodeURIComponent(product.category)}`" | |||
:to="`${homepagePath}/products?category=${encodeURIComponent( | |||
product.category | |||
)}`" | |||
class="text-white/60 text-base font-normal" | |||
>{{ product.category }}</nuxt-link | |||
> | |||
@@ -286,9 +288,6 @@ | |||
<!-- 产品参数 --> | |||
<div class="bg-zinc-900 rounded-lg p-6"> | |||
<h2 class="text-white text-xl font-medium mb-6"> | |||
{{ t("products.productSpecifications") }} | |||
</h2> | |||
<div class="grid grid-cols-1 gap-4"> | |||
<div | |||
class="flex justify-between items-center py-2 border-b border-zinc-800" | |||
@@ -340,9 +339,6 @@ | |||
</div> | |||
<div class="bg-zinc-900 rounded-lg p-6"> | |||
<h2 class="text-white text-xl font-medium mb-6"> | |||
{{ t("products.detailedDescription") }} | |||
</h2> | |||
<div | |||
class="text-stone-400 leading-relaxed space-y-4 prose prose-invert max-w-none" | |||
> | |||
@@ -667,13 +663,11 @@ function retryLoadSlideImage(index: number) { | |||
// 创建新的图片对象并设置超时 | |||
const img = new Image(); | |||
const timeoutId = setTimeout(() => { | |||
console.error("Image load timeout:", index); | |||
handleSlideImageError(index); | |||
}, 10000); // 10秒超时 | |||
img.onload = () => { | |||
clearTimeout(timeoutId); | |||
console.log("Image loaded successfully:", index); | |||
handleSlideImageLoad(index); | |||
}; | |||
@@ -711,11 +705,6 @@ onMounted(() => { | |||
} | |||
}); | |||
console.log("Initialized thumbnail states:", { | |||
loading: isSlideThumbnailLoading.value, | |||
errors: slideThumbnailErrors.value, | |||
}); | |||
// 添加滚动监听 | |||
scrollContainer.value = document.querySelector(".max-w-screen-2xl"); | |||
if (scrollContainer.value) { |