2025-07-30 01:07:36 +00:00
|
|
|
|
import React, { useState, useEffect } from 'react';
|
2025-08-21 10:06:49 +00:00
|
|
|
|
import { Layout, message } from 'antd';
|
2025-07-30 01:07:36 +00:00
|
|
|
|
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();
|
|
|
|
|
|
|
2025-08-21 10:06:49 +00:00
|
|
|
|
// useEffect(() => {
|
|
|
|
|
|
// // 检查登录状态
|
|
|
|
|
|
// const isLoggedIn = localStorage.getItem('isLoggedIn');
|
|
|
|
|
|
// const currentUsername = localStorage.getItem('username');
|
|
|
|
|
|
|
|
|
|
|
|
// if (!isLoggedIn) {
|
|
|
|
|
|
// message.error('请先登录!');
|
|
|
|
|
|
// history.push('/login');
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
2025-07-30 01:07:36 +00:00
|
|
|
|
|
2025-08-21 10:06:49 +00:00
|
|
|
|
// setUsername(currentUsername || '');
|
|
|
|
|
|
// }, []);
|
2025-07-30 01:07:36 +00:00
|
|
|
|
|
2025-08-21 10:06:49 +00:00
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
// TODO: 第一次来:判断是否配置ip/DHCP、服务ip绑定终端 绑定:直接到版本更新页面 未绑定:到配置ip/DHCP页面
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
history.push('/login');
|
|
|
|
|
|
},9000)
|
2025-07-30 01:07:36 +00:00
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
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">
|
2025-08-21 10:06:49 +00:00
|
|
|
|
<Content className="main-content">
|
|
|
|
|
|
<Outlet />
|
|
|
|
|
|
</Content>
|
2025-07-30 01:07:36 +00:00
|
|
|
|
</Layout>
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default MainLayout;
|