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