-
Notifications
You must be signed in to change notification settings - Fork 116
/
index.tsx
56 lines (49 loc) · 1.92 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react'
import { observer } from 'mobx-react'
import { Form, Input, Button } from 'antd'
import intl from 'react-intl-universal'
import { UserOutlined, LockOutlined, AntDesignOutlined } from '@ant-design/icons'
import styles from './index.module.scss'
import useRootStore from '@store/useRootStore'
const FormItem = Form.Item
function Login() {
const { authStore } = useRootStore()
const [loading, setLoading] = React.useState(false)
async function submit(values: IAuthStore.LoginParams) {
setLoading(true)
try {
await authStore.login(values)
} finally {
setLoading(false)
}
}
return (
<div className={styles.login}>
<Form onFinish={submit} className={styles.form}>
<div className={styles.logoBox}>
<AntDesignOutlined />
</div>
<FormItem name="account" hasFeedback rules={[{ required: true }]}>
<Input prefix={<UserOutlined style={{ color: 'rgba(0,0,0,.25)' }} />} placeholder="account" />
</FormItem>
<FormItem name="password" hasFeedback rules={[{ required: true }]}>
<Input
prefix={<LockOutlined style={{ color: 'rgba(0,0,0,.25)' }} />}
type="password"
placeholder="password"
/>
</FormItem>
<FormItem>
<div className={styles.tips}>
<span>{intl.get('USERNAME')}: admin</span>
<span>{intl.get('PASSWORD')}: admin</span>
</div>
<Button type="primary" htmlType="submit" block loading={loading}>
{intl.get('LOGIN')}
</Button>
</FormItem>
</Form>
</div>
)
}
export default observer(Login)