mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 23:06:06 +08:00
登录增加错误延迟提醒
This commit is contained in:
parent
54bb13aad0
commit
622037ee98
|
@ -58,17 +58,6 @@ export default class AuthService {
|
|||
);
|
||||
return { code: 200, data: { token, lastip, lastaddr, lastlogon } };
|
||||
} else {
|
||||
if (
|
||||
retries > 2 &&
|
||||
Date.now() - lastlogon < Math.pow(3, retries) * 1000
|
||||
) {
|
||||
return {
|
||||
code: 400,
|
||||
message: `失败次数过多,请${Math.round(
|
||||
(Math.pow(3, retries) * 1000 - Date.now() + lastlogon) / 1000,
|
||||
)}秒后重试`,
|
||||
};
|
||||
}
|
||||
fs.writeFileSync(
|
||||
config.authConfigFile,
|
||||
JSON.stringify({
|
||||
|
@ -76,9 +65,23 @@ export default class AuthService {
|
|||
retries: retries + 1,
|
||||
lastlogon: timestamp,
|
||||
ip,
|
||||
address,
|
||||
lastaddr: address,
|
||||
}),
|
||||
);
|
||||
if (
|
||||
retries > 2 &&
|
||||
Date.now() - lastlogon < Math.pow(3, retries) * 1000
|
||||
) {
|
||||
return {
|
||||
code: 410,
|
||||
message: `失败次数过多,请${Math.round(
|
||||
(Math.pow(3, retries) * 1000 - Date.now() + lastlogon) / 1000,
|
||||
)}秒后重试`,
|
||||
data: Math.round(
|
||||
(Math.pow(3, retries) * 1000 - Date.now() + lastlogon) / 1000,
|
||||
),
|
||||
};
|
||||
}
|
||||
return { code: 400, message: config.authError };
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -241,7 +241,7 @@ input:-webkit-autofill:active {
|
|||
}
|
||||
}
|
||||
|
||||
.ant-message .ant-statistic {
|
||||
.inline-countdown.ant-statistic {
|
||||
display: inline-block;
|
||||
.ant-statistic-content {
|
||||
font-size: 14px;
|
||||
|
|
|
@ -57,7 +57,11 @@ const CronLogModal = ({
|
|||
content: (
|
||||
<span>
|
||||
系统将在
|
||||
<Countdown format="ss" value={Date.now() + 1000 * 10} />
|
||||
<Countdown
|
||||
className="inline-countdown"
|
||||
format="ss"
|
||||
value={Date.now() + 1000 * 10}
|
||||
/>
|
||||
秒后自动刷新
|
||||
</span>
|
||||
),
|
||||
|
|
|
@ -1,14 +1,28 @@
|
|||
import React, { Fragment, useEffect } from 'react';
|
||||
import { Button, Row, Input, Form, message, notification } from 'antd';
|
||||
import React, { Fragment, useEffect, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Row,
|
||||
Input,
|
||||
Form,
|
||||
message,
|
||||
notification,
|
||||
Statistic,
|
||||
} from 'antd';
|
||||
import config from '@/utils/config';
|
||||
import { history, Link } from 'umi';
|
||||
import styles from './index.less';
|
||||
import { request } from '@/utils/http';
|
||||
|
||||
const FormItem = Form.Item;
|
||||
const { Countdown } = Statistic;
|
||||
|
||||
const Login = () => {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [waitTime, setWaitTime] = useState<any>();
|
||||
|
||||
const handleOk = (values: any) => {
|
||||
setLoading(true);
|
||||
setWaitTime(null);
|
||||
request
|
||||
.post(`${config.apiPrefix}login`, {
|
||||
data: {
|
||||
|
@ -36,12 +50,17 @@ const Login = () => {
|
|||
history.push('/crontab');
|
||||
} else if (data.code === 100) {
|
||||
message.warn(data.message);
|
||||
} else if (data.code === 410) {
|
||||
message.error(data.message);
|
||||
setWaitTime(data.data);
|
||||
} else {
|
||||
message.error(data.message);
|
||||
}
|
||||
setLoading(false);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
setLoading(false);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -82,13 +101,27 @@ const Login = () => {
|
|||
<Input type="password" placeholder="密码" />
|
||||
</FormItem>
|
||||
<Row>
|
||||
{waitTime ? (
|
||||
<Button type="primary" style={{ width: '100%' }} disabled>
|
||||
请
|
||||
<Countdown
|
||||
valueStyle={{ color: 'rgba(232, 230, 227, 0.25)' }}
|
||||
className="inline-countdown"
|
||||
format="ss"
|
||||
value={Date.now() + 1000 * waitTime}
|
||||
/>
|
||||
秒后重试
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
type="primary"
|
||||
htmlType="submit"
|
||||
style={{ width: '100%' }}
|
||||
loading={loading}
|
||||
>
|
||||
登录
|
||||
</Button>
|
||||
)}
|
||||
</Row>
|
||||
</Form>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user