updateFile切换关卡

dev_unstable
hjm 6 years ago
parent 6e7c302c9c
commit 26b78bcfb3

@ -230,6 +230,7 @@ class MainContentContainer extends Component {
&& prevProps.game.identifier !== game.identifier) { && prevProps.game.identifier !== game.identifier) {
// 切换关卡时,停止轮训 // 切换关卡时,停止轮训
this.oldGameIdentifier = prevProps.game.identifier; this.oldGameIdentifier = prevProps.game.identifier;
this.doFileUpdateRequestOnCodeMirrorBlur(prevProps)
} }
} }
@ -384,8 +385,8 @@ class MainContentContainer extends Component {
} }
doFileUpdateRequestOnCodeMirrorBlur = () => { doFileUpdateRequestOnCodeMirrorBlur = (props) => {
var fileUpdatePromise = this.doFileUpdateRequest(true) var fileUpdatePromise = this.doFileUpdateRequest(true, undefined, props)
if (fileUpdatePromise) { if (fileUpdatePromise) {
fileUpdatePromise.then((resData) => { fileUpdatePromise.then((resData) => {
if (resData.status === -1) { // 保存文件出现异常 if (resData.status === -1) { // 保存文件出现异常
@ -494,7 +495,8 @@ class MainContentContainer extends Component {
} }
// forTest true 是评测时触发的file_update // forTest true 是评测时触发的file_update
doFileUpdateRequest(checkIfCodeChanged, forTest) { doFileUpdateRequest(checkIfCodeChanged, forTest, props) {
const _props = props || this.props;
const { codeStatus } = this.state; const { codeStatus } = this.state;
if (!forTest && codeStatus !== UPDATED) { // 已修改状态才能保存 if (!forTest && codeStatus !== UPDATED) { // 已修改状态才能保存
return; return;
@ -519,7 +521,7 @@ class MainContentContainer extends Component {
}) })
return null; return null;
} }
const { challenge, output_sets, onRunCodeTestFinish, myshixun } = this.props const { challenge, output_sets, onRunCodeTestFinish, myshixun } = _props
// var url = `${locationPath}/file_update?path=${encodeURIComponent(challenge.path)}` // var url = `${locationPath}/file_update?path=${encodeURIComponent(challenge.path)}`
var url = `/myshixuns/${myshixun.identifier}/update_file.json` var url = `/myshixuns/${myshixun.identifier}/update_file.json`

Loading…
Cancel
Save