forked from Gitlink/forgeplus-react
feat: 离开当前页面清除定时器
This commit is contained in:
parent
5dfe4b2350
commit
3d2e91dafd
|
@ -6,6 +6,7 @@ import bug from '../Images/quality/bug.svg'
|
|||
import semibold from '../Images/quality/semibold.svg'
|
||||
import bugRed from '../Images/quality/bug-red.svg'
|
||||
import {Button, Spin, Empty} from "antd";
|
||||
|
||||
import axios from "axios";
|
||||
import './index.scss'
|
||||
|
||||
|
@ -27,11 +28,9 @@ function Quality(props){
|
|||
}
|
||||
useEffect(()=>{
|
||||
getTask()
|
||||
},[])
|
||||
|
||||
useEffect(()=>{
|
||||
// 拦截判断是否离开当前页面
|
||||
window.addEventListener('beforeunload', beforeunload);
|
||||
return () => {
|
||||
clearInterval(timer)
|
||||
}
|
||||
},[])
|
||||
|
||||
useEffect(()=>{
|
||||
|
@ -70,9 +69,6 @@ function Quality(props){
|
|||
|
||||
});
|
||||
}
|
||||
const beforeunload = (e) => {
|
||||
console.log('我被切换了');
|
||||
}
|
||||
|
||||
const getTaskData = () => {
|
||||
axios.post(`/${owner}/${projectsId}/sonar_tasks.json`)
|
||||
|
|
Loading…
Reference in New Issue