mirror of
https://github.com/songquanpeng/one-api.git
synced 2025-10-28 20:33:42 +08:00
* feat: add theme berry * docs: add development notes * fix: fix blank page * chore: update implementation * fix: fix package.json * chore: update ui copy --------- Co-authored-by: JustSong <songquanpeng@foxmail.com>
76 lines
1.8 KiB
JavaScript
76 lines
1.8 KiB
JavaScript
// material-ui
|
|
import { useTheme } from "@mui/material/styles";
|
|
import { Box, Button, Stack } from "@mui/material";
|
|
import LogoSection from "layout/MainLayout/LogoSection";
|
|
import { Link } from "react-router-dom";
|
|
import { useLocation } from "react-router-dom";
|
|
import { useSelector } from "react-redux";
|
|
|
|
// ==============================|| MAIN NAVBAR / HEADER ||============================== //
|
|
|
|
const Header = () => {
|
|
const theme = useTheme();
|
|
const { pathname } = useLocation();
|
|
const account = useSelector((state) => state.account);
|
|
|
|
return (
|
|
<>
|
|
<Box
|
|
sx={{
|
|
width: 228,
|
|
display: "flex",
|
|
[theme.breakpoints.down("md")]: {
|
|
width: "auto",
|
|
},
|
|
}}
|
|
>
|
|
<Box component="span" sx={{ flexGrow: 1 }}>
|
|
<LogoSection />
|
|
</Box>
|
|
</Box>
|
|
|
|
<Box sx={{ flexGrow: 1 }} />
|
|
<Box sx={{ flexGrow: 1 }} />
|
|
<Stack spacing={2} direction="row">
|
|
<Button
|
|
component={Link}
|
|
variant="text"
|
|
to="/"
|
|
color={pathname === "/" ? "primary" : "inherit"}
|
|
>
|
|
首页
|
|
</Button>
|
|
<Button
|
|
component={Link}
|
|
variant="text"
|
|
to="/about"
|
|
color={pathname === "/about" ? "primary" : "inherit"}
|
|
>
|
|
关于
|
|
</Button>
|
|
{account.user ? (
|
|
<Button
|
|
component={Link}
|
|
variant="contained"
|
|
to="/panel"
|
|
color="primary"
|
|
>
|
|
控制台
|
|
</Button>
|
|
) : (
|
|
<Button
|
|
component={Link}
|
|
variant="contained"
|
|
to="/login"
|
|
color="primary"
|
|
>
|
|
登入
|
|
</Button>
|
|
)}
|
|
</Stack>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default Header;
|