@@ -6,7 +6,7 @@ import { siteConfig } from '@/config/site';
66import { MenuIcon } from 'lucide-react' ;
77import Image from 'next/image' ;
88import Link from 'next/link' ;
9- import { useState } from 'react' ;
9+ import { useState , useEffect } from 'react' ;
1010import { CgClose } from 'react-icons/cg' ;
1111import { useParams } from 'next/navigation' ;
1212import { defaultLocale } from '@/lib/i18n' ;
@@ -24,6 +24,20 @@ const Header = ({ dict, CTALocale }: { dict: Dict; CTALocale: any }) => {
2424 const params = useParams < { lang : string } > ( ) ;
2525 const lang = params ?. lang || defaultLocale ;
2626
27+ useEffect ( ( ) => {
28+ if ( isMenuOpen ) {
29+ // 只在移动端锁定滚动
30+ if ( window . innerWidth < 768 ) {
31+ document . body . style . overflow = 'hidden' ;
32+ }
33+ } else {
34+ document . body . style . overflow = '' ;
35+ }
36+ return ( ) => {
37+ document . body . style . overflow = '' ;
38+ } ;
39+ } , [ isMenuOpen ] ) ;
40+
2741 return (
2842 < header className = "relative py-2 mx-auto max-w-8xl px-4 sm:px-6 lg:px-8 flex justify-between" >
2943 < nav className = "z-50 flex justify-between w-full fix-header" >
@@ -49,24 +63,27 @@ const Header = ({ dict, CTALocale }: { dict: Dict; CTALocale: any }) => {
4963 </ button >
5064
5165 { isMenuOpen && (
52- < div className = "absolute top-0 left-0 z-50 w-screen h-screen bg-overlay/50" >
53- < div className = "p-5 bg-background rounded shadow-sm" >
54- < div className = "flex items-center justify-between mb-4" >
66+ < div
67+ className = "absolute top-0 left-0 z-50 w-screen h-screen bg-overlay/50"
68+ onClick = { ( ) => setIsMenuOpen ( false ) }
69+ >
70+ < div className = "bg-background h-screen overflow-y-auto" onClick = { ( e ) => e . stopPropagation ( ) } >
71+ < div className = "px-4 sm:px-6 lg:px-8 flex items-center justify-between h-[56px]" >
5572 < LogoFC dict = { dict } lang = { lang } />
5673
5774 < div >
5875 < button
5976 aria-label = "Close Menu"
6077 title = "Close Menu"
61- className = "tracking-wide transition-colors duration-200 font-norma "
78+ className = "p-2 -mr-1 transition duration-200 rounded focus:outline-none focus:shadow-outline "
6279 onClick = { ( ) => setIsMenuOpen ( false ) }
6380 >
6481 < CgClose />
6582 </ button >
6683 </ div >
6784 </ div >
6885
69- < nav >
86+ < nav className = "px-4 sm:px-6 lg:px-8" >
7087 < ul className = "space-y-4" >
7188 { dict ?. links . map ( ( link ) => (
7289 < Link
@@ -83,7 +100,7 @@ const Header = ({ dict, CTALocale }: { dict: Dict; CTALocale: any }) => {
83100 </ ul >
84101 </ nav >
85102
86- < div className = "mt-4 border-t-1 flex flex-col gap-6 pt-4 border-white/10" >
103+ < div className = "mt-4 border-t pt-4 border-white/10 px-4 sm:px-6 lg:px-8 " >
87104 < LangSwitcher />
88105 </ div >
89106 </ div >
@@ -111,7 +128,7 @@ const LogoFC = ({ dict, lang }: { dict: Dict; lang: string }) => (
111128 width = { 32 }
112129 height = { 32 }
113130 />
114- < span className = "text-white hidden md:block " > FastGPT</ span >
131+ < span className = "text-white" > FastGPT</ span >
115132 </ Link >
116133
117134 < ul className = "hidden items-center gap-5 md:flex" >
0 commit comments