vdi/pc-fe/src/pages/components/Layout/index.tsx

55 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;