"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { type ReactNode, useMemo } from "react"; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/components/ui/breadcrumb"; import { useI18n } from "@/core/i18n/hooks"; import { cn } from "@/lib/utils"; export function WorkspaceContainer({ className, children, ...props }: React.ComponentProps<"div">) { // h-full 而非 h-screen:本容器恒在 WorkspaceRoutes 的 SidebarInset(flex-1,确定高度)下, // h-full 既跟随容器高度(无界等嵌套不再锁死整屏),又修掉原 h-screen=100vh 比可用区域 // 高出一个页头高度的溢出。 return (
{children}
); } export function WorkspaceHeader({ className, children, rightActions, ...props }: React.ComponentProps<"header"> & { rightActions?: ReactNode; }) { const { t } = useI18n(); const pathname = usePathname(); const segments = useMemo(() => { const parts = pathname?.split("/") || []; if (parts.length > 0) { return parts.slice(1, 3); } }, [pathname]); return (
{segments?.[0] && ( {nameOfSegment(segments[0], t)} )} {segments?.[1] && ( <> {segments.length >= 2 ? ( {nameOfSegment(segments[1], t)} ) : ( {nameOfSegment(segments[1], t)} )} )} {children && ( <> {children} )}
{rightActions ? (
{rightActions}
) : null}
); } export function WorkspaceBody({ className, children, ...props }: React.ComponentProps<"main">) { return (
{children}
); } function nameOfSegment( segment: string | undefined, t: ReturnType["t"], ) { if (!segment) return t.common.home; if (segment === "workspace") return t.breadcrumb.workspace; if (segment === "chats") return t.breadcrumb.chats; return segment[0]?.toUpperCase() + segment.slice(1); }