import Link from 'next/link'
import { useRouter } from 'next/router'
import { useState } from 'react'
export const MenuItemDrop = ({ link }) => {
const [show, changeShow] = useState(false)
const hasSubMenu = link?.subMenus?.length > 0
const selected = useRouter().asPath === link?.to
if (!link || !link.show) {
return null
}
return (
changeShow(true)}
onMouseOut={() => changeShow(false)}
className='h-full'>
{!hasSubMenu && (
{link?.icon &&
}
{link?.name}
{/* {hasSubMenu &&
} */}
)}
{hasSubMenu && (
<>
{link?.icon &&
}
{link?.name}
{/*
*/}
>
)}
{/* 子菜单 */}
{hasSubMenu && (
{link.subMenus.map((sLink, index) => {
return (
-
{link?.icon && }
{sLink.title}
)
})}
)}
)
}