This commit is contained in:
ditiqi 2025-02-27 09:05:27 +08:00
parent d299da29c8
commit deb0bf25d2
1 changed files with 34 additions and 83 deletions

View File

@ -29,33 +29,31 @@ export function MainHeader() {
</div>
<NavigationMenu />
</div>
<div className="flex items-center space-x-6">
<div className="group relative">
<Input
size="large"
prefix={
<SearchOutlined className="text-gray-400 group-hover:text-blue-500 transition-colors" />
}
placeholder="搜索课程"
className="w-72 rounded-full"
value={searchValue}
onChange={(e) => setSearchValue(e.target.value)}
onPressEnter={(e) => {
if (
!window.location.pathname.startsWith(
"/courses/"
) &&
!window.location.pathname.startsWith("my")
) {
navigate(`/courses/`);
window.scrollTo({
top: 0,
behavior: "smooth",
});
}
}}
/>
</div>
</div>
<div className=" flex justify-end gap-4 mr-2">
<Input
size="large"
prefix={
<SearchOutlined className="text-gray-400 group-hover:text-blue-500 transition-colors" />
}
placeholder="搜索课程"
className="w-96 rounded-full"
value={searchValue}
onChange={(e) => setSearchValue(e.target.value)}
onPressEnter={(e) => {
if (
!window.location.pathname.startsWith("/courses/") &&
!window.location.pathname.startsWith("my")
) {
navigate(`/courses/`);
window.scrollTo({
top: 0,
behavior: "smooth",
});
}
}}
/>
<div className="flex items-center gap-4">
{isAuthenticated && (
<>
<Button
@ -71,6 +69,15 @@ export function MainHeader() {
</Button>
</>
)}
{isAuthenticated && (
<Button
onClick={() => {
window.location.href = "/path/editor";
}}
icon={<PlusOutlined></PlusOutlined>}>
</Button>
)}
{isAuthenticated ? (
<UserMenu />
) : (
@ -82,62 +89,6 @@ export function MainHeader() {
</Button>
)}
</div>
<NavigationMenu />
</div>
<Input
size="large"
prefix={
<SearchOutlined className="text-gray-400 group-hover:text-blue-500 transition-colors" />
}
placeholder="搜索课程"
className="w-96 rounded-full"
value={searchValue}
onChange={(e) => setSearchValue(e.target.value)}
onPressEnter={(e) => {
if (!window.location.pathname.startsWith("/courses/")) {
navigate(`/courses/`);
window.scrollTo({
top: 0,
behavior: "smooth",
});
}
}}
/>
<div className="flex items-center gap-4">
{isAuthenticated && (
<>
<Button
onClick={() => {
const url = id
? `/course/${id}/editor`
: "/course/editor";
navigate(url);
}}
className="flex items-center space-x-1 bg-gradient-to-r from-blue-500 to-blue-600 text-white hover:from-blue-600 hover:to-blue-700 border-none shadow-md hover:shadow-lg transition-all"
icon={<EditFilled />}>
{id ? "编辑课程" : "创建课程"}
</Button>
</>
)}
{isAuthenticated && (
<Button
onClick={() => {
window.location.href = "/path/editor";
}}
icon={<PlusOutlined></PlusOutlined>}>
</Button>
)}
{isAuthenticated ? (
<UserMenu />
) : (
<Button
onClick={() => navigate("/login")}
className="flex items-center space-x-1 bg-gradient-to-r from-blue-500 to-blue-600 text-white hover:from-blue-600 hover:to-blue-700 border-none shadow-md hover:shadow-lg transition-all"
icon={<UserOutlined />}>
</Button>
)}
</div>
</div>
);