96 lines
2.7 KiB
TypeScript
96 lines
2.7 KiB
TypeScript
|
|
"use client"
|
||
|
|
|
||
|
|
import Link from "next/link"
|
||
|
|
import { usePathname } from "next/navigation"
|
||
|
|
|
||
|
|
import {
|
||
|
|
DropdownMenu,
|
||
|
|
DropdownMenuContent,
|
||
|
|
DropdownMenuItem,
|
||
|
|
DropdownMenuSeparator,
|
||
|
|
DropdownMenuTrigger,
|
||
|
|
} from "@/components/ui/dropdown-menu"
|
||
|
|
import {
|
||
|
|
SidebarGroup,
|
||
|
|
SidebarGroupLabel,
|
||
|
|
SidebarMenu,
|
||
|
|
SidebarMenuAction,
|
||
|
|
SidebarMenuButton,
|
||
|
|
SidebarMenuItem,
|
||
|
|
useSidebar,
|
||
|
|
} from "@/components/ui/sidebar"
|
||
|
|
import { MoreHorizontalIcon, FolderIcon, ShareIcon, Trash2Icon } from "lucide-react"
|
||
|
|
|
||
|
|
export function NavDocuments({
|
||
|
|
items,
|
||
|
|
}: {
|
||
|
|
items: ReadonlyArray<{
|
||
|
|
name: string
|
||
|
|
url: string
|
||
|
|
icon: React.ReactNode
|
||
|
|
}>
|
||
|
|
}) {
|
||
|
|
const pathname = usePathname()
|
||
|
|
const { isMobile } = useSidebar()
|
||
|
|
return (
|
||
|
|
<SidebarGroup className="group-data-[collapsible=icon]:hidden">
|
||
|
|
<SidebarGroupLabel>业务模块</SidebarGroupLabel>
|
||
|
|
<SidebarMenu>
|
||
|
|
{items.map((item) => (
|
||
|
|
<SidebarMenuItem key={item.name}>
|
||
|
|
<SidebarMenuButton
|
||
|
|
render={<Link href={item.url} />}
|
||
|
|
isActive={pathname === item.url}
|
||
|
|
>
|
||
|
|
{item.icon}
|
||
|
|
<span>{item.name}</span>
|
||
|
|
</SidebarMenuButton>
|
||
|
|
<DropdownMenu>
|
||
|
|
<DropdownMenuTrigger
|
||
|
|
render={
|
||
|
|
<SidebarMenuAction
|
||
|
|
showOnHover
|
||
|
|
className="aria-expanded:bg-muted"
|
||
|
|
/>
|
||
|
|
}
|
||
|
|
>
|
||
|
|
<MoreHorizontalIcon
|
||
|
|
/>
|
||
|
|
<span className="sr-only">More</span>
|
||
|
|
</DropdownMenuTrigger>
|
||
|
|
<DropdownMenuContent
|
||
|
|
className="w-24"
|
||
|
|
side={isMobile ? "bottom" : "right"}
|
||
|
|
align={isMobile ? "end" : "start"}
|
||
|
|
>
|
||
|
|
<DropdownMenuItem>
|
||
|
|
<FolderIcon
|
||
|
|
/>
|
||
|
|
<span>打开</span>
|
||
|
|
</DropdownMenuItem>
|
||
|
|
<DropdownMenuItem>
|
||
|
|
<ShareIcon
|
||
|
|
/>
|
||
|
|
<span>分享</span>
|
||
|
|
</DropdownMenuItem>
|
||
|
|
<DropdownMenuSeparator />
|
||
|
|
<DropdownMenuItem variant="destructive">
|
||
|
|
<Trash2Icon
|
||
|
|
/>
|
||
|
|
<span>删除</span>
|
||
|
|
</DropdownMenuItem>
|
||
|
|
</DropdownMenuContent>
|
||
|
|
</DropdownMenu>
|
||
|
|
</SidebarMenuItem>
|
||
|
|
))}
|
||
|
|
<SidebarMenuItem>
|
||
|
|
<SidebarMenuButton className="text-sidebar-foreground/70">
|
||
|
|
<MoreHorizontalIcon className="text-sidebar-foreground/70" />
|
||
|
|
<span>更多</span>
|
||
|
|
</SidebarMenuButton>
|
||
|
|
</SidebarMenuItem>
|
||
|
|
</SidebarMenu>
|
||
|
|
</SidebarGroup>
|
||
|
|
)
|
||
|
|
}
|