55 lines
1.5 KiB
TypeScript
55 lines
1.5 KiB
TypeScript
import React, { useState, useEffect } from 'react';
|
||
import { Layout, message } from 'antd';
|
||
import { history, useLocation, Outlet } from 'umi';
|
||
import './index.less';
|
||
|
||
const { Header, Sider, Content } = Layout;
|
||
|
||
const MainLayout: React.FC = () => {
|
||
const [username, setUsername] = useState('');
|
||
const location = useLocation();
|
||
|
||
// useEffect(() => {
|
||
// // 检查登录状态
|
||
// const isLoggedIn = localStorage.getItem('isLoggedIn');
|
||
// const currentUsername = localStorage.getItem('username');
|
||
|
||
// if (!isLoggedIn) {
|
||
// message.error('请先登录!');
|
||
// history.push('/login');
|
||
// return;
|
||
// }
|
||
|
||
// setUsername(currentUsername || '');
|
||
// }, []);
|
||
|
||
useEffect(() => {
|
||
// TODO: 第一次来:判断是否配置ip/DHCP、服务ip绑定终端 绑定:直接到版本更新页面 未绑定:到配置ip/DHCP页面
|
||
setTimeout(() => {
|
||
history.push('/login');
|
||
},9000)
|
||
}, []);
|
||
|
||
const handleMenuClick = (key: string) => {
|
||
// 使用路由导航
|
||
history.push(`/${key}`);
|
||
};
|
||
|
||
const handleLogout = () => {
|
||
localStorage.removeItem('isLoggedIn');
|
||
localStorage.removeItem('username');
|
||
message.success('已退出登录');
|
||
history.push('/login');
|
||
};
|
||
|
||
return (
|
||
<Layout className="main-layout">
|
||
<Content className="main-content">
|
||
<Outlet />
|
||
</Content>
|
||
</Layout>
|
||
);
|
||
};
|
||
|
||
export default MainLayout;
|