mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-06-13 21:37:03 +08:00
顶部导航
This commit is contained in:
parent
444a47e43e
commit
2c95548412
@ -17,13 +17,51 @@
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
.App-logo {
|
.App-logo {
|
||||||
width: auto;
|
width: 124px;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
|
text-align: left;
|
||||||
img {
|
img {
|
||||||
width: auto;
|
width: auto;
|
||||||
height: 40px;
|
height: 40px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.navs {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
.nav-item {
|
||||||
|
width: 64px;
|
||||||
|
height: 40px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: rgba(0, 0, 0, 0.88);
|
||||||
|
line-height: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin-left: 80px;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-active-item {
|
||||||
|
width: 64px;
|
||||||
|
height: 40px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 40px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
color: #ff4d4f;
|
||||||
|
margin-left: 80px;
|
||||||
|
cursor: pointer;
|
||||||
|
&:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
.department-name {
|
.department-name {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
|
@ -3,7 +3,7 @@ import styles from "./index.module.scss";
|
|||||||
import { Modal, Button, Dropdown } from "antd";
|
import { Modal, Button, Dropdown } from "antd";
|
||||||
import type { MenuProps } from "antd";
|
import type { MenuProps } from "antd";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
import { Link, useNavigate, useLocation } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
logoutAction,
|
logoutAction,
|
||||||
saveCurrentDepId,
|
saveCurrentDepId,
|
||||||
@ -16,6 +16,7 @@ const { confirm } = Modal;
|
|||||||
export const Header: React.FC = () => {
|
export const Header: React.FC = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
const user = useSelector((state: any) => state.loginUser.value.user);
|
const user = useSelector((state: any) => state.loginUser.value.user);
|
||||||
const departments = useSelector(
|
const departments = useSelector(
|
||||||
(state: any) => state.loginUser.value.departments
|
(state: any) => state.loginUser.value.departments
|
||||||
@ -26,6 +27,7 @@ export const Header: React.FC = () => {
|
|||||||
const [userInfoVisiale, setUserInfoVisiale] = useState<boolean>(false);
|
const [userInfoVisiale, setUserInfoVisiale] = useState<boolean>(false);
|
||||||
const [departmentsMenu, setDepartmentsMenu] = useState<any>([]);
|
const [departmentsMenu, setDepartmentsMenu] = useState<any>([]);
|
||||||
const [currentDepartment, setCurrentDepartment] = useState<string>("");
|
const [currentDepartment, setCurrentDepartment] = useState<string>("");
|
||||||
|
const [currentNav, serCurrentNav] = useState(location.pathname);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCurrentDepartment(departments[0].name);
|
setCurrentDepartment(departments[0].name);
|
||||||
@ -126,6 +128,17 @@ export const Header: React.FC = () => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const navs = [
|
||||||
|
{
|
||||||
|
key: "/",
|
||||||
|
label: "首页",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: "/recent-learn",
|
||||||
|
label: "最近学习",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["app-header"]}>
|
<div className={styles["app-header"]}>
|
||||||
<div className={styles["main-header"]}>
|
<div className={styles["main-header"]}>
|
||||||
@ -133,6 +146,24 @@ export const Header: React.FC = () => {
|
|||||||
<Link to="/" className={styles["App-logo"]}>
|
<Link to="/" className={styles["App-logo"]}>
|
||||||
<img src={config.systemLogo} />
|
<img src={config.systemLogo} />
|
||||||
</Link>
|
</Link>
|
||||||
|
<div className={styles["navs"]}>
|
||||||
|
{navs.map((item: any) => (
|
||||||
|
<div
|
||||||
|
key={item.key}
|
||||||
|
className={
|
||||||
|
item.key === currentNav
|
||||||
|
? styles["nav-active-item"]
|
||||||
|
: styles["nav-item"]
|
||||||
|
}
|
||||||
|
onClick={() => {
|
||||||
|
serCurrentNav(item.key);
|
||||||
|
navigate(item.key);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{item.label}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex">
|
<div className="d-flex">
|
||||||
{departments.length === 1 && (
|
{departments.length === 1 && (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user