'use client'; import { useState, useMemo, useRef, ChangeEvent } from 'react'; import { useInView } from 'framer-motion'; import { NEWS } from '@/lib/constants'; import { Card, CardContent } from '@/components/ui/card'; import { Badge } from '@/components/ui/badge'; import { Input } from '@/components/ui/input'; import { Button } from '@/components/ui/button'; import { PageHeader } from '@/components/ui/page-header'; import { Search, Calendar, Filter, ArrowRight, SearchX } from 'lucide-react'; import { StaticLink } from '@/components/ui/static-link'; import { motion } from 'framer-motion'; import { Pagination } from '@/components/ui/pagination'; const categories = ['全部', '公司新闻', '产品发布', '研发动态']; const ITEMS_PER_PAGE = 9; export default function NewsListPage() { const [selectedCategory, setSelectedCategory] = useState('全部'); const [searchQuery, setSearchQuery] = useState(''); const [currentPage, setCurrentPage] = useState(1); const contentRef = useRef(null); const isContentInView = useInView(contentRef, { once: true, margin: '-100px' }); const filteredNews = useMemo(() => { return NEWS.filter((newsItem) => { const matchesCategory = selectedCategory === '全部' || newsItem.category === selectedCategory; const matchesSearch = newsItem.title.toLowerCase().includes(searchQuery.toLowerCase()) || newsItem.excerpt.toLowerCase().includes(searchQuery.toLowerCase()); return matchesCategory && matchesSearch; }).sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()); }, [selectedCategory, searchQuery]); const totalPages = Math.ceil(filteredNews.length / ITEMS_PER_PAGE); const paginatedNews = useMemo(() => { const startIndex = (currentPage - 1) * ITEMS_PER_PAGE; const endIndex = startIndex + ITEMS_PER_PAGE; return filteredNews.slice(startIndex, endIndex); }, [filteredNews, currentPage]); const handlePageChange = (page: number) => { setCurrentPage(page); }; const handleCategoryChange = (category: string) => { setSelectedCategory(category); setCurrentPage(1); }; const handleSearchChange = (e: ChangeEvent) => { setSearchQuery(e.target.value); setCurrentPage(1); }; return (
分类筛选:
{categories.map((category) => ( ))}
{paginatedNews.length === 0 ? (

没有找到相关新闻

) : ( <>
{paginatedNews.map((newsItem, index) => ( {newsItem.image ? (
{newsItem.title}
) : (
📰
)}
{newsItem.category}
{newsItem.date}

{newsItem.title}

{newsItem.excerpt}

阅读更多
))}
显示 {paginatedNews.length} 条,共 {filteredNews.length} 条新闻
)} {/* Bottom CTA */}

想获取最新行业资讯?

关注我们的公众号,第一时间了解数字化转型趋势和公司动态

); }