From bb885624ee94794f72166ccba4c9704e72eca131 Mon Sep 17 00:00:00 2001 From: dinglink <837816638@qq.com> Date: Mon, 23 Mar 2020 17:35:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=AE=9E=E8=AE=AD=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E6=97=A0=E6=95=B0=E6=8D=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/react/src/AppConfig.js | 2 +- .../react/src/context/TPIContextProvider.js | 23 +++++++++++++++---- public/react/src/modules/page/LeftNav.js | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/public/react/src/AppConfig.js b/public/react/src/AppConfig.js index 5182cb991..d91c42fcf 100644 --- a/public/react/src/AppConfig.js +++ b/public/react/src/AppConfig.js @@ -46,7 +46,7 @@ debugType = "admin"; // 老师 // debugType="teacher"; // 学生 - debugType="student"; + //debugType="student"; diff --git a/public/react/src/context/TPIContextProvider.js b/public/react/src/context/TPIContextProvider.js index bb1e0bef4..fa0cbafcd 100644 --- a/public/react/src/context/TPIContextProvider.js +++ b/public/react/src/context/TPIContextProvider.js @@ -137,6 +137,9 @@ class TPIContextProvider extends Component { this.costTimeInterval && window.clearInterval(this.costTimeInterval) } componentDidMount() { + window.$(window).unload( ()=>{ + console.log(12321) + }); // TODO 登录状态的判断? // request @@ -158,12 +161,24 @@ class TPIContextProvider extends Component { } }, 1000) - // 页面离开时存下用户的任务耗时 + // 页面离开时存下用户的任务耗时 + window.$(window).bind('beforeunload', function (e) { + console.log(111111) + this._updateCostTime(); + }) + + // // 页面离开时存下用户的任务耗时 + // window.$(window).unload( ()=>{ + // this._updateCostTime(); + + // }); - window.$(window).unload( ()=>{ - this._updateCostTime(); - }); } + + + + + // force 评测通过后,异步执行该方法,强制同步costTime到服务端 _updateCostTime(async = false, force) { const { game, loading } = this.state; diff --git a/public/react/src/modules/page/LeftNav.js b/public/react/src/modules/page/LeftNav.js index d1a7b1a11..63628d7ff 100644 --- a/public/react/src/modules/page/LeftNav.js +++ b/public/react/src/modules/page/LeftNav.js @@ -59,7 +59,7 @@ class LeftNav extends Component {