feat: 🎸 新增许多页面
This commit is contained in:
194
src/components/Sidebar/index.css
Normal file
194
src/components/Sidebar/index.css
Normal file
@@ -0,0 +1,194 @@
|
||||
.sidebar-expand-wrapper {
|
||||
width: 280px;
|
||||
box-sizing: border-box;
|
||||
position: relative;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
transition: width 0.3s ease;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
background-color: #fff;
|
||||
|
||||
.sidebar-title {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
> img {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
margin-right: 10px;
|
||||
transition: margin 0.3s ease;
|
||||
}
|
||||
> p {
|
||||
color: #262626;
|
||||
font-size: 20px;
|
||||
font-weight: 400;
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
.user-info {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
.user-avatar {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
border-radius: 12px;
|
||||
}
|
||||
}
|
||||
.visitor-count {
|
||||
width: 100%;
|
||||
height: 41px;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
line-height: 41px;
|
||||
}
|
||||
.sidebar-menu {
|
||||
width: 100%;
|
||||
overflow-x: hidden;
|
||||
overflow-y: auto;
|
||||
box-sizing: border-box;
|
||||
padding: 0 20px;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
|
||||
.sidebar-menu-title {
|
||||
width: 100%;
|
||||
height: 36px;
|
||||
text-align: left;
|
||||
line-height: 36px;
|
||||
color: #bfbfbf;
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.sidebar-menu-item-active {
|
||||
background-color: #e8f3ff;
|
||||
|
||||
.sidebar-menu-icon {
|
||||
color: #0275f2 !important;
|
||||
}
|
||||
.sidebar-menu-text {
|
||||
color: #0275f2 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-menu-item {
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
|
||||
.sidebar-menu-icon {
|
||||
margin: 0 10px;
|
||||
font-size: 20px;
|
||||
}
|
||||
.sidebar-menu-text {
|
||||
margin-left: 10px;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
color: #616065;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-btn {
|
||||
width: 190px;
|
||||
height: 22px;
|
||||
position: absolute;
|
||||
bottom: 20px;
|
||||
left: 50%;
|
||||
transform: translateX(-50%);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
|
||||
> img {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
}
|
||||
|
||||
.sidebar-btn-text {
|
||||
margin-left: 10px;
|
||||
color: #616065;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
opacity: 1;
|
||||
transform: translateX(0);
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-retract-wrapper {
|
||||
width: 95px;
|
||||
.sidebar-title {
|
||||
> img {
|
||||
margin: 0;
|
||||
transition: margin 0.3s ease;
|
||||
}
|
||||
> p {
|
||||
opacity: 0;
|
||||
transform: translateX(-10px);
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
width: 0;
|
||||
}
|
||||
}
|
||||
.user-info {
|
||||
margin-bottom: 41px;
|
||||
}
|
||||
.visitor-count {
|
||||
display: none;
|
||||
}
|
||||
.sidebar-menu {
|
||||
.sidebar-menu-title {
|
||||
text-align: center;
|
||||
opacity: 0;
|
||||
transition: opacity 0.3s ease;
|
||||
}
|
||||
.sidebar-menu-item {
|
||||
justify-content: center;
|
||||
|
||||
.sidebar-menu-icon {
|
||||
margin: 0;
|
||||
}
|
||||
.sidebar-menu-text {
|
||||
opacity: 0;
|
||||
transform: translateX(-10px);
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
width: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar-btn {
|
||||
width: 80px;
|
||||
.sidebar-btn-text {
|
||||
opacity: 0;
|
||||
transform: translateX(-10px);
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s ease, transform 0.3s ease;
|
||||
width: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
81
src/components/Sidebar/index.jsx
Normal file
81
src/components/Sidebar/index.jsx
Normal file
@@ -0,0 +1,81 @@
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import { mockData } from "@/data/mockData";
|
||||
import IconFont from "@/components/IconFont";
|
||||
import Logo from "@/assets/images/Sidebar/logo.png";
|
||||
import BTNICON from "@/assets/images/Sidebar/btn_icon.png";
|
||||
import routes from "@/routes";
|
||||
import "./index.css";
|
||||
|
||||
const Sidebar = ({ isCollapsed, setIsCollapsed }) => {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const { user } = mockData;
|
||||
|
||||
const handleNavClick = (path) => {
|
||||
navigate(path);
|
||||
};
|
||||
|
||||
// 切换侧边栏展开/折叠状态
|
||||
const toggleSidebar = () => {
|
||||
setIsCollapsed((prev) => !prev);
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`${
|
||||
!isCollapsed
|
||||
? "sidebar-retract-wrapper sidebar-expand-wrapper"
|
||||
: "sidebar-expand-wrapper"
|
||||
}`}
|
||||
>
|
||||
<div className="sidebar-title">
|
||||
<img src={Logo} alt="logo" />
|
||||
<p>多多畅职教育系统</p>
|
||||
</div>
|
||||
<div className="user-info">
|
||||
<img
|
||||
alt="avatar"
|
||||
className="user-avatar"
|
||||
src="//p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/3ee5f13fb09879ecb5185e440cef6eb9.png~tplv-uwbnlip3yd-webp.webp"
|
||||
/>
|
||||
</div>
|
||||
<div className="visitor-count">访客总数:1000</div>
|
||||
<ul className="sidebar-menu">
|
||||
{routes
|
||||
.filter((item) => item.showMenu)
|
||||
?.map((item) => (
|
||||
<>
|
||||
<p className="sidebar-menu-title" key={item.name}>
|
||||
{item.name}
|
||||
</p>
|
||||
{item.routes
|
||||
?.filter((i) => i.showMenuItem)
|
||||
?.map((j) => (
|
||||
<li
|
||||
className={
|
||||
location.pathname === j.path
|
||||
? "sidebar-menu-item-active sidebar-menu-item"
|
||||
: "sidebar-menu-item"
|
||||
}
|
||||
key={j.path}
|
||||
onClick={() => handleNavClick(j.path)}
|
||||
>
|
||||
<IconFont
|
||||
className="sidebar-menu-icon"
|
||||
name="icon-yishiming"
|
||||
/>
|
||||
<span className="sidebar-menu-text">{j.name}</span>
|
||||
</li>
|
||||
))}
|
||||
</>
|
||||
))}
|
||||
</ul>
|
||||
<div className="sidebar-btn" onClick={toggleSidebar}>
|
||||
<img src={BTNICON} alt="btn" className="sidebar-btn-icon" />
|
||||
<span className="sidebar-btn-text">展开/收起</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Sidebar;
|
||||
Reference in New Issue
Block a user