11import { Clover , Film , Home , Search , Tv } from 'lucide-react' ;
22import Link from 'next/link' ;
3- import { usePathname , useRouter , useSearchParams } from 'next/navigation' ;
3+ import { usePathname , useRouter } from 'next/navigation' ;
44import { useCallback , useEffect , useState } from 'react' ;
55
66import { BackButton } from './BackButton' ;
@@ -19,25 +19,14 @@ interface PageLayoutProps {
1919const TopNavbar = ( { activePath = '/' } : { activePath ?: string } ) => {
2020 const router = useRouter ( ) ;
2121 const pathname = usePathname ( ) ;
22- const searchParams = useSearchParams ( ) ;
2322 const { siteName } = useSite ( ) ;
2423
2524 const [ active , setActive ] = useState ( activePath ) ;
2625
2726 useEffect ( ( ) => {
28- // 优先使用传入的 activePath
29- if ( activePath ) {
30- setActive ( activePath ) ;
31- } else {
32- // 否则使用当前路径
33- const getCurrentFullPath = ( ) => {
34- const queryString = searchParams . toString ( ) ;
35- return queryString ? `${ pathname } ?${ queryString } ` : pathname ;
36- } ;
37- const fullPath = getCurrentFullPath ( ) ;
38- setActive ( fullPath ) ;
39- }
40- } , [ activePath , pathname , searchParams ] ) ;
27+ // 优先使用传入的 activePath,否则使用当前路径
28+ setActive ( activePath || pathname ) ;
29+ } , [ activePath , pathname ] ) ;
4130
4231 const handleSearchClick = useCallback ( ( ) => {
4332 router . push ( '/search' ) ;
0 commit comments