diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index 706fff8..e24be2f 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -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(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)} />
{errText}
+ setKeepPass(e.target.checked)} + > + 记住密码 +