feat: 添加产品中心功能并优化博客系统
- 新增产品中心功能,包括产品列表页和详情页 - 实现产品多语言支持(中文、英文、越南语) - 重构博客系统,从API获取改为本地MDX文件管理 - 更新favicon为PNG格式并修复相关引用 - 添加产品类型定义和获取逻辑 - 优化首页应用场景图片和链接 - 完善国际化配置和翻译 - 新增产品详情页标签切换组件 - 修复代理配置中的favicon路径问题
This commit is contained in:
57
components/ProductTabsClient.tsx
Normal file
57
components/ProductTabsClient.tsx
Normal file
@@ -0,0 +1,57 @@
|
||||
// @/components/ProductTabsClient.tsx (客户端组件)
|
||||
'use client';
|
||||
import { useTranslations } from 'next-intl';
|
||||
import { useState } from 'react';
|
||||
|
||||
type ProductTabsClientProps = {
|
||||
detail: string;
|
||||
spec: string[];
|
||||
packaging: string;
|
||||
locale: string;
|
||||
};
|
||||
|
||||
// 纯客户端交互组件(仅处理标签页切换)
|
||||
export default function ProductTabsClient({ detail, spec, packaging, locale }: ProductTabsClientProps) {
|
||||
const [activeTab, setActiveTab] = useState('spec'); // 仅客户端使用状态
|
||||
const t = useTranslations("Product");
|
||||
|
||||
return (
|
||||
<div className="border rounded">
|
||||
{/* 标签栏 */}
|
||||
<div className="flex border-b">
|
||||
<button
|
||||
className={`px-4 py-2 border-r transition-colors ${activeTab === 'detail' ? 'bg-orange-50 text-orange-600 font-medium' : 'hover:bg-gray-50'}`}
|
||||
onClick={() => setActiveTab('detail')}
|
||||
>
|
||||
{t('productDetail')}
|
||||
</button>
|
||||
<button
|
||||
className={`px-4 py-2 border-r transition-colors ${activeTab === 'spec' ? 'bg-orange-50 text-orange-600 font-medium' : 'hover:bg-gray-50'}`}
|
||||
onClick={() => setActiveTab('spec')}
|
||||
>
|
||||
{t('productSpec')}
|
||||
</button>
|
||||
<button
|
||||
className={`px-4 py-2 transition-colors ${activeTab === 'packaging' ? 'bg-orange-50 text-orange-600 font-medium' : 'hover:bg-gray-50'}`}
|
||||
onClick={() => setActiveTab('packaging')}
|
||||
>
|
||||
{t('productPackaging')}
|
||||
</button>
|
||||
</div>
|
||||
{/* 内容区 */}
|
||||
<div className="p-4">
|
||||
{activeTab === 'detail' && <div className="text-gray-800">{detail || t('productNoDetail')}</div>}
|
||||
{activeTab === 'spec' && (
|
||||
spec.length > 0 ? (
|
||||
<div className="space-y-1 text-gray-800">
|
||||
{spec.map((item, idx) => <div key={idx}>{item}</div>)}
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-gray-500">{t('productNoSpec')}</p>
|
||||
)
|
||||
)}
|
||||
{activeTab === 'packaging' && <div className="text-gray-800">{packaging || t('productNoPacking')}</div>}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -28,7 +28,7 @@ const WebsiteLogo = ({
|
||||
`https://${domain}/apple-touch-icon-precomposed.png`,
|
||||
`https://www.google.com/s2/favicons?domain=${domain}&sz=64`,
|
||||
`https://icons.duckduckgo.com/ip3/${domain}.ico`,
|
||||
`https://${domain}/favicon.ico`,
|
||||
`https://${domain}/favicon.png`,
|
||||
];
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -41,9 +41,11 @@ export default function HomeComponent() {
|
||||
|
||||
{/* 第三部分:按钮 */}
|
||||
<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>
|
||||
<I18nLink href="/about">
|
||||
<button className="bg-red-600 hover:bg-red-700 text-white font-medium py-2 px-6 rounded transition-colors">
|
||||
{t("company.button")}
|
||||
</button>
|
||||
</I18nLink>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -163,9 +165,11 @@ 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">
|
||||
{t("news.button")}
|
||||
</button>
|
||||
<I18nLink href="/blog">
|
||||
<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>
|
||||
</I18nLink>
|
||||
</div>
|
||||
</div>
|
||||
{/* 产品中心 */}
|
||||
@@ -314,7 +318,7 @@ export default function HomeComponent() {
|
||||
{/* 电梯井道 */}
|
||||
<div className="w-1/4 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group1.items.app1.image")}
|
||||
alt={t("applications.groups.group1.items.app1.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -326,7 +330,7 @@ export default function HomeComponent() {
|
||||
{/* 塔机制造 - 宽度为其他卡片的两倍 */}
|
||||
<div className="w-1/2 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group1.items.app2.image")}
|
||||
alt={t("applications.groups.group1.items.app2.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -338,7 +342,7 @@ export default function HomeComponent() {
|
||||
{/* 工程机械 */}
|
||||
<div className="w-1/4 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group1.items.app3.image")}
|
||||
alt={t("applications.groups.group1.items.app3.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -353,7 +357,7 @@ export default function HomeComponent() {
|
||||
{/* 高速护栏 - 宽度为其他卡片的两倍 */}
|
||||
<div className="w-1/2 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group1.items.app4.image")}
|
||||
alt={t("applications.groups.group1.items.app4.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -365,7 +369,7 @@ export default function HomeComponent() {
|
||||
{/* 桥梁 */}
|
||||
<div className="w-1/4 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group1.items.app5.image")}
|
||||
alt={t("applications.groups.group1.items.app5.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -377,7 +381,7 @@ export default function HomeComponent() {
|
||||
{/* 钢结构 */}
|
||||
<div className="w-1/4 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group1.items.app6.image")}
|
||||
alt={t("applications.groups.group1.items.app6.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -395,7 +399,7 @@ export default function HomeComponent() {
|
||||
{/* 建筑工程 */}
|
||||
<div className="w-1/3 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group2.items.app7.image")}
|
||||
alt={t("applications.groups.group2.items.app7.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -407,7 +411,7 @@ export default function HomeComponent() {
|
||||
{/* 水利水电 */}
|
||||
<div className="w-1/3 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group2.items.app8.image")}
|
||||
alt={t("applications.groups.group2.items.app8.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -419,7 +423,7 @@ export default function HomeComponent() {
|
||||
{/* 轨道交通 */}
|
||||
<div className="w-1/3 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group2.items.app9.image")}
|
||||
alt={t("applications.groups.group2.items.app9.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -434,7 +438,7 @@ export default function HomeComponent() {
|
||||
{/* 市政工程 */}
|
||||
<div className="w-1/3 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group2.items.app10.image")}
|
||||
alt={t("applications.groups.group2.items.app10.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -446,7 +450,7 @@ export default function HomeComponent() {
|
||||
{/* 农业设施 */}
|
||||
<div className="w-1/3 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group2.items.app11.image")}
|
||||
alt={t("applications.groups.group2.items.app11.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
@@ -458,7 +462,7 @@ export default function HomeComponent() {
|
||||
{/* 能源化工 */}
|
||||
<div className="w-1/3 relative overflow-hidden rounded-lg">
|
||||
<img
|
||||
src="/placeholder.svg"
|
||||
src={t("applications.groups.group2.items.app12.image")}
|
||||
alt={t("applications.groups.group2.items.app12.alt")}
|
||||
className="w-full h-[280px] object-cover hover:scale-105 transition-transform duration-300"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user