Commit c61d5e45 authored by Sixiang_Zzb's avatar Sixiang_Zzb

批量上传成功后倒计时bug修复

parent 23a3e560
...@@ -5,25 +5,31 @@ import { connect, history } from 'umi'; ...@@ -5,25 +5,31 @@ import { connect, history } from 'umi';
const module = 'User'; const module = 'User';
const ResultPage = () => { const ResultPage = () => {
const [resultTime, setResultTime] = useState(3); const [resultTime, setResultTime] = useState(3);
let timer: NodeJS.Timeout;
function loop(i: number) { function loop(i: number) {
if (i < 4) { setResultTime(i);
console.log(i); timer = setInterval(() => {
if (i <= 0) {
setResultTime(4 - i); clearInterval(timer);
setTimeout(function () {
loop(++i);
}, 1000);
} else {
setResultTime(0);
history.go(-1); history.go(-1);
return;
} }
setResultTime(--i);
}, 1000);
} }
useEffect(() => { useEffect(() => {
loop(1); loop(3);
return () => {
clearInterval(timer);
};
}, []); }, []);
const backPage = () => {};
const backPage = () => {
clearTimeout(timer);
history.go(-1);
};
return ( return (
<div style={{ width: '100%', minWidth: 1020, padding: 34, backgroundColor: '#ffffff' }}> <div style={{ width: '100%', minWidth: 1020, padding: 34, backgroundColor: '#ffffff' }}>
<Result <Result
...@@ -36,9 +42,9 @@ const ResultPage = () => { ...@@ -36,9 +42,9 @@ const ResultPage = () => {
</p> </p>
} }
extra={[ extra={[
<Button type="primary" key="ok" onClick={backPage}> // <Button type="primary" key="ok" onClick={backPage}>
Ok // Ok
</Button>, // </Button>,
<Button key="back" onClick={backPage}> <Button key="back" onClick={backPage}>
Back Back
</Button>, </Button>,
......
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