import * as React from 'react'; import { Form, Row, Input, Button, notification, Icon } from 'component/antd'; import { userLogin } from 'lib/api'; import { setCookie } from 'lib/utils'; import './index.less'; import bgImgUrl from '../../../assets/image/login-bg.png'; import kafkaImgUrl from '../../../assets/image/kafka-manager.png'; class Login extends React.Component { public state = { show: '', }; public handleSubmit = (e: React.MouseEvent) => { e.preventDefault(); this.props.form.validateFields((err: Error, values: any) => { if (err) return; userLogin(values).then((data) => { setCookie([{ key: 'username', value: data.username, time: 1 }, { key: 'role', value: data.role, time: 1 }]); notification.success({ message: '登录成功' }); this.props.history.push('/'); }); }); } public handleReset = () => { this.props.form.resetFields(); } public handleKeyPress = (e: any) => { if (e.nativeEvent.keyCode === 13) { this.handleSubmit(e); } } public inputOnBlur = () => { this.setState({ show: 'show' }); } public render() { const { getFieldDecorator } = this.props.form; return (
{getFieldDecorator('username')( , )} {getFieldDecorator('password')( , )}
); } } export default Form.create({ name: 'login' })(Login);