首页头部初步

This commit is contained in:
禺狨
2023-03-23 17:43:41 +08:00
parent a3da93be82
commit 872f5baca8
11 changed files with 144 additions and 7 deletions

View File

@@ -0,0 +1,27 @@
.app-header {
width: 100%;
position: sticky;
top: 0;
left: 0;
right: 0;
height: 60px;
background: #ffffff;
box-shadow: 0px 1px 4px 0px rgba(0, 0, 0, 0.04);
.main-header {
width: 1200px;
height: 60px;
line-height: 60px;
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 auto;
.App-logo {
width: auto;
height: 40px;
img {
width: auto;
height: 40px;
}
}
}
}

View File

@@ -0,0 +1,79 @@
import React from "react";
import styles from "./index.module.scss";
import { Button, Dropdown, MenuProps } from "antd";
import { useDispatch, useSelector } from "react-redux";
import { Link, useNavigate } from "react-router-dom";
import { logoutAction } from "../../store/user/loginUserSlice";
export const Header: React.FC = () => {
const dispatch = useDispatch();
const navigate = useNavigate();
const user = useSelector((state: any) => state.loginUser.value.user);
const config = useSelector((state: any) => state.systemConfig.value);
const onClick: MenuProps["onClick"] = ({ key }) => {
if (key === "login_out") {
dispatch(logoutAction());
navigate("/login");
} else if (key === "change_password") {
navigate("/change-password");
}
};
const items: MenuProps["items"] = [
{
label: "个人中心",
key: "user_center",
icon: (
<i className="iconfont icon-icon-12 c-red" style={{ fontSize: 16 }} />
),
},
{
label: "修改密码",
key: "change_password",
icon: (
<i
className="iconfont icon-icon-password c-red"
style={{ fontSize: 16 }}
/>
),
},
{
label: "退出登录",
key: "login_out",
icon: (
<i
className="iconfont icon-a-icon-logout c-red"
style={{ fontSize: 16 }}
/>
),
},
];
return (
<div className={styles["app-header"]}>
<div className={styles["main-header"]}>
<div className="d-flex">
<Link to="/" className={styles["App-logo"]}>
<img src={config.systemLogo} />
</Link>
</div>
<div className="d-flex">
<Button.Group className={styles["button-group"]}>
<Dropdown menu={{ items, onClick }} placement="bottomRight">
<div className="d-flex">
{user.name && (
<img
style={{ width: 36, height: 36, borderRadius: "50%" }}
src={user.avatar}
/>
)}
<span className="ml-8 c-admin">{user.name}</span>
</div>
</Dropdown>
</Button.Group>
</div>
</div>
</div>
);
};

View File

@@ -1,2 +1,3 @@
export * from "./footer";
export * from "./no-header";
export * from "./no-header";
export * from "./header";