Browse Source

取消自动登录,增加记住密码

main
zhengzhou 3 years ago
parent
commit
a650848637
2 changed files with 27 additions and 6 deletions
  1. +22
    -5
      src/pages/login/index.tsx
  2. +5
    -1
      src/pages/login/login.less

+ 22
- 5
src/pages/login/index.tsx View File

@@ -1,5 +1,13 @@
import React, { useState } from 'react';
import { Input, Button, Form, Modal, ModalProps, message } from 'antd';
import {
Input,
Button,
Form,
Modal,
ModalProps,
message,
Checkbox,
} from 'antd';
import styles from './login.less';
import { history, useModel } from 'umi';
import { MobileFilled, LockFilled } from '@ant-design/icons';
@@ -27,6 +35,7 @@ export default function Login() {
const [account, setAccount] = useState('');
const [password, setPassword] = useState('');
const [loading, setLoading] = useState(false);
const [keepPass, setKeepPass] = useState(false);
const [regModalVisible, setRegModalVisible] = useState(false);
const { refresh } = useModel('@@initialState');
const buttonRef = useRef<HTMLElement>(null);
@@ -50,7 +59,7 @@ export default function Login() {
})
.success(() => {
// 记录账号密码
if (isClient) {
if (isClient && keepPass) {
storage.set('account', account, true);
storage.set('password', password, true);
}
@@ -74,9 +83,10 @@ export default function Login() {
if (iAccount && iPass) {
setAccount(iAccount);
setPassword(iPass);
setTimeout(() => {
buttonRef.current?.click();
}, 500);
setKeepPass(true);
// setTimeout(() => {
// buttonRef.current?.click();
// }, 500);
}
}, 0);
}
@@ -115,6 +125,13 @@ export default function Login() {
onChange={(e) => setPassword(e.target.value)}
/>
<div className={styles.errText}>{errText}</div>
<Checkbox
className={styles.checkbox}
checked={keepPass}
onChange={(e) => setKeepPass(e.target.checked)}
>
记住密码
</Checkbox>
<div className={styles.btnGroup}>
<Button
ref={buttonRef}


+ 5
- 1
src/pages/login/login.less View File

@@ -26,7 +26,7 @@
padding: 0 16px;
border-radius: 2px;
color: #fff;
margin-bottom: 12px;
&:not(:empty) {
background-color: #d6243a;
}
@@ -58,6 +58,10 @@
}
}

.checkbox {
color: #fff;
margin-bottom: 24px;
}
.modal {
:global(.ant-modal-body) {
padding: 40px 173px 10px;


Loading…
Cancel
Save