import React, { Fragment, useEffect } from 'react'; import { Button, Row, Input, Form, notification } from 'antd'; import config from '@/utils/config'; import { history, Link } from 'umi'; import styles from './index.less'; import { request } from '@/utils/http'; const FormItem = Form.Item; const Login = () => { const handleOk = (values: any) => { request .post(`${config.apiPrefix}login`, { data: { username: values.username, password: values.password, }, }) .then((data) => { if (data.code === 200) { localStorage.setItem(config.authKey, data.token); history.push('/crontab'); } else if (data.code === 100) { notification.warn({ message: data.msg, }); } else { notification.error({ message: data.msg, }); } }) .catch(function (error) { console.log(error); }); }; useEffect(() => { const isAuth = localStorage.getItem(config.authKey); if (isAuth) { history.push('/crontab'); } }, []); return (
logo {config.siteName}
); }; export default Login;