Files
fad-trade-next/components/home/index.tsx
砂糖 de67af263e feat: 更新国际化内容和优化首页组件
refactor: 移除调试日志和简化博客页面逻辑

docs: 更新多语言翻译文件,添加公司信息、产品中心和应用领域等内容
2025-12-03 16:21:56 +08:00

472 lines
24 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client'
import { useTranslations } from "next-intl";
export default function HomeComponent() {
const t = useTranslations("Home");
// 客户端组件中直接使用翻译键next-intl 会自动处理
// 注意:在客户端组件中,我们不能使用 raw() 函数,需要直接访问翻译键
return (
<>
<section className="mx-auto text-center">
{/* 轮播图区域, 先用一张图片占位, 宽度100% 盖度100vh */}
<img src="/placeholder.svg" alt={t("carousel")} className="w-screen h-[80vh] object-cover rounded-lg" />
{/* 公司介绍 - 左右布局 */}
<div className="flex flex-col lg:flex-row w-full my-16 px-8">
{/* 左边视频(图片占位) */}
<div className="w-full lg:w-1/2 h-[50vh] lg:h-[60vh] relative overflow-hidden">
<img
src="/placeholder.svg"
alt={t("company_video")}
className="w-full h-full object-cover"
/>
</div>
{/* 右边内容 - 分三部分 */}
<div className="w-full lg:w-1/2 flex flex-col justify-center p-8 lg:p-16">
{/* 第一部分:标题 */}
<div className="mb-6">
<h2 className="text-3xl font-bold text-gray-900">{t("company.title")}</h2>
</div>
{/* 第二部分:介绍 */}
<div className="mb-8">
<p className="text-lg text-gray-700 leading-relaxed">
{t("company.description")}
</p>
</div>
{/* 第三部分:按钮 */}
<div>
<button className="bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-6 rounded transition-colors">
{t("company.button")}
</button>
</div>
</div>
</div>
{/* 隐式轮播图,没有控件,每张四个卡片 */}
<div className="relative overflow-hidden py-16">
<div className="flex w-full flex-nowrap animate-carousel">
{/* 第一组卡片 */}
<div className="min-w-full flex justify-center px-4 gap-6">
<div className="bg-white rounded-lg shadow-md p-6 flex-1 max-w-[22%] text-center">
<div className="text-red-600 text-4xl font-bold mb-2">{t("stats.card1.number")}</div>
<div className="text-gray-700">{t("stats.card1.title")}</div>
</div>
<div className="bg-white rounded-lg shadow-md p-6 flex-1 max-w-[22%] text-center">
<div className="text-red-600 text-4xl font-bold mb-2">{t("stats.card2.number")}</div>
<div className="text-gray-700">{t("stats.card2.title")}</div>
</div>
<div className="bg-white rounded-lg shadow-md p-6 flex-1 max-w-[22%] text-center">
<div className="text-red-600 text-4xl font-bold mb-2">{t("stats.card3.number")}</div>
<div className="text-gray-700">{t("stats.card3.title")}</div>
</div>
<div className="bg-white rounded-lg shadow-md p-6 flex-1 max-w-[22%] text-center">
<div className="text-red-600 text-4xl font-bold mb-2">{t("stats.card4.number")}</div>
<div className="text-gray-700">{t("stats.card4.title")}</div>
</div>
</div>
{/* 第二组卡片 - 用于无缝轮播 */}
<div className="min-w-full flex justify-center px-4 gap-6">
<div className="bg-white rounded-lg shadow-md p-6 flex-1 max-w-[22%] text-center">
<div className="text-red-600 text-4xl font-bold mb-2">{t("stats.card1.number")}</div>
<div className="text-gray-700">{t("stats.card1.title")}</div>
</div>
<div className="bg-white rounded-lg shadow-md p-6 flex-1 max-w-[22%] text-center">
<div className="text-red-600 text-4xl font-bold mb-2">{t("stats.card2.number")}</div>
<div className="text-gray-700">{t("stats.card2.title")}</div>
</div>
<div className="bg-white rounded-lg shadow-md p-6 flex-1 max-w-[22%] text-center">
<div className="text-red-600 text-4xl font-bold mb-2">{t("stats.card3.number")}</div>
<div className="text-gray-700">{t("stats.card3.title")}</div>
</div>
<div className="bg-white rounded-lg shadow-md p-6 flex-1 max-w-[22%] text-center">
<div className="text-red-600 text-4xl font-bold mb-2">{t("stats.card4.number")}</div>
<div className="text-gray-700">{t("stats.card4.title")}</div>
</div>
</div>
</div>
</div>
<style jsx>{`
@keyframes carousel {
0% { transform: translateX(0); }
90% { transform: translateX(0); }
100% { transform: translateX(-100%); }
100% { transform: translateX(-100%); }
}
.animate-carousel {
animation: carousel 5s infinite linear;
animation-timing-function: linear;
transition: transform 1.5s;
}
`}</style>
{/* 最新资讯 */}
<div className="py-16 px-4 bg-white relative overflow-hidden">
{/* 标题 */}
<div className="text-center mb-12">
<h2 className="text-3xl font-bold text-gray-900 inline-block relative">
{t("news.title")}
<span className="absolute bottom-0 left-1/4 w-1/2 h-1 bg-red-600"></span>
</h2>
</div>
{/* 资讯卡片列表 */}
<div className="flex flex-wrap justify-center gap-6 max-w-7xl mx-auto">
{/* 第一张卡片 */}
<div className="w-full md:w-[28vw] lg:w-[28vw] bg-white rounded-lg overflow-hidden transition-all duration-300 hover:shadow-lg">
<div className="p-4">
<div className="text-red-600 mb-2 font-medium text-left">{t("news.items.news1.date")}</div>
<div className="text-gray-800 mb-3 line-clamp-1 text-base whitespace-nowrap overflow-hidden text-ellipsis">{t("news.items.news1.title")}</div>
</div>
<div className="p-4 h-48 overflow-hidden">
<img src="/placeholder.svg" alt={t("news.items.news1.title")} className="w-full h-full object-cover rounded" />
</div>
</div>
{/* 第二张卡片 - 中间突出显示 */}
<div className="w-full md:w-[28vw] lg:w-[28vw] bg-white rounded-lg overflow-hidden transition-all duration-300 hover:shadow-lg relative -mt-2 z-10">
<div className="p-4">
<div className="text-red-600 mb-2 font-medium text-left">{t("news.items.news2.date")}</div>
<div className="text-gray-800 mb-3 line-clamp-1 text-base whitespace-nowrap overflow-hidden text-ellipsis">{t("news.items.news2.title")}</div>
</div>
<div className="p-4 h-48 overflow-hidden">
<img src="/placeholder.svg" alt={t("news.items.news2.title")} className="w-full h-full object-cover rounded" />
</div>
</div>
{/* 第三张卡片 */}
<div className="w-full md:w-[26vw] lg:w-[26vw] bg-white rounded-lg overflow-hidden transition-all duration-300 hover:shadow-lg">
<div className="p-4">
<div className="text-red-600 mb-2 font-medium text-left">{t("news.items.news3.date")}</div>
<div className="text-gray-800 mb-3 line-clamp-1 text-base whitespace-nowrap overflow-hidden text-ellipsis">{t("news.items.news3.title")}</div>
</div>
<div className="p-4 h-48 overflow-hidden">
<img src="/placeholder.svg" alt={t("news.items.news3.title")} className="w-full h-full object-cover rounded" />
</div>
</div>
</div>
{/* 了解更多按钮 */}
<div className="text-center mt-12">
<button className="px-6 py-2 bg-white border border-red-600 text-red-600 hover:bg-red-600 hover:text-white transition-all duration-300 rounded-sm">
{t("news.button")}
</button>
</div>
</div>
{/* 产品中心 */}
<div className="py-16 px-4 bg-white">
<div className="text-center mb-12">
<h2 className="text-3xl font-bold text-gray-900 inline-block relative">
{t("products.title")}
<span className="absolute bottom-0 left-1/4 w-1/2 h-1 bg-red-600"></span>
</h2>
</div>
{/* 左右布局左3右2 */}
<div className="flex flex-col lg:flex-row w-full max-w-7xl mx-auto">
{/* 左侧产品图 - 占3份 */}
<div className="w-full lg:w-3/5 h-[50vh] lg:h-[70vh] relative overflow-hidden bg-gray-100 rounded-lg mb-8 lg:mb-0">
{/* 默认显示第一张产品图 */}
<img
id="productImage"
src="/placeholder.svg"
alt={t("products.list.product1.alt")}
className="w-full h-full object-contain p-8 transition-opacity duration-300"
/>
{/* 产品标题覆盖层 */}
<div className="absolute bottom-0 left-0 right-0 p-6 bg-gradient-to-t from-black/70 to-transparent">
<h3 id="productTitle" className="text-white text-2xl font-bold">{t("products.list.product1.name")}</h3>
</div>
</div>
{/* 右侧产品列表 - 占2份两列布局 */}
<div className="w-full lg:w-2/5 grid grid-cols-2 gap-4 lg:gap-6 p-4 lg:pl-8">
{/* 产品1 */}
<div
className="product-item p-6 flex items-center justify-center text-center bg-gray-200 cursor-pointer transition-colors duration-300 hover:bg-red-600 hover:text-white"
onMouseEnter={() => {
document.getElementById('productImage')?.setAttribute('src', '/placeholder.svg');
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product1.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product1.name");
}}
>
<span>{t("products.list.product1.name")}</span>
</div>
{/* 产品2 */}
<div
className="product-item p-6 flex items-center justify-center text-center bg-gray-200 cursor-pointer transition-colors duration-300 hover:bg-red-600 hover:text-white"
onMouseEnter={() => {
document.getElementById('productImage')?.setAttribute('src', '/placeholder.svg');
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product2.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product2.name");
}}
>
<span>{t("products.list.product2.name")}</span>
</div>
{/* 产品3 */}
<div
className="product-item p-6 flex items-center justify-center text-center bg-gray-200 cursor-pointer transition-colors duration-300 hover:bg-red-600 hover:text-white"
onMouseEnter={() => {
document.getElementById('productImage')?.setAttribute('src', '/placeholder.svg');
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product3.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product3.name");
}}
>
<span>{t("products.list.product3.name")}</span>
</div>
{/* 产品4 */}
<div
className="product-item p-6 flex items-center justify-center text-center bg-gray-200 cursor-pointer transition-colors duration-300 hover:bg-red-600 hover:text-white"
onMouseEnter={() => {
document.getElementById('productImage')?.setAttribute('src', '/placeholder.svg');
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product4.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product4.name");
}}
>
<span>{t("products.list.product4.name")}</span>
</div>
{/* 产品5 */}
<div
className="product-item p-6 flex items-center justify-center text-center bg-gray-200 cursor-pointer transition-colors duration-300 hover:bg-red-600 hover:text-white"
onMouseEnter={() => {
document.getElementById('productImage')?.setAttribute('src', '/placeholder.svg');
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product5.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product5.name");
}}
>
<span>{t("products.list.product5.name")}</span>
</div>
{/* 产品6 */}
<div
className="product-item p-6 flex items-center justify-center text-center bg-gray-200 cursor-pointer transition-colors duration-300 hover:bg-red-600 hover:text-white"
onMouseEnter={() => {
document.getElementById('productImage')?.setAttribute('src', '/placeholder.svg');
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product6.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product6.name");
}}
>
<span>{t("products.list.product6.name")}</span>
</div>
</div>
</div>
</div>
{/* 应用领域 */}
<div className="py-16 px-4 bg-gray-50 relative overflow-hidden">
{/* 标题 */}
<div className="text-center mb-12">
<h2 className="text-3xl font-bold text-gray-900 inline-block relative">
{t("applications.title")}
<span className="absolute bottom-0 left-1/4 w-1/2 h-1 bg-red-600"></span>
</h2>
</div>
{/* 轮播容器 */}
<div className="relative max-w-7xl mx-auto">
{/* 左切换按钮 */}
<button
id="prevSlide"
className="absolute left-4 top-1/2 transform -translate-y-1/2 w-10 h-10 rounded-full bg-white shadow-md flex items-center justify-center text-gray-700 hover:bg-red-600 hover:text-white transition-colors z-20"
>
&lt;
</button>
{/* 右切换按钮 */}
<button
id="nextSlide"
className="absolute right-4 top-1/2 transform -translate-y-1/2 w-10 h-10 rounded-full bg-white shadow-md flex items-center justify-center text-gray-700 hover:bg-red-600 hover:text-white transition-colors z-20"
>
&gt;
</button>
{/* 轮播内容 */}
<div className="overflow-hidden">
<div
id="carouselTrack"
className="flex transition-transform duration-500 ease-in-out"
style={{ transform: 'translateX(0)' }}
>
{/* 第一组卡片拼图 */}
<div className="min-w-full flex flex-wrap gap-4 p-4">
{/* 第一行 */}
<div className="w-full flex gap-4 mb-4">
{/* 电梯井道 */}
<div className="w-1/4 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group1.items.app1.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group1.items.app1.name")}
</div>
</div>
{/* 塔机制造 - 宽度为其他卡片的两倍 */}
<div className="w-1/2 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group1.items.app2.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group1.items.app2.name")}
</div>
</div>
{/* 工程机械 */}
<div className="w-1/4 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group1.items.app3.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group1.items.app3.name")}
</div>
</div>
</div>
{/* 第二行 */}
<div className="w-full flex gap-4">
{/* 高速护栏 - 宽度为其他卡片的两倍 */}
<div className="w-1/2 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group1.items.app4.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group1.items.app4.name")}
</div>
</div>
{/* 桥梁 */}
<div className="w-1/4 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group1.items.app5.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group1.items.app5.name")}
</div>
</div>
{/* 钢结构 */}
<div className="w-1/4 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group1.items.app6.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group1.items.app6.name")}
</div>
</div>
</div>
</div>
{/* 第二组卡片拼图(可扩展更多组) */}
<div className="min-w-full flex flex-wrap gap-4 p-4">
{/* 第一行 */}
<div className="w-full flex gap-4 mb-4">
{/* 建筑工程 */}
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group2.items.app7.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group2.items.app7.name")}
</div>
</div>
{/* 水利水电 */}
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group2.items.app8.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group2.items.app8.name")}
</div>
</div>
{/* 轨道交通 */}
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group2.items.app9.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group2.items.app9.name")}
</div>
</div>
</div>
{/* 第二行 */}
<div className="w-full flex gap-4">
{/* 市政工程 */}
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group2.items.app10.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group2.items.app10.name")}
</div>
</div>
{/* 农业设施 */}
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group2.items.app11.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group2.items.app11.name")}
</div>
</div>
{/* 能源化工 */}
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt={t("applications.groups.group2.items.app12.alt")}
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
/>
<div className="absolute bottom-0 left-0 right-0 bg-black/60 text-white py-2 px-4">
{t("applications.groups.group2.items.app12.name")}
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
{/* 生产案例 */}
</section>
</>
);
}