- 新增产品中心功能,包括产品列表页和详情页 - 实现产品多语言支持(中文、英文、越南语) - 重构博客系统,从API获取改为本地MDX文件管理 - 更新favicon为PNG格式并修复相关引用 - 添加产品类型定义和获取逻辑 - 优化首页应用场景图片和链接 - 完善国际化配置和翻译 - 新增产品详情页标签切换组件 - 修复代理配置中的favicon路径问题
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
// @/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>
|
|
);
|
|
} |