From fc6b0d3a7cd1bb26e55ff9424cc612aecb217c9d Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Wed, 19 Nov 2025 15:53:36 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=AF=BC=E8=88=AA?= =?UTF-8?q?=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/news/header/TopNav.tsx | 62 +++++++++++++++------------ 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/app/components/news/header/TopNav.tsx b/app/components/news/header/TopNav.tsx index f5dfd1f..d9247a3 100644 --- a/app/components/news/header/TopNav.tsx +++ b/app/components/news/header/TopNav.tsx @@ -1,6 +1,6 @@ import { Search } from 'lucide-react'; import React, { useState } from 'react'; - +import { Button } from '@/ui/button'; interface MenuItem { label: string; key: string; @@ -60,46 +60,54 @@ export function TopNav({ }; return ( -
+ // 将组件宽度调整为1514px,并保持居中 +
{/* 搜索框与导航菜单组合 */} -
+
{/* 搜索框 */} -
-
- setSearchKeyword(e.target.value)} - placeholder="搜索..." - className="pl-10 pr-4 py-2 text-sm rounded-lg border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent w-64 transition-all duration-200 hover:shadow-sm" - /> - - - -
-
- {/* 导航菜单 */} -
    +
    + + + setSearchKeyword(e.target.value)} + className="pl-5 pr-4 py-2 text-sm h-full border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent w-64 transition-all duration-200 hover:shadow-sm" /> +
    + + + {/* 导航菜单 */} +
      {menuItems.map((item) => { - const isActive = currentActiveKey === item.key; // 判断当前项是否激活 + const isActive = currentActiveKey === item.key; return ( -
    • +
    • ); })}
    + + +
); -}; +}; \ No newline at end of file From fffc57ce8324ada7bd45dfd10c1059fe29df454b Mon Sep 17 00:00:00 2001 From: qiuchenfan <2035024011@qq.com> Date: Wed, 19 Nov 2025 16:01:05 +0800 Subject: [PATCH 2/2] =?UTF-8?q?s=E5=88=A0=E9=99=A4=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/news/header/TopNav.tsx | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/components/news/header/TopNav.tsx b/app/components/news/header/TopNav.tsx index d52002f..8eaf5ed 100644 --- a/app/components/news/header/TopNav.tsx +++ b/app/components/news/header/TopNav.tsx @@ -29,15 +29,7 @@ export function TopNav({ const [internalActiveKey, setInternalActiveKey] = useState('home'); const currentActiveKey = externalActiveKey !== undefined ? externalActiveKey : internalActiveKey; const [searchKeyword, setSearchKeyword] = useState(''); - // const [activeIndex, setActiveIndex] = useState(0); - // const [prevIndex, setPrevIndex] = useState(0); - - // 监听激活项变化,更新索引和动画方向 - // useEffect(() => { - // const currentIndex = menuItems.findIndex(item => item.key === currentActiveKey); - // setPrevIndex(activeIndex); - // setActiveIndex(currentIndex); - // }, [currentActiveKey, menuItems, activeIndex]); + const handleSearchSubmit = (e: React.FormEvent) => { e.preventDefault();