Commit 980438d3 authored by 张子雨's avatar 张子雨

feat: 优化

parent 1fdf38b4
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import { Form, Input, Button, Checkbox, Card, notification } from 'antd'; import { Form, Input, Button, Checkbox, Card, notification, Popover } from 'antd';
import { history } from 'umi'; import { history } from 'umi';
import { da } from 'date-fns/locale'; import { da } from 'date-fns/locale';
import styles from './style.less'; import styles from './style.less';
...@@ -51,32 +51,51 @@ const Password = props => { ...@@ -51,32 +51,51 @@ const Password = props => {
<div className={styles.div}> <div className={styles.div}>
<Card className={styles.card}> <Card className={styles.card}>
<p>修改密码</p> <p>修改密码</p>
<Form <Form
initialValues={{ remember: true }} initialValues={{ remember: true }}
onFinish={onFinish} onFinish={onFinish}
autoComplete="off" autoComplete="off"
className={styles.form} className={styles.form}
ref={formRef} ref={formRef}
// labelCol={{
// span: 16,
// }}
// wrapperCol={{
// span: 16,
// }}
> >
<Form.Item name="password" rules={[{ required: true, message: '请输入原密码!' }]}> <Form.Item name="password" rules={[{ required: true, message: '请输入原密码!' }]}>
<Input.Password placeholder="输入原密码" /> <Input.Password placeholder="输入原密码" />
</Form.Item> </Form.Item>
<Form.Item <Popover
name="newPassword" content="限13-18字符,包含大小写字母、数字和特殊字符"
rules={[ placement="right"
{ required: true, message: '请输入新密码!' }, trigger="hover"
{
message: '至少13最多18位且必须包含大小写字母、数字和特殊字符',
pattern: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{13,18}/,
},
]}
> >
<Input.Password placeholder="输入新密码" maxLength={18} /> <Form.Item
</Form.Item> name="newPassword"
validateFirst
rules={[
{ required: true, message: '请输入新密码!' },
{ min: 13, message: '密码最少13位' },
{ max: 18, message: '密码最多18位' },
{
message: '至少13位且必须包含大小写字母、数字和特殊字符',
pattern: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{13,18}/,
},
]}
>
<Input.Password placeholder="输入新密码" />
</Form.Item>
</Popover>
<Form.Item <Form.Item
name="newPasswordAgain" name="newPasswordAgain"
validateFirst
rules={[ rules={[
{ required: true, message: '请输入新密码!' }, { required: true, message: '请输入新密码!' },
{ min: 13, message: '密码最少13位' },
{ max: 18, message: '密码最多18位' },
{ {
message: '至少13位最多18位且必须包含大小写字母、数字和特殊字符', message: '至少13位最多18位且必须包含大小写字母、数字和特殊字符',
pattern: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{13,18}/, pattern: /(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{13,18}/,
...@@ -92,11 +111,10 @@ const Password = props => { ...@@ -92,11 +111,10 @@ const Password = props => {
}), }),
]} ]}
> >
<Input.Password placeholder="输入新密码" maxLength={18} /> <Input.Password placeholder="输入新密码" />
</Form.Item> </Form.Item>
<Form.Item className={styles.btn}> <Form.Item className={styles.btn}>
<Button type="primary" htmlType="submit" loading={loading}> <Button type="primary" htmlType="submit" loading={loading}>
{' '}
确认修改 确认修改
</Button> </Button>
<Button type="primary" ghost onClick={goHome}> <Button type="primary" ghost onClick={goHome}>
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
&:first-child { &:first-child {
width: 200px; width: 200px;
margin-right: 10px; margin-right: 10px;
margin-bottom: 10px;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment