Commit 5d804078 authored by GuanHua's avatar GuanHua

fix: 修改登录页扫码,切换回密码登录时仍然请求的问题

parent 74199014
......@@ -10,7 +10,7 @@ import { GlobalConfig } from '@/global/config';
* @author xjm
*/
const UserLayouts: React.FC = (props) => {
console.log(props)
return (
<>
{/* <Helmet>
......
import React, { useState, useEffect } from 'react'
import { Form, Row, Col, Input, Button, message } from 'antd'
import React, { useState, useEffect, useRef } from 'react'
import { message } from 'antd'
import { history } from 'umi';
import {
UserOutlined,
LockOutlined,
ExclamationCircleFilled
} from '@ant-design/icons';
import { setAuth, setRouters } from '@/utils/auth';
import QRCode from 'qrcode';
import { PublicApi } from '@/services/api';
......@@ -13,12 +8,14 @@ import { PublicApi } from '@/services/api';
const ScanLoginWrap: React.FC = () => {
const { redirect } = history.location.query
const [qrCode, setQrCode] = useState('')
const timer = useRef(null)
let time = 60 * 5;
const hanleCountdown = (authCode) => {
if (time > 0 && time <= 60 * 5) {
time -= 2;
console.log(time);
setTimeout(() => {
timer.current = setTimeout(() => {
loginInfo(authCode)
hanleCountdown(authCode);
}, 2000);
......@@ -62,13 +59,19 @@ const ScanLoginWrap: React.FC = () => {
useEffect(() => {
AuthCode();
return () => {
clearTimeout(timer.current)
timer.current = null
}
// hanleCountdown()
}, [])
return (
<div className={'scanLoginWrap'}>
<h2>扫码登录</h2>
<div className={'qrCodeImage'}>
<img src={qrCode} alt="" />
{
qrCode && <img src={qrCode} alt="" />
}
</div>
</div>
)
......
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