"use client"; import { MessageSquarePlus } from "lucide-react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { toast } from "sonner"; import { SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarTrigger, useSidebar, } from "@/components/ui/sidebar"; import { useThreadChat } from "@/components/workspace/chats"; import { useI18n } from "@/core/i18n/hooks"; import { POST_MESSAGE_TYPES, sendToParent } from "@/core/iframe-messages"; import { env } from "@/env"; import { cn } from "@/lib/utils"; import { copyToClipboard } from "@/lib/utils"; export function WorkspaceHeader({ className }: { className?: string }) { const { t } = useI18n(); const { state } = useSidebar(); const pathname = usePathname(); const { threadId } = useThreadChat(); const threadUrl = threadId ? `/workspace/chats/${threadId}` : ""; const handleCopyThreadId = async () => { if (!threadId) return; sendToParent({ type: POST_MESSAGE_TYPES.COPY_TO_CLIPBOARD, text: threadId, }); try { await copyToClipboard(threadId); toast.success(t.clipboard.copiedToClipboard); } catch { toast.error(t.clipboard.failedToCopyToClipboard); } }; return ( <>
{state === "collapsed" ? (
XC
) : (
{env.NEXT_PUBLIC_STATIC_WEBSITE_ONLY === "true" ? ( {t.workspaceHeader.sidebarTitle} ) : (
{/* TODO: 测试标识 */} XClaw{" "} v3.2.9 {" "} { void handleCopyThreadId(); }} title={threadId ? t.clipboard.copyToClipboard : undefined} > id:{threadId ? threadId.slice(0, 5) : "-"} {" "} {threadId && ( 打开 )}
)}
)}
{t.sidebar.newChat} ); }