diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index a8bd0c4b4..d91c42fcf 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -46,11 +46,7 @@ debugType = "admin"; // 老师 // debugType="teacher"; // 学生 -<<<<<<< HEAD //debugType="student"; -======= -// debugType="student"; ->>>>>>> 97765680b4f08ade017f6db22b1c76dcb0ae29f7 diff --git a/public/react/src/context/TPIContextProvider.js b/public/react/src/context/TPIContextProvider.js index fa0cbafcd..64b93f016 100644 --- a/public/react/src/context/TPIContextProvider.js +++ b/public/react/src/context/TPIContextProvider.js @@ -133,13 +133,15 @@ class TPIContextProvider extends Component { }) } + componentWillMount () { + // 拦截判断是否离开当前页面 + } + componentWillUnmount() { this.costTimeInterval && window.clearInterval(this.costTimeInterval) } componentDidMount() { - window.$(window).unload( ()=>{ - console.log(12321) - }); + // TODO 登录状态的判断? // request @@ -161,12 +163,16 @@ class TPIContextProvider extends Component { } }, 1000) - // 页面离开时存下用户的任务耗时 - window.$(window).bind('beforeunload', function (e) { - console.log(111111) + // // 页面离开时存下用户的任务耗时 + window.$(window).bind('beforeunload',()=>{ + console.log(111) this._updateCostTime(); }) + window.$(window).unload( ()=>{ + this._updateCostTime(); + + }); // // 页面离开时存下用户的任务耗时 // window.$(window).unload( ()=>{ // this._updateCostTime(); @@ -190,6 +196,7 @@ class TPIContextProvider extends Component { if (window.location.port == 3007) { testPath = 'http://test-newweb.educoder.net' } + console.log(222) // var url = `${testPath}/api/v1/games/${ game.identifier }/cost_time` var url = `${testPath}/api/tasks/${ game.identifier }/cost_time${getRandomNumber()}` window.$.ajax({