|
|
|
@ -1,6 +1,6 @@
|
|
|
|
import React from 'react';
|
|
|
|
import React, { useState } from 'react';
|
|
|
|
import { Layout, Menu, Button, Input, Avatar, Badge, Switch, ConfigProvider } from 'antd';
|
|
|
|
import { Layout, Menu, Button, Input, Avatar, Badge, Switch, ConfigProvider } from 'antd';
|
|
|
|
import { SearchOutlined, BellOutlined, UserOutlined, MenuFoldOutlined, MenuUnfoldOutlined, HomeOutlined, BarChartOutlined, SafetyOutlined, SettingOutlined } from '@ant-design/icons';
|
|
|
|
import { SearchOutlined, BellOutlined, UserOutlined, MenuFoldOutlined, MenuUnfoldOutlined, HomeOutlined, BarChartOutlined, SafetyOutlined, SettingOutlined, SunOutlined, MoonOutlined } from '@ant-design/icons';
|
|
|
|
import { Link, useLocation } from 'react-router-dom';
|
|
|
|
import { Link, useLocation } from 'react-router-dom';
|
|
|
|
import './MainLayout.css';
|
|
|
|
import './MainLayout.css';
|
|
|
|
|
|
|
|
|
|
|
|
@ -9,11 +9,13 @@ const { Search } = Input;
|
|
|
|
|
|
|
|
|
|
|
|
const MainLayout = ({ children }) => {
|
|
|
|
const MainLayout = ({ children }) => {
|
|
|
|
const location = useLocation();
|
|
|
|
const location = useLocation();
|
|
|
|
|
|
|
|
const [collapsed, setCollapsed] = useState(false);
|
|
|
|
|
|
|
|
const [darkMode, setDarkMode] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
const getSelectedKey = () => {
|
|
|
|
const getSelectedKey = () => {
|
|
|
|
const path = location.pathname;
|
|
|
|
const path = location.pathname;
|
|
|
|
if (path === '/') return '1';
|
|
|
|
if (path === '/') return '1';
|
|
|
|
if (path === '/detail') return '2';
|
|
|
|
if (path.includes('/detail/')) return '2';
|
|
|
|
if (path === '/risk-control') return '3';
|
|
|
|
if (path === '/risk-control') return '3';
|
|
|
|
if (path === '/config') return '4';
|
|
|
|
if (path === '/config') return '4';
|
|
|
|
return '1';
|
|
|
|
return '1';
|
|
|
|
@ -28,7 +30,7 @@ const MainLayout = ({ children }) => {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
key: '2',
|
|
|
|
icon: <BarChartOutlined />,
|
|
|
|
icon: <BarChartOutlined />,
|
|
|
|
label: <Link to="/detail">详情分析</Link>,
|
|
|
|
label: <Link to="/detail/AG">详情分析</Link>,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
key: '3',
|
|
|
|
key: '3',
|
|
|
|
@ -42,19 +44,70 @@ const MainLayout = ({ children }) => {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const toggleCollapse = () => {
|
|
|
|
|
|
|
|
setCollapsed(!collapsed);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const toggleDarkMode = () => {
|
|
|
|
|
|
|
|
const newDarkMode = !darkMode;
|
|
|
|
|
|
|
|
setDarkMode(newDarkMode);
|
|
|
|
|
|
|
|
document.body.setAttribute('data-theme', newDarkMode ? 'dark' : 'light');
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 初始化主题
|
|
|
|
|
|
|
|
React.useEffect(() => {
|
|
|
|
|
|
|
|
document.body.setAttribute('data-theme', darkMode ? 'dark' : 'light');
|
|
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<ConfigProvider theme={{ token: { colorScheme: 'light' } }}>
|
|
|
|
<ConfigProvider
|
|
|
|
|
|
|
|
theme={{
|
|
|
|
|
|
|
|
token: {
|
|
|
|
|
|
|
|
colorScheme: darkMode ? 'dark' : 'light',
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
algorithm: darkMode ? ConfigProvider.darkAlgorithm : ConfigProvider.defaultAlgorithm,
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
>
|
|
|
|
<Layout style={{ minHeight: '100vh' }}>
|
|
|
|
<Layout style={{ minHeight: '100vh' }}>
|
|
|
|
<Header className="header">
|
|
|
|
<Header className="header">
|
|
|
|
<div className="header-left">
|
|
|
|
<div className="header-left">
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
type="text"
|
|
|
|
|
|
|
|
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
|
|
|
|
|
|
|
|
onClick={toggleCollapse}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
fontSize: '16px',
|
|
|
|
|
|
|
|
width: 64,
|
|
|
|
|
|
|
|
height: 64,
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
<h1 className="logo">AI期货分析系统</h1>
|
|
|
|
<h1 className="logo">AI期货分析系统</h1>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="header-right">
|
|
|
|
<div className="header-right">
|
|
|
|
|
|
|
|
<Switch
|
|
|
|
|
|
|
|
checkedChildren={<MoonOutlined />}
|
|
|
|
|
|
|
|
unCheckedChildren={<SunOutlined />}
|
|
|
|
|
|
|
|
checked={darkMode}
|
|
|
|
|
|
|
|
onChange={toggleDarkMode}
|
|
|
|
|
|
|
|
style={{ marginRight: 16 }}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Badge count={4} style={{ marginRight: 16 }}>
|
|
|
|
|
|
|
|
<Button type="text" icon={<BellOutlined />} />
|
|
|
|
|
|
|
|
</Badge>
|
|
|
|
<Avatar icon={<UserOutlined />} />
|
|
|
|
<Avatar icon={<UserOutlined />} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Header>
|
|
|
|
</Header>
|
|
|
|
<Layout>
|
|
|
|
<Layout>
|
|
|
|
<Sider width={200} theme="light">
|
|
|
|
<Sider
|
|
|
|
|
|
|
|
width={200}
|
|
|
|
|
|
|
|
theme={darkMode ? 'dark' : 'light'}
|
|
|
|
|
|
|
|
collapsed={collapsed}
|
|
|
|
|
|
|
|
collapsedWidth={80}
|
|
|
|
|
|
|
|
trigger={null}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
transition: 'width 0.3s',
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
>
|
|
|
|
<Menu
|
|
|
|
<Menu
|
|
|
|
mode="inline"
|
|
|
|
mode="inline"
|
|
|
|
selectedKeys={[getSelectedKey()]}
|
|
|
|
selectedKeys={[getSelectedKey()]}
|
|
|
|
|