56 lines
2.0 KiB
TypeScript
56 lines
2.0 KiB
TypeScript
import './menu-with-top-button.css'
|
|
import { IMenuWithTopButton } from "../../interfaces/menu/IMenuWithTopButton.ts";
|
|
import objImg from '../../static/left/obj.png'
|
|
import newImg from '../../static/left/new.png'
|
|
import { useNavigate } from 'react-router-dom';
|
|
import {
|
|
RightOutlined
|
|
} from '@ant-design/icons';
|
|
export default function MenuWithTopButton(props: IMenuWithTopButton) {
|
|
const navugate = useNavigate()
|
|
|
|
const list = props.list.map((item, index) => (
|
|
// 创建项目下三个选项
|
|
<li className={item.active ? 'active' : ''} key={item.id} onClick={(e) => {
|
|
props.handleListItem(e, index, item);
|
|
navugate('/home')
|
|
}}>
|
|
|
|
{item.icon ? (<img src={item.icon} className="menu-icon" alt="加载失败" />) : <></>}
|
|
<span className="menu-name">{item.name}</span>
|
|
<span className='topIcon'><RightOutlined /></span>
|
|
</li>
|
|
));
|
|
|
|
return (
|
|
<div className="menu-with-top-button">
|
|
{/* button 是三个黄色按钮 */}
|
|
<div className='top'>
|
|
<div className='top-lift'>
|
|
<img src={objImg} alt="" />
|
|
<div> {props.button.name}</div>
|
|
</div>
|
|
<div className='top-right' onClick={(e) => {
|
|
props.button.handle(e);
|
|
// 当点击创建时其他按钮默认为不被选中
|
|
// props.list.forEach(item => item.active = false);
|
|
// console.log(props.list);
|
|
|
|
}}>
|
|
<img src={newImg} alt="" />
|
|
<div>创建</div>
|
|
</div>
|
|
</div>
|
|
{/* <button className="btn btn-orange top-button"
|
|
onClick={(e) => {
|
|
props.button.handle(e);
|
|
console.log(e);
|
|
|
|
}}
|
|
>
|
|
{props.button.name}
|
|
</button> */}
|
|
<ul>{list}</ul>
|
|
</div>
|
|
)
|
|
} |