修改TPI时间

dev_home
tangjiang 5 years ago
parent e4d65cf571
commit f3d6ead7ca

@ -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 #<Grape::Endpoint:0xc8c91c0>"}
window.__fetchAllFlag = true;

@ -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) => {

Loading…
Cancel
Save