修改下拉菜单栏选择选项后页面展示但菜单栏未关闭问题
This commit is contained in:
@@ -5,7 +5,9 @@ import h01 from '@/assets/header/help/01.svg'
|
||||
import h02 from '@/assets/header/help/02.svg'
|
||||
import h03 from '@/assets/header/help/03.svg'
|
||||
import banner from '@/assets/header/help/banner.webp'
|
||||
import {FragmentTitle} from '@/app/(home)/@header/common'
|
||||
import {FragmentTitle, HeaderContext} from './common'
|
||||
import {useContext} from 'react'
|
||||
import {useRouter} from 'next/navigation'
|
||||
|
||||
export default function HelpMenu() {
|
||||
return (
|
||||
@@ -49,13 +51,28 @@ function Column(props: {
|
||||
href: string
|
||||
}[]
|
||||
}) {
|
||||
const ctx = useContext(HeaderContext) // 获取菜单上下文
|
||||
const router = useRouter()
|
||||
|
||||
if (!ctx) {
|
||||
throw new Error(`HeaderContext not found`)
|
||||
}
|
||||
return (
|
||||
<div className="flex-1 flex flex-col gap-4">
|
||||
<FragmentTitle img={props.icon} text={props.title}/>
|
||||
<ul className="flex flex-col gap-2">
|
||||
{props.items.map((item, index) => (
|
||||
<li key={index}>
|
||||
<Link href={item.href} className="px-4 py-2">{item.lead}</Link>
|
||||
<Link
|
||||
href={item.href}
|
||||
className="px-4 py-2"
|
||||
onClick={() => {
|
||||
ctx.setMenu(false) // 点击时关闭菜单
|
||||
router.push(item.href) // 跳转页面
|
||||
}}
|
||||
>
|
||||
{item.lead}
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -8,8 +8,10 @@ import s06 from '@/assets/header/solution/06.svg'
|
||||
import s07 from '@/assets/header/solution/07.svg'
|
||||
import s08 from '@/assets/header/solution/08.svg'
|
||||
import {StaticImageData} from 'next/image'
|
||||
import {FragmentTitle} from '@/app/(home)/@header/common'
|
||||
import Link from 'next/link'
|
||||
import {useRouter} from 'next/navigation'
|
||||
import {useContext} from 'react'
|
||||
import {FragmentTitle, HeaderContext} from './common'
|
||||
|
||||
export default function SolutionMenu() {
|
||||
return (
|
||||
@@ -72,6 +74,16 @@ function SolutionItem(props: {
|
||||
desc: string
|
||||
href: string
|
||||
}) {
|
||||
const router = useRouter()
|
||||
const ctx = useContext(HeaderContext)
|
||||
if (!ctx) {
|
||||
throw new Error(`HeaderContext not found`)
|
||||
}
|
||||
|
||||
const onClick = () => {
|
||||
ctx.setMenu(false)
|
||||
router.push(props.href)
|
||||
}
|
||||
return (
|
||||
<Link
|
||||
href={props.href}
|
||||
@@ -79,6 +91,7 @@ function SolutionItem(props: {
|
||||
`flex flex-col gap-2 items-start rounded-md cursor-pointer`,
|
||||
`transition-colors duration-200 hover:bg-blue-50`,
|
||||
].join(' ')}
|
||||
onClick={onClick}
|
||||
>
|
||||
<FragmentTitle img={props.icon} text={props.title}/>
|
||||
<p className="text-gray-400 text-sm">{props.desc}</p>
|
||||
|
||||
@@ -9,7 +9,7 @@ export default function CollectPage(props: CollectPageProps) {
|
||||
<main className="mt-20 flex flex-col gap-4">
|
||||
<Wrap className="flex flex-col py-8 gap-8">
|
||||
<BreadCrumb items={[
|
||||
{label: 'IP 提取', href: '/collect'},
|
||||
{label: '短效IP 提取', href: '/collect'},
|
||||
]}/>
|
||||
<Extract/>
|
||||
</Wrap>
|
||||
|
||||
Reference in New Issue
Block a user