Files
page-assist/src/components/Layouts/Header.tsx

68 lines
2.2 KiB
TypeScript
Raw Normal View History

import React, { useContext } from "react"
import { HistoryContext } from "@/components/Layouts/Layout.tsx"
import { PanelLeftIcon } from "lucide-react"
import { Button } from "antd"
import { PlusOutlined } from "@ant-design/icons"
import { useMessageOption } from "@/hooks/useMessageOption.tsx"
import { useTranslation } from "react-i18next"
2024-05-31 13:50:05 +05:30
export const Header = () => {
const { show, setShow } = useContext(HistoryContext)
2024-05-31 13:50:05 +05:30
const { t } = useTranslation(["option", "common", "settings"])
2024-05-31 13:50:05 +05:30
const { clearChat } = useMessageOption()
2024-05-31 13:50:05 +05:30
return (
<div
className={`w-full h-[60px] absolute inset-0 pl-5 z-10 flex items-center transition-all duration-300 ease-in-out ${show ? "left-[300px]" : ""}`}>
{/*控制侧边栏显示隐藏与新建对话*/}
{!show && (
<div className="flex items-center gap-3">
2024-05-31 13:50:05 +05:30
<button
className="text-gray-500 dark:text-gray-400"
onClick={() => {
setShow(!show)
}}>
2024-05-31 13:50:05 +05:30
<PanelLeftIcon className="w-6 h-6" />
</button>
<Button
color="cyan"
variant="filled"
shape="round"
style={{
color: "#0057ff",
background: "#0057ff0f",
border: "1px solid #0066ff26"
2025-01-25 15:19:28 +05:30
}}
onClick={clearChat}>
<div className="flex items-center justify-between w-full">
<div className="flex items-center">
<PlusOutlined
className="text-sm"
style={{ fontSize: "16px", fontWeight: 500 }}
/>
<span>{t("newChat")}</span>
</div>
</div>
</Button>
2024-05-31 13:50:05 +05:30
</div>
)}
{/* 项目标题 */}
<div
className={`
absolute left-1/2 transform -translate-x-1/2
w-[600px] h-[55px] bg-white dark:bg-black
flex items-center justify-center
shadow-[0px_0px_5px_rgba(0,0,0,0.2)]
rounded-b-[15px]
transition-[top]
${show ? "-top-[56px]" : "-top-[1px] delay-200"}
`}>
<h2 className="text-xl font-bold text-zinc-700 dark:text-zinc-300 mr-3">
<span className="text-[#d30100]"></span>
</h2>
2024-05-31 13:50:05 +05:30
</div>
</div>
)
}