system-copyright-react/src/route/index/index.tsx

79 lines
2.8 KiB
TypeScript
Raw Normal View History

2024-03-12 18:53:51 +08:00
import './index.css';
2024-03-13 19:01:21 +08:00
import {MouseEvent, useState} from "react";
2024-03-14 18:33:58 +08:00
import {Link, useNavigate} from "react-router-dom";
2024-03-12 18:53:51 +08:00
import {IMenuListItem, IMenuWithTopButton} from "../../interfaces/menu/IMenuWithTopButton.ts";
import MenuWithTopButton from "../../components/menu/MenuWithTopButton.tsx";
2024-03-13 16:11:28 +08:00
import MenuTreeWithTopButton from "../../components/menu/MenuTreeWithTopButton.tsx";
import ListProj from "../../components/list/ListProj.tsx";
2024-03-13 19:01:21 +08:00
import ListProjAgent from "../../components/list/ListProjAgent.tsx";
2024-03-14 18:33:58 +08:00
import {Breadcrumb} from 'antd';
2024-03-12 18:53:51 +08:00
2024-03-13 19:01:21 +08:00
export default function Index() {
const [listType, setListType] = useState('proj');
2024-03-14 18:33:58 +08:00
const nav = useNavigate();
2024-03-13 19:01:21 +08:00
const projMenu: IMenuWithTopButton = {
button: {
name: '创建项目',
2024-03-14 18:33:58 +08:00
handle() {
nav('/proj-create')
2024-03-13 19:01:21 +08:00
}
},
list: [
{id: 'proj1', icon: './vite.svg', name: '全部项目'},
{id: 'proj2', icon: './vite.svg', name: '进行中的'},
{id: 'proj3', icon: './vite.svg', name: '已完成的'}
],
handleListItem(e: MouseEvent<HTMLLIElement>, index: number, item: IMenuListItem) {
console.log(e);
console.log(index);
console.log(item)
setListType('proj');
2024-03-12 18:53:51 +08:00
}
}
2024-03-13 19:01:21 +08:00
const agentMenu: IMenuWithTopButton = {
button: {
name: '代理服务',
handle(e: MouseEvent<HTMLButtonElement>) {
console.log(e)
}
},
list: [
{id: 'agent1', icon: './vite.svg', name: '全部项目'},
{id: 'agent2', icon: './vite.svg', name: '进行中的'},
{id: 'agent3', icon: './vite.svg', name: '已完成的'},
],
handleListItem(e: MouseEvent<HTMLLIElement>, index: number, item: IMenuListItem) {
console.log(e);
console.log(index);
console.log(item)
setListType('projAgent');
2024-03-12 18:53:51 +08:00
}
}
return (
2024-03-14 18:33:58 +08:00
<>
<Breadcrumb
items={[
{title: <Link to={'/'}></Link>}
]}
/>
<div className="index">
<div className="left">
<MenuWithTopButton
button={projMenu.button}
list={projMenu.list}
handleListItem={projMenu.handleListItem}
/>
<MenuTreeWithTopButton/>
<MenuWithTopButton
button={agentMenu.button}
list={agentMenu.list}
handleListItem={agentMenu.handleListItem}
/>
</div>
<div className="right">{listType === 'proj' ? <ListProj/> : <ListProjAgent/>}</div>
2024-03-12 18:53:51 +08:00
</div>
2024-03-14 18:33:58 +08:00
</>
2024-03-12 18:53:51 +08:00
)
}