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> </div>
<NavigationMenu /> <NavigationMenu />
</div> </div>
<div className="flex items-center space-x-6"> </div>
<div className="group relative"> <div className=" flex justify-end gap-4 mr-2">
<Input <Input
size="large" size="large"
prefix={ prefix={
<SearchOutlined className="text-gray-400 group-hover:text-blue-500 transition-colors" /> <SearchOutlined className="text-gray-400 group-hover:text-blue-500 transition-colors" />
} }
placeholder="搜索课程" placeholder="搜索课程"
className="w-72 rounded-full" className="w-96 rounded-full"
value={searchValue} value={searchValue}
onChange={(e) => setSearchValue(e.target.value)} onChange={(e) => setSearchValue(e.target.value)}
onPressEnter={(e) => { onPressEnter={(e) => {
if ( if (
!window.location.pathname.startsWith( !window.location.pathname.startsWith("/courses/") &&
"/courses/" !window.location.pathname.startsWith("my")
) && ) {
!window.location.pathname.startsWith("my") navigate(`/courses/`);
) { window.scrollTo({
navigate(`/courses/`); top: 0,
window.scrollTo({ behavior: "smooth",
top: 0, });
behavior: "smooth", }
}); }}
} />
}} <div className="flex items-center gap-4">
/>
</div>
{isAuthenticated && ( {isAuthenticated && (
<> <>
<Button <Button
@ -71,6 +69,15 @@ export function MainHeader() {
</Button> </Button>
</> </>
)} )}
{isAuthenticated && (
<Button
onClick={() => {
window.location.href = "/path/editor";
}}
icon={<PlusOutlined></PlusOutlined>}>
</Button>
)}
{isAuthenticated ? ( {isAuthenticated ? (
<UserMenu /> <UserMenu />
) : ( ) : (
@ -82,62 +89,6 @@ export function MainHeader() {
</Button> </Button>
)} )}
</div> </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>
</div> </div>
); );