From f3d6ead7caa61a8626732fa343928293f02bf4d8 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Tue, 19 Nov 2019 17:54:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9TPI=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/context/TPIContextProvider.js | 13 +++++------ .../modules/page/main/CodeRepositoryView.js | 23 ------------------- 2 files changed, 6 insertions(+), 30 deletions(-) diff --git a/public/react/src/context/TPIContextProvider.js b/public/react/src/context/TPIContextProvider.js index bcd470134..d63e02174 100644 --- a/public/react/src/context/TPIContextProvider.js +++ b/public/react/src/context/TPIContextProvider.js @@ -129,7 +129,8 @@ class TPIContextProvider extends Component { tpm_cases_modified, tpm_modified, tpm_script_modified, - showUpdateDialog: false + showUpdateDialog: false, + initTime: 0 }) } @@ -145,7 +146,6 @@ class TPIContextProvider extends Component { window.__fetchAllFlag = false; this.fetchAll(stageId); - this.costTimeInterval = window.setInterval(()=> { const { game } = this.state; if (!game || game.status === 2) { // 已完成的任务不需要计时 @@ -167,7 +167,7 @@ class TPIContextProvider extends Component { } // force 评测通过后,异步执行该方法,强制同步costTime到服务端 _updateCostTime(async = false, force) { - const { game, loading } = this.state; + const { game, loading, initTime = 0 } = this.state; // TODO 还有一种情况,通关后cost_time计时停止,没法通过这个判断 if (!force && (loading || !game || game.status === 2)) { return; // 已完成的任务不需要处理 @@ -178,12 +178,13 @@ class TPIContextProvider extends Component { } // var url = `${testPath}/api/v1/games/${ game.identifier }/cost_time` var url = `${testPath}/api/tasks/${ game.identifier }/cost_time` + const disTime = Math.abs(game.cost_time - initTime); window.$.ajax({ type: 'get', url: url, async: async, //IMPORTANT, the call will be synchronous data: { - time: game.cost_time + time: disTime } }).done((data) => { console.log('complete'); @@ -406,7 +407,6 @@ pop_box_new(htmlvalue, 480, 182); } resData.game = game; - const { tpm_cases_modified, tpm_modified, tpm_script_modified, myshixun } = resData; if (myshixun.system_tip) { // system_tip为true的时候 不弹框提示用户更新 @@ -440,7 +440,7 @@ pop_box_new(htmlvalue, 480, 182); this.setState({ ...resData, - + initTime: game.cost_time, currentGamePassed: false, loading: false, testSetsExpandedArray: testSetsExpandedArrayInitVal.slice(0), @@ -519,7 +519,6 @@ pop_box_new(htmlvalue, 480, 182); // var url = `/api/v1/games/${stageId}` var url = `/tasks/${stageId}.json` - // {"status":1,"message":"undefined method `authenticate!' for #"} window.__fetchAllFlag = true; diff --git a/public/react/src/modules/page/main/CodeRepositoryView.js b/public/react/src/modules/page/main/CodeRepositoryView.js index acdf7693d..5dd87f6a0 100644 --- a/public/react/src/modules/page/main/CodeRepositoryView.js +++ b/public/react/src/modules/page/main/CodeRepositoryView.js @@ -112,29 +112,6 @@ class CodeRepositoryView extends Component { .removeClass("codeRepoShow") // .removeClass("fa-caret-down").addClass("fa-caret-right"); }) - - // $('#codetab_con_1').append(``) - // $('#codetab_con_1 .codemirrorBackground').hide() - window.addEventListener('beforeunload', this.beforeUnload); - } - - componentWillUnmount () { - window.removeEventListener('beforeunload', this.beforeUnload); - } - - beforeUnload = (e) => { - // console.log(this.props); - const { game } = this.props; - const url = `/api/tasks/${game.identifier}/cost_time.json`; - axios.get(url).then(res => { - // TODO - }); - const msg = '确定要离开吗?'; - e = e || window.event; - if (e) { - e.returnValue = msg; - } - return msg; } onTreeSelect = (selectedKeys, info) => {