Ver a proveniência

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

main
zhengzhou há 3 anos
ascendente
cometimento
a650848637
2 ficheiros alterados com 27 adições e 6 eliminações
  1. +22
    -5
      src/pages/login/index.tsx
  2. +5
    -1
      src/pages/login/login.less

+ 22
- 5
src/pages/login/index.tsx Ver ficheiro

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


+ 5
- 1
src/pages/login/login.less Ver ficheiro

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


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


Carregando…
Cancelar
Guardar