Files
web/src/app/(home)/_components/header/menu-help.tsx

83 lines
2.3 KiB
TypeScript
Raw Normal View History

'use client'
import Link from 'next/link'
2025-03-28 15:00:46 +08:00
import Image, {StaticImageData} from 'next/image'
import Wrap from '@/components/wrap'
2025-03-18 18:00:29 +08:00
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, HeaderContext} from './common'
import {useContext} from 'react'
import {useRouter} from 'next/navigation'
2025-03-18 18:00:29 +08:00
export default function HelpMenu() {
return (
<Wrap className="w-full grid sm:grid-cols-3 lg:grid-cols-4 gap-4 justify-items-start">
2025-03-18 18:00:29 +08:00
<Column
icon={h01}
title="提取 IP"
2025-03-18 18:00:29 +08:00
items={[
{lead: '短效 IP 提取', href: '/collect?type=short'},
{lead: '长效 IP 提取', href: '/collect?type=long'},
2025-03-18 18:00:29 +08:00
]}
/>
<Column
icon={h02}
title="操作指南"
2025-03-18 18:00:29 +08:00
items={[
2026-01-14 17:27:31 +08:00
{lead: '修改信息', href: '/docs/profile-settings'},
{lead: '提取链接', href: '/docs/extract-link'},
{lead: '查看记录', href: '/docs/payment-records'},
2025-03-18 18:00:29 +08:00
]}
/>
<Column
icon={h03}
title="平台教程"
2025-03-18 18:00:29 +08:00
items={[
2026-01-14 17:27:31 +08:00
{lead: 'iOS 设置', href: '/docs/ios-proxy'},
{lead: 'Android 设置', href: '/docs/android-proxy'},
{lead: 'Windows 设置', href: '/docs/windows10-proxy'},
2025-03-18 18:00:29 +08:00
]}
/>
2025-06-18 17:57:12 +08:00
<Image src={banner} alt="banner" className="hidden lg:block"/>
2025-03-18 18:00:29 +08:00
</Wrap>
)
}
function Column(props: {
2025-03-28 15:00:46 +08:00
icon: StaticImageData
2025-03-18 18:00:29 +08:00
title: string
items: {
lead: string
href: string
}[]
}) {
const ctx = useContext(HeaderContext) // 获取菜单上下文
const router = useRouter()
if (!ctx) {
throw new Error(`HeaderContext not found`)
}
2025-03-18 18:00:29 +08:00
return (
<div className="flex-1 flex flex-col gap-4">
<FragmentTitle img={props.icon} text={props.title}/>
<ul className="flex flex-col gap-2">
2025-03-18 18:00:29 +08:00
{props.items.map((item, index) => (
<li key={index}>
<Link
href={item.href}
className="px-4 py-2"
onClick={() => {
ctx.setMenu(false)
router.push(item.href)
}}
>
{item.lead}
</Link>
</li>
2025-03-18 18:00:29 +08:00
))}
</ul>
</div>
)
2025-03-28 15:00:46 +08:00
}