Files
novalon-website/src/components/ui/detail-swipe-nav.tsx
T
张翔 7f6128a6ff feat: 更新营销页面组件与交互优化
- 删除 .impeccable.md
- 新增 detail-swipe-nav, loading-state, skeleton, tooltip 组件
- 新增 use-keyboard-shortcuts, use-swipe-gesture hooks
- 更新 contact, news, products, services, solutions 等页面
- 优化 header, mobile-menu, input, page-transition 组件
- 添加 terms 与错误追踪测试页面
2026-05-14 18:21:54 +08:00

42 lines
1.3 KiB
TypeScript

'use client';
import { PRODUCTS, SERVICES } from '@/lib/constants';
import { SwipeNavigation } from '@/hooks/use-swipe-gesture';
interface DetailSwipeNavProps {
type: 'product' | 'service' | 'solution';
currentId: string;
className?: string;
}
export function DetailSwipeNav({ type, currentId, className }: DetailSwipeNavProps) {
let items: { id: string; title: string }[] = [];
if (type === 'product') {
items = PRODUCTS.map(p => ({ id: p.id, title: p.title }));
} else if (type === 'service') {
items = SERVICES.map(s => ({ id: s.id, title: s.title }));
} else {
return null;
}
const currentIndex = items.findIndex(item => item.id === currentId);
if (currentIndex === -1) return null;
const prevItem = currentIndex > 0 ? items[currentIndex - 1] : null;
const nextItem = currentIndex < items.length - 1 ? items[currentIndex + 1] : null;
const basePath = type === 'product' ? '/products' : type === 'service' ? '/services' : `/solutions`;
return (
<SwipeNavigation
prevRoute={prevItem ? `${basePath}/${prevItem.id}` : undefined}
nextRoute={nextItem ? `${basePath}/${nextItem.id}` : undefined}
prevLabel={prevItem?.title || ''}
nextLabel={nextItem?.title || ''}
className={className}
/>
);
}