首页菜单栏下拉页面调整高度1024适配
This commit is contained in:
@@ -9,6 +9,7 @@ import prod from '@/assets/header/product/prod.svg'
|
||||
import custom from '@/assets/header/product/custom.svg'
|
||||
import {HeaderContext} from '@/app/(home)/@header/_client/provider'
|
||||
import {useSearchParams} from 'next/navigation'
|
||||
import {useRouter} from 'next/navigation'
|
||||
|
||||
type TabType = 'domestic' | 'oversea'
|
||||
|
||||
@@ -100,9 +101,20 @@ export default function ProductMenu() {
|
||||
const urlType = searchParams?.get('type')
|
||||
console.log('URL参数:', urlType)
|
||||
}, [searchParams])
|
||||
// 响应式布局
|
||||
const [isMobile, setIsMobile] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const checkMobile = () => {
|
||||
setIsMobile(window.innerWidth <= 1024)
|
||||
}
|
||||
|
||||
checkMobile()
|
||||
window.addEventListener('resize', checkMobile)
|
||||
return () => window.removeEventListener('resize', checkMobile)
|
||||
}, [])
|
||||
return (
|
||||
<Wrap className="flex">
|
||||
<Wrap className="flex h-75">
|
||||
<ul role="tablist" className="w-48">
|
||||
<Tab selected={type === 'domestic'} onSelect={() => setType('domestic')}>国内代理</Tab>
|
||||
<Tab selected={type === 'oversea'} onSelect={() => setType('oversea')}>海外代理</Tab>
|
||||
@@ -145,12 +157,21 @@ export function DomesticLink(props: {
|
||||
active?: boolean
|
||||
}) {
|
||||
const ctx = useContext(HeaderContext)
|
||||
const router = useRouter()
|
||||
if (!ctx) {
|
||||
throw new Error(`HeaderContext not found`)
|
||||
}
|
||||
|
||||
const onClick = () => {
|
||||
// const onClick = () => {
|
||||
// ctx.setMenu(false)
|
||||
// }
|
||||
const onClick = (e: React.MouseEvent) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
ctx.setMenu(false)
|
||||
setTimeout(() => {
|
||||
router.push(props.href)
|
||||
}, ctx.isMobile ? 100 : 0)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user