feat: 更新国际化内容和优化首页组件

refactor: 移除调试日志和简化博客页面逻辑

docs: 更新多语言翻译文件,添加公司信息、产品中心和应用领域等内容
This commit is contained in:
砂糖
2025-12-03 16:21:56 +08:00
parent effdee935a
commit de67af263e
7 changed files with 586 additions and 204 deletions

View File

@@ -4,6 +4,9 @@ import { useTranslations } from "next-intl";
export default function HomeComponent() {
const t = useTranslations("Home");
// 客户端组件中直接使用翻译键next-intl 会自动处理
// 注意:在客户端组件中,我们不能使用 raw() 函数,需要直接访问翻译键
return (
<>
<section className="mx-auto text-center">
@@ -24,20 +27,20 @@ export default function HomeComponent() {
<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"></h2>
<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">
'友发''正金'西10
{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>
@@ -50,39 +53,39 @@ export default function HomeComponent() {
{/* 第一组卡片 */}
<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">5</div>
<div className="text-gray-700">绿</div>
<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">3+</div>
<div className="text-gray-700">绿</div>
<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">7</div>
<div className="text-gray-700">CNAS</div>
<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">10</div>
<div className="text-gray-700"></div>
<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">5</div>
<div className="text-gray-700">绿</div>
<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">3+</div>
<div className="text-gray-700">绿</div>
<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">7</div>
<div className="text-gray-700">CNAS</div>
<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">10</div>
<div className="text-gray-700"></div>
<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>
@@ -108,7 +111,7 @@ export default function HomeComponent() {
{/* 标题 */}
<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>
@@ -118,33 +121,33 @@ export default function HomeComponent() {
{/* 第一张卡片 */}
<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">2025/11/17</div>
<div className="text-gray-800 mb-3 line-clamp-1 text-base whitespace-nowrap overflow-hidden text-ellipsis">202...</div>
<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="资讯图片1" className="w-full h-full object-cover rounded" />
<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">2025/11/17</div>
<div className="text-gray-800 mb-3 line-clamp-1 text-base whitespace-nowrap overflow-hidden text-ellipsis">...</div>
<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="资讯图片2" className="w-full h-full object-cover rounded" />
<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">2025/09/20</div>
<div className="text-gray-800 mb-3 line-clamp-1 text-base whitespace-nowrap overflow-hidden text-ellipsis">...</div>
<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="资讯图片3" className="w-full h-full object-cover rounded" />
<img src="/placeholder.svg" alt={t("news.items.news3.title")} className="w-full h-full object-cover rounded" />
</div>
</div>
</div>
@@ -152,7 +155,7 @@ export default function HomeComponent() {
{/* 了解更多按钮 */}
<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">
&gt;
{t("news.button")}
</button>
</div>
</div>
@@ -160,7 +163,7 @@ export default function HomeComponent() {
<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>
@@ -173,13 +176,13 @@ export default function HomeComponent() {
<img
id="productImage"
src="/placeholder.svg"
alt="直缝高频焊接圆管"
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">()</h3>
<h3 id="productTitle" className="text-white text-2xl font-bold">{t("products.list.product1.name")}</h3>
</div>
</div>
@@ -190,11 +193,11 @@ export default function HomeComponent() {
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', '直缝高频焊接圆管');
document.getElementById('productTitle')!.textContent = '直缝高频焊接圆管(含热浸镀锌)';
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product1.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product1.name");
}}
>
<span>()</span>
<span>{t("products.list.product1.name")}</span>
</div>
{/* 产品2 */}
@@ -202,11 +205,11 @@ export default function HomeComponent() {
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', '方形焊接钢管');
document.getElementById('productTitle')!.textContent = '方形焊接钢管(含热浸镀锌)';
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product2.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product2.name");
}}
>
<span>()</span>
<span>{t("products.list.product2.name")}</span>
</div>
{/* 产品3 */}
@@ -214,11 +217,11 @@ export default function HomeComponent() {
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', '钢塑复合管');
document.getElementById('productTitle')!.textContent = '钢塑复合管';
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product3.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product3.name");
}}
>
<span></span>
<span>{t("products.list.product3.name")}</span>
</div>
{/* 产品4 */}
@@ -226,11 +229,11 @@ export default function HomeComponent() {
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', '管路连接件');
document.getElementById('productTitle')!.textContent = '管路连接件';
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product4.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product4.name");
}}
>
<span></span>
<span>{t("products.list.product4.name")}</span>
</div>
{/* 产品5 */}
@@ -238,11 +241,11 @@ export default function HomeComponent() {
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', '盘扣脚手架');
document.getElementById('productTitle')!.textContent = '盘扣脚手架';
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product5.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product5.name");
}}
>
<span></span>
<span>{t("products.list.product5.name")}</span>
</div>
{/* 产品6 */}
@@ -250,11 +253,11 @@ export default function HomeComponent() {
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', '不锈钢管及管件');
document.getElementById('productTitle')!.textContent = '不锈钢管及管件';
document.getElementById('productImage')?.setAttribute('alt', t("products.list.product6.alt"));
document.getElementById('productTitle')!.textContent = t("products.list.product6.name");
}}
>
<span></span>
<span>{t("products.list.product6.name")}</span>
</div>
</div>
</div>
@@ -265,7 +268,7 @@ export default function HomeComponent() {
{/* 标题 */}
<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>
@@ -303,11 +306,11 @@ export default function HomeComponent() {
<div className="w-1/4 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="电梯井道"
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>
@@ -315,11 +318,11 @@ export default function HomeComponent() {
<div className="w-1/2 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="塔机制造"
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>
@@ -327,11 +330,11 @@ export default function HomeComponent() {
<div className="w-1/4 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="工程机械"
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>
@@ -342,11 +345,11 @@ export default function HomeComponent() {
<div className="w-1/2 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="高速护栏"
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>
@@ -354,11 +357,11 @@ export default function HomeComponent() {
<div className="w-1/4 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="桥梁"
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>
@@ -366,11 +369,11 @@ export default function HomeComponent() {
<div className="w-1/4 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="钢结构"
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>
@@ -384,11 +387,11 @@ export default function HomeComponent() {
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="建筑工程"
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>
@@ -396,11 +399,11 @@ export default function HomeComponent() {
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="水利水电"
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>
@@ -408,11 +411,11 @@ export default function HomeComponent() {
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="轨道交通"
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>
@@ -423,11 +426,11 @@ export default function HomeComponent() {
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="市政工程"
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>
@@ -435,11 +438,11 @@ export default function HomeComponent() {
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="农业设施"
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>
@@ -447,11 +450,11 @@ export default function HomeComponent() {
<div className="w-1/3 relative overflow-hidden rounded-lg">
<img
src="/placeholder.svg"
alt="能源化工"
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>