2025-01-26 16:05:24 +08:00
|
|
|
|
import { Link, NavLink, useNavigate } from "react-router-dom";
|
2025-01-26 19:33:45 +08:00
|
|
|
|
import { memo } from "react";
|
2025-01-22 19:24:52 +08:00
|
|
|
|
import { SearchBar } from "./SearchBar";
|
2025-01-22 23:19:58 +08:00
|
|
|
|
import Navigation from "./navigation";
|
2025-01-23 23:59:49 +08:00
|
|
|
|
import { useAuth } from "@web/src/providers/auth-provider";
|
2025-01-24 17:37:51 +08:00
|
|
|
|
import { UserOutlined } from "@ant-design/icons";
|
2025-01-26 12:45:59 +08:00
|
|
|
|
import { UserMenu } from "../element/usermenu/usermenu";
|
2025-01-26 21:01:45 +08:00
|
|
|
|
import logo from "@web/src/assets/logo.png"
|
|
|
|
|
|
import { env } from "@web/src/env";
|
2025-01-26 16:05:24 +08:00
|
|
|
|
export const Header = memo(function Header() {
|
2025-01-26 18:24:16 +08:00
|
|
|
|
const { isAuthenticated } = useAuth();
|
|
|
|
|
|
return (
|
2025-01-26 21:01:45 +08:00
|
|
|
|
<header className="sticky top-0 z-50 bg-gradient-to-br from-primary-500 to-primary-800 text-white shadow-lg">
|
|
|
|
|
|
<div className="mx-auto px-4">
|
|
|
|
|
|
<div className="py-2 relative"> {/* 添加relative定位上下文 */}
|
2025-01-26 18:24:16 +08:00
|
|
|
|
<div className="flex items-center justify-between gap-4">
|
2025-01-26 21:01:45 +08:00
|
|
|
|
{/* 左侧logo部分 */}
|
|
|
|
|
|
<div className="flex items-center flex-shrink-0"> {/* 防止压缩 */}
|
|
|
|
|
|
<img className="w-24" src={logo} alt="logo" />
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<span className="text-xl font-bold"> {env.APP_NAME || '信箱'}</span>
|
|
|
|
|
|
<p className="text-sm text-secondary-50">
|
|
|
|
|
|
聆怀若水,应语如风;纾难化困,践诺成春
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
2025-01-26 18:24:16 +08:00
|
|
|
|
</div>
|
2025-01-24 17:37:51 +08:00
|
|
|
|
|
2025-01-26 21:01:45 +08:00
|
|
|
|
{/* 右侧登录部分 */}
|
|
|
|
|
|
<div className="flex items-center flex-shrink-0"> {/* 防止压缩 */}
|
|
|
|
|
|
{!isAuthenticated ? (
|
|
|
|
|
|
<Link to="/auth" className="...">
|
|
|
|
|
|
<UserOutlined className="..." />
|
2025-01-26 18:24:16 +08:00
|
|
|
|
<span>登录</span>
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
<UserMenu />
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
2025-01-26 21:01:45 +08:00
|
|
|
|
|
|
|
|
|
|
{/* 独立定位的搜索栏 */}
|
|
|
|
|
|
<div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-full max-w-2xl px-4">
|
|
|
|
|
|
<SearchBar />
|
|
|
|
|
|
</div>
|
2025-01-26 18:24:16 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<Navigation />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</header>
|
|
|
|
|
|
);
|
2025-01-26 21:01:45 +08:00
|
|
|
|
});
|