create-antd-layout 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,7 +1,86 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { FormProps } from 'antd'
|
|
3
|
+
import { Button, Checkbox, Divider, Flex, Form, Input,theme } from 'antd'
|
|
4
|
+
import { useNavigate } from 'react-router';
|
|
5
|
+
|
|
6
|
+
const {useToken} = theme
|
|
7
|
+
|
|
8
|
+
type FieldType = {
|
|
9
|
+
username?: string;
|
|
10
|
+
password?: string;
|
|
11
|
+
remember?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const boxStyles:React.CSSProperties = {
|
|
16
|
+
minWidth:"180px",
|
|
17
|
+
width:"100%",
|
|
18
|
+
padding:"2rem",
|
|
19
|
+
maxWidth:"450px",
|
|
20
|
+
borderRadius:"1rem"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* This is just a casual demo
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
1
27
|
export default function Login(){
|
|
28
|
+
const {token} = useToken()
|
|
29
|
+
const navigate = useNavigate()
|
|
30
|
+
|
|
31
|
+
const onFinish: FormProps<FieldType>['onFinish'] = (values) => {
|
|
32
|
+
console.log('Success:', values);
|
|
33
|
+
navigate("/")
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const onFinishFailed: FormProps<FieldType>['onFinishFailed'] = (errorInfo) => {
|
|
37
|
+
console.log('Failed:', errorInfo);
|
|
38
|
+
}
|
|
39
|
+
|
|
2
40
|
return (
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
41
|
+
<Flex orientation="vertical" align="center" justify="center" style={{width:"100vw",height:"100vh",padding:"1rem",backgroundColor:token.colorBgLayout}}>
|
|
42
|
+
<Flex orientation="vertical" align="center" justify="center">
|
|
43
|
+
<a href="#"><img src="/vite.svg" style={{width:"60px"}} /></a>
|
|
44
|
+
<h3 style={{marginBlockStart:"0.6rem",marginBlockEnd:"0.1rem"}}>Vite.dev</h3>
|
|
45
|
+
<span style={{marginBlockEnd:"1rem",color:token.colorTextSecondary}}>Log in to the backend</span>
|
|
46
|
+
</Flex>
|
|
47
|
+
<div style={{...boxStyles,backgroundColor:token.colorBgContainer}}>
|
|
48
|
+
<Form
|
|
49
|
+
name="basic"
|
|
50
|
+
layout='vertical'
|
|
51
|
+
initialValues={{ remember: true, layout:"vertical"}}
|
|
52
|
+
onFinish={onFinish}
|
|
53
|
+
onFinishFailed={onFinishFailed}
|
|
54
|
+
autoComplete="off"
|
|
55
|
+
>
|
|
56
|
+
<Form.Item<FieldType>
|
|
57
|
+
label="Username"
|
|
58
|
+
name="username"
|
|
59
|
+
rules={[{ required: true, message: 'Please input your username!' }]}
|
|
60
|
+
>
|
|
61
|
+
<Input />
|
|
62
|
+
</Form.Item>
|
|
63
|
+
<Form.Item<FieldType>
|
|
64
|
+
label="Password"
|
|
65
|
+
name="password"
|
|
66
|
+
rules={[{ required: true, message: 'Please input your password!' }]}
|
|
67
|
+
>
|
|
68
|
+
<Input.Password />
|
|
69
|
+
</Form.Item>
|
|
70
|
+
<Form.Item<FieldType> name="remember" valuePropName="checked" label={null}>
|
|
71
|
+
<Checkbox>Remember me</Checkbox>
|
|
72
|
+
</Form.Item>
|
|
73
|
+
<Form.Item label={null} style={{paddingBlockEnd:"0px",marginBlockEnd:"0px"}}>
|
|
74
|
+
<Button block type="primary" htmlType="submit">
|
|
75
|
+
Sign in
|
|
76
|
+
</Button>
|
|
77
|
+
<Divider>or</Divider>
|
|
78
|
+
<Button block>
|
|
79
|
+
Sign up
|
|
80
|
+
</Button>
|
|
81
|
+
</Form.Item>
|
|
82
|
+
</Form>
|
|
83
|
+
</div>
|
|
84
|
+
</Flex>
|
|
6
85
|
)
|
|
7
86
|
}
|