|
|
@ -1,118 +1,37 @@
|
|
|
|
import React, { useEffect, useState, useContext } from 'react';
|
|
|
|
import { useState, useContext, ReactNode } from 'react';
|
|
|
|
import { DefaultTheme, ThemeContext } from 'styled-components';
|
|
|
|
import { DefaultTheme, ThemeContext } from 'styled-components';
|
|
|
|
|
|
|
|
import { Layout, Button, Menu } from 'antd';
|
|
|
|
import { Layout, Button, Menu, Table } from 'antd';
|
|
|
|
import useThemeMode from '@/hooks/useThemeMode';
|
|
|
|
import { Routes, Route, Link } from 'react-router-dom';
|
|
|
|
import { IMenuList } from '@/typings';
|
|
|
|
import Home from '@/page/home';
|
|
|
|
|
|
|
|
import About from '@/page/about';
|
|
|
|
|
|
|
|
import Login from '@/page/login';
|
|
|
|
|
|
|
|
import style from './index.module.less';
|
|
|
|
import style from './index.module.less';
|
|
|
|
import TableBox from '../table';
|
|
|
|
|
|
|
|
import Search from '@/page/search';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import { AppstoreOutlined, MailOutlined, SettingOutlined } from '@ant-design/icons';
|
|
|
|
|
|
|
|
import { THEME_NAME, MyThemeContext } from '@/context/themeContext';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { Header, Sider, Content } = Layout;
|
|
|
|
const { Header, Sider, Content } = Layout;
|
|
|
|
|
|
|
|
|
|
|
|
interface ThemeProps {
|
|
|
|
interface ILayoutCom {
|
|
|
|
children: React.ReactNode;
|
|
|
|
children?: ReactNode;
|
|
|
|
|
|
|
|
sideMenuList: IMenuList[];
|
|
|
|
|
|
|
|
isSider?: boolean;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const LayoutCom = (props: ILayoutCom) => {
|
|
|
|
const items = [
|
|
|
|
const { sideMenuList, children, isSider = true } = props;
|
|
|
|
{
|
|
|
|
|
|
|
|
label: <a href="/about">Navigation One</a>,
|
|
|
|
|
|
|
|
key: 'mail',
|
|
|
|
|
|
|
|
icon: <MailOutlined />,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Navigation Two',
|
|
|
|
|
|
|
|
key: 'app',
|
|
|
|
|
|
|
|
icon: <AppstoreOutlined />,
|
|
|
|
|
|
|
|
disabled: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: <a href="/about">Navigation One</a>,
|
|
|
|
|
|
|
|
key: 'app',
|
|
|
|
|
|
|
|
icon: <AppstoreOutlined />,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Navigation Three - Submenu',
|
|
|
|
|
|
|
|
key: 'SubMenu',
|
|
|
|
|
|
|
|
icon: <SettingOutlined />,
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
type: 'group',
|
|
|
|
|
|
|
|
label: 'Item 1',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Option 1',
|
|
|
|
|
|
|
|
key: 'setting:1',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Option 2',
|
|
|
|
|
|
|
|
key: 'setting:2',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
type: 'group',
|
|
|
|
|
|
|
|
label: 'Item 2',
|
|
|
|
|
|
|
|
children: [
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Option 3',
|
|
|
|
|
|
|
|
key: 'setting:3',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: 'Option 4',
|
|
|
|
|
|
|
|
key: 'setting:4',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
],
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
label: (
|
|
|
|
|
|
|
|
<a href="https://ant.design" target="_blank" rel="noopener noreferrer">
|
|
|
|
|
|
|
|
Navigation Four - Link
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
key: 'alipay',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const LayoutCom = () => {
|
|
|
|
|
|
|
|
const myThemes: DefaultTheme = useContext<any>(ThemeContext);
|
|
|
|
const myThemes: DefaultTheme = useContext<any>(ThemeContext);
|
|
|
|
const { themeName, setThemeName } = useContext<any>(MyThemeContext);
|
|
|
|
|
|
|
|
const [current, setCurrent] = useState('mail');
|
|
|
|
const [current, setCurrent] = useState('mail');
|
|
|
|
const onClick = (e: any) => {
|
|
|
|
const onClick = (e: any) => {
|
|
|
|
console.log('click ', e);
|
|
|
|
|
|
|
|
setCurrent(e.key);
|
|
|
|
setCurrent(e.key);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
const [isDark, setIsDark] = useState(false);
|
|
|
|
const [setIsDark] = useThemeMode();
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
isDark ? setThemeName(THEME_NAME.DARK) : setThemeName(THEME_NAME.DEFAULT);
|
|
|
|
|
|
|
|
}, [isDark, setThemeName]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<main className={style.container} style={{ backgroundColor: myThemes.backgroundColor.bg1 }}>
|
|
|
|
<main className={style.container} style={{ backgroundColor: myThemes.backgroundColor.bg1 }}>
|
|
|
|
<Header className={style.header} style={{ backgroundColor: myThemes.backgroundColor.bg1 }}>
|
|
|
|
<Header className={style.header} style={{ backgroundColor: myThemes.backgroundColor.bg2 }}>
|
|
|
|
<Button onClick={() => setIsDark(pre => !pre)}>切换主题</Button>
|
|
|
|
<Button onClick={() => setIsDark(pre => !pre)}>切换主题</Button>
|
|
|
|
</Header>
|
|
|
|
</Header>
|
|
|
|
<Layout>
|
|
|
|
<Layout style={{ backgroundColor: myThemes.backgroundColor.bg1, height: 'calc(100vh - 64px)' }}>
|
|
|
|
<Sider className={style.sider} style={{ backgroundColor: myThemes.backgroundColor.bg1 }}>
|
|
|
|
{isSider && (
|
|
|
|
<Menu onClick={onClick} selectedKeys={[current]} mode="inline" items={items} />
|
|
|
|
<Sider className={style.sider} style={{ backgroundColor: myThemes.backgroundColor.bg1 }}>
|
|
|
|
</Sider>
|
|
|
|
<Menu onClick={onClick} selectedKeys={[current]} mode="inline" items={sideMenuList} />
|
|
|
|
<Content className={style.content}>
|
|
|
|
</Sider>
|
|
|
|
<Routes>
|
|
|
|
)}
|
|
|
|
<Route path="/Search" Component={Search}></Route>
|
|
|
|
<Content className={style.content}>{children}</Content>
|
|
|
|
<Route path="/Table" Component={TableBox}></Route>
|
|
|
|
|
|
|
|
<Route path="/Login" Component={Login}></Route>
|
|
|
|
|
|
|
|
<Route path="/home" Component={Home}></Route>
|
|
|
|
|
|
|
|
<Route path="/about" Component={About}></Route>
|
|
|
|
|
|
|
|
</Routes>
|
|
|
|
|
|
|
|
</Content>
|
|
|
|
|
|
|
|
</Layout>
|
|
|
|
</Layout>
|
|
|
|
</main>
|
|
|
|
</main>
|
|
|
|
);
|
|
|
|
);
|
|
|
|