diff --git a/src/components/timer-panel/index.jsx b/src/components/timer-panel/index.jsx
index 2135db7..51d9306 100644
--- a/src/components/timer-panel/index.jsx
+++ b/src/components/timer-panel/index.jsx
@@ -22,6 +22,7 @@ export default ({ identifier, onUpdateCostTime, status, defaultTime = 0,type })
lastV.current = defaultTime
setCostTime(defaultTime)
//已经评测完成的不需要再计时
+
if (status !== 2) {
let timeHandler = function () {
setCostTime(costTime => costTime + 1)
@@ -36,7 +37,20 @@ export default ({ identifier, onUpdateCostTime, status, defaultTime = 0,type })
return () => {
clearInterval(tid)
unSub()
+
+
if(type===1){
+ let bodys = {
+ answer_long_time: lastV.current*1000,
+ };
+ let headers = {
+ type: 'application/json',
+ };
+ let blob = new Blob([JSON.stringify(bodys)], headers);
+ window.navigator.sendBeacon(
+ `https://test-data.educoder.net/api/myproblems/${identifier}/save_long_time.json?answer_long_time=${lastV.current*1000}`,
+ blob,
+ );
mediator.publish('reset-game')
return
}
diff --git a/src/routes/tasks/hack-game/index.jsx b/src/routes/tasks/hack-game/index.jsx
index 922671b..ea592d8 100644
--- a/src/routes/tasks/hack-game/index.jsx
+++ b/src/routes/tasks/hack-game/index.jsx
@@ -1,10 +1,10 @@
import React, { useState, useEffect, useRef, useCallback, Fragment } from 'react'
import Editor from './ace-editor'
-import Modal from '../../../components/modal'
+import Modals from '../../../components/modal'
import FooterBar from './footer-bar'
import TestCaseList from './test-case-list'
import './index.less'
-import { fetchWxCode, UpdateHackWxCode, restoreWxHackCode, fetchWxHackCodeGameBuild, sumbitCode, updateCostTime } from '../../../util/rest-api'
+import { fetchWxCode, UpdateHackWxCode, restoreWxHackCode, fetchWxHackCodeGameBuild, sumbitCode, updateCostTimes } from '../../../util/rest-api'
import { useHistory, Route, Switch, useRouteMatch,useParams } from 'react-router-dom'
import { Toast } from 'antd-mobile'
import TestResultDialog from './test-result-dialog'
@@ -62,6 +62,8 @@ export default ({ source, taskId,callback }) => {
const [isShowTest, setIsShowTest] = useState(false)
const [isShowResult, setIsShowResult] = useState(false)
const [language,setlanguage]=useState()
+ const [isshow,setisshow]=useState(false);
+ const [datas,setdatas]=useState();
const [opacity, setOpacity] = useState(1)
const [code, setCode] = useState({
content: {
@@ -122,7 +124,9 @@ export default ({ source, taskId,callback }) => {
fetchWxHackCodeGameBuilds()
}, 1000);
}else{
- Toast.show(ExecuteDict[rs?.data?.data?.status])
+ setdatas(rs?.data?.data);
+ // Toast.show(ExecuteDict[rs?.data?.data?.status])
+ setisshow(true);
setTimeout(() => {
Toast.hide()
}, 3000);
@@ -141,7 +145,6 @@ export default ({ source, taskId,callback }) => {
}
async function onReset() {
- debugger
if (taskId) {
const response = await restoreWxHackCode(taskId,{})
const { data } = response
@@ -165,9 +168,9 @@ export default ({ source, taskId,callback }) => {
lastedValue.current = window.decodeURIComponent(
escape(window.atob(hack?.code)))
setEditValue(lastedValue.current)
-
}
if (taskId) {
+
init()
}
}, [hack.code])
@@ -181,6 +184,10 @@ export default ({ source, taskId,callback }) => {
setOpacity(routeMatch.isExact ? 1 : 0)
}, [routeMatch.isExact])
+ useEffect(()=>{
+ // mediator.publish('update-cost-time')
+ },[])
+
useEffect(() => {
document.body.addEventListener('focusout', scrollT)
@@ -198,9 +205,9 @@ export default ({ source, taskId,callback }) => {
}
const timePanelOpt = {
identifier: taskId,
- // onUpdateCostTime: updateCostTime,
+ onUpdateCostTime: updateCostTimes,
type:1,
- defaultTime: hack.answer_long_time,
+ defaultTime: hack.answer_long_time/1000,
status: hack.status
}
@@ -254,14 +261,14 @@ export default ({ source, taskId,callback }) => {