|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2020-01-15 09:56:34
|
|
|
|
|
* @LastEditors : tangjiang
|
|
|
|
|
* @LastEditTime : 2020-01-17 15:34:40
|
|
|
|
|
* @LastEditTime : 2020-01-17 21:10:23
|
|
|
|
|
*/
|
|
|
|
|
import './index.scss';
|
|
|
|
|
import React, {useState, useEffect, useRef} from 'react';
|
|
|
|
@ -22,6 +22,10 @@ const App = (props) => {
|
|
|
|
|
wxCode,
|
|
|
|
|
path,
|
|
|
|
|
showLoading,
|
|
|
|
|
showDialog,
|
|
|
|
|
gold,
|
|
|
|
|
experience,
|
|
|
|
|
next_game,
|
|
|
|
|
// userCode,
|
|
|
|
|
testCase = [],
|
|
|
|
|
getWXCode,
|
|
|
|
@ -34,7 +38,8 @@ const App = (props) => {
|
|
|
|
|
updateWXCodeForInterval,
|
|
|
|
|
evaluateWxCode,
|
|
|
|
|
showWXCodeTextCase,
|
|
|
|
|
changeWXCodeEvaluateLoading
|
|
|
|
|
changeWXCodeEvaluateLoading,
|
|
|
|
|
changeWXCodeEvaluateDialog
|
|
|
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
const {identifier} = props.match.params;
|
|
|
|
@ -51,7 +56,10 @@ const App = (props) => {
|
|
|
|
|
path: '/',
|
|
|
|
|
domain: '.educoder.net'
|
|
|
|
|
});
|
|
|
|
|
cookie.save(_arr[0], _arr[1], { domain: '.educoder.net', path: '/'});
|
|
|
|
|
cookie.save(_arr[0], _arr[1], {
|
|
|
|
|
path: '/',
|
|
|
|
|
domain: '.educoder.net'
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -60,18 +68,22 @@ const App = (props) => {
|
|
|
|
|
// const [isVisible, setIsVisible] = useState(false);
|
|
|
|
|
const editorRef = useRef(null);
|
|
|
|
|
let timer = null;
|
|
|
|
|
|
|
|
|
|
const loadResult = (identifier) => {
|
|
|
|
|
// 加载代码块内容
|
|
|
|
|
getWXCode(identifier);
|
|
|
|
|
// 加载测试集
|
|
|
|
|
const params = {
|
|
|
|
|
path,
|
|
|
|
|
status: 0,
|
|
|
|
|
retry: 1
|
|
|
|
|
};
|
|
|
|
|
getWXCodeTestCase(identifier, params);
|
|
|
|
|
}
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
setCookier();
|
|
|
|
|
// 加载代码块内容
|
|
|
|
|
getWXCode(identifier, );
|
|
|
|
|
// 加载测试集
|
|
|
|
|
const params = {
|
|
|
|
|
path,
|
|
|
|
|
status: 0,
|
|
|
|
|
retry: 1
|
|
|
|
|
};
|
|
|
|
|
getWXCodeTestCase(identifier, params);
|
|
|
|
|
loadResult(identifier);
|
|
|
|
|
}, 0);
|
|
|
|
|
}, []);
|
|
|
|
|
// 关闭
|
|
|
|
@ -106,7 +118,7 @@ const App = (props) => {
|
|
|
|
|
timer = null;
|
|
|
|
|
// 调用更新代码
|
|
|
|
|
updateWXCodeForInterval(identifier, path);
|
|
|
|
|
}, 10000);
|
|
|
|
|
}, 5000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -128,11 +140,29 @@ const App = (props) => {
|
|
|
|
|
evaluateWxCode(identifier, path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关闭弹框
|
|
|
|
|
const handleCloseDialog = () => {
|
|
|
|
|
changeWXCodeEvaluateDialog(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查看测试集
|
|
|
|
|
const handleClickShowResult = () => {
|
|
|
|
|
showWXCodeTextCase(true);
|
|
|
|
|
changeWXCodeEvaluateDialog(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 下一关
|
|
|
|
|
const handleClickNext = () => {
|
|
|
|
|
changeWXCodeEvaluateDialog(false);
|
|
|
|
|
loadResult(next_game);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const tcclasses = isShow ? `wx-code-test-case active` : 'wx-code-test-case';
|
|
|
|
|
const loading = showLoading ? 'code-evaluate-loading active' : 'code-evaluate-loading';
|
|
|
|
|
const _val = sets_error_count === 0;
|
|
|
|
|
const dialog = showDialog ? 'pass-dialog active' : 'pass-dialog';
|
|
|
|
|
const _val = +sets_error_count === 0;
|
|
|
|
|
let resultTxt = (_val) ? '全部通过' : `${sets_error_count}组测试结果不匹配`;
|
|
|
|
|
const iclasses = _val ? 'iconfont icon-tishi1 icon success' : 'iconfont icon-tishi1 icon fail';
|
|
|
|
|
const iclasses = _val ? 'iconfont icon-wancheng icon success' : 'iconfont icon-tishi1 icon fail';
|
|
|
|
|
const tclasses = _val ? 'result-txt success' : 'result-txt fail';
|
|
|
|
|
const ulClasses = last_compile_output ? 'case-list hasResult' : 'case-list';
|
|
|
|
|
return (
|
|
|
|
@ -147,7 +177,7 @@ const App = (props) => {
|
|
|
|
|
options={{
|
|
|
|
|
selectOnLineNumbers: true,
|
|
|
|
|
automaticLayout: true,
|
|
|
|
|
fontSize: `32px`
|
|
|
|
|
fontSize: `36px`
|
|
|
|
|
}}
|
|
|
|
|
theme='dark'
|
|
|
|
|
editorDidMount={handleEditorChange}
|
|
|
|
@ -196,7 +226,7 @@ const App = (props) => {
|
|
|
|
|
测试集{i + 1}
|
|
|
|
|
</h2>
|
|
|
|
|
{
|
|
|
|
|
is_public
|
|
|
|
|
is_public && last_compile_output
|
|
|
|
|
? (result
|
|
|
|
|
? <span className="iconfont icon-wancheng case_item_success"></span>
|
|
|
|
|
: <span className="iconfont icon-jinggao1 case_item_fail"></span>)
|
|
|
|
@ -246,6 +276,34 @@ const App = (props) => {
|
|
|
|
|
<span className="loading-txt">测评中...</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
{/* 通过弹框 */}
|
|
|
|
|
<div className={dialog}>
|
|
|
|
|
<div className="pass-box">
|
|
|
|
|
<div className="pass-img"></div>
|
|
|
|
|
<div className="pass-ctx">
|
|
|
|
|
<div className="pass-title">{next_game ? '评测通过' : '恭喜通关'}</div>
|
|
|
|
|
<p className="pass-value">
|
|
|
|
|
金币 <span className="value_color">{gold > 0 ? `+${gold}` : 0}</span>,
|
|
|
|
|
经验值 <span className="value_color">{experience > 0 ? `+${experience}` : 0}</span>
|
|
|
|
|
</p>
|
|
|
|
|
{
|
|
|
|
|
next_game
|
|
|
|
|
? (
|
|
|
|
|
<div className="pass-btn">
|
|
|
|
|
<button className="btn btn-first" onClick={handleClickShowResult}>评测结果</button>
|
|
|
|
|
<button className="btn btn-second" onClick={handleClickNext}>下一关</button>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
: (
|
|
|
|
|
<div className="pass-btn-all">
|
|
|
|
|
<button className="btn btn-second" onClick={handleClickShowResult}>评测结果</button>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<i className="iconfont icon-roundclose icon_close" onClick={handleCloseDialog}></i>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
@ -256,8 +314,12 @@ const mapStateToProps = (state) => {
|
|
|
|
|
isShow,
|
|
|
|
|
wxCode,
|
|
|
|
|
userCode,
|
|
|
|
|
gold,
|
|
|
|
|
experience,
|
|
|
|
|
next_game,
|
|
|
|
|
testCase,
|
|
|
|
|
showLoading,
|
|
|
|
|
showDialog,
|
|
|
|
|
last_compile_output,
|
|
|
|
|
test_sets_count,
|
|
|
|
|
sets_error_count
|
|
|
|
@ -268,8 +330,12 @@ const mapStateToProps = (state) => {
|
|
|
|
|
isShow,
|
|
|
|
|
wxCode,
|
|
|
|
|
userCode,
|
|
|
|
|
gold,
|
|
|
|
|
experience,
|
|
|
|
|
next_game,
|
|
|
|
|
testCase,
|
|
|
|
|
showLoading,
|
|
|
|
|
showDialog,
|
|
|
|
|
last_compile_output,
|
|
|
|
|
test_sets_count,
|
|
|
|
|
sets_error_count
|
|
|
|
@ -284,7 +350,8 @@ const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
updateWXCodeForInterval: (identifier, path) => dispatch(actions.updateWXCodeForInterval(identifier, path)),
|
|
|
|
|
evaluateWxCode: (identifier, path) => dispatch(actions.evaluateWxCode(identifier, path)),
|
|
|
|
|
showWXCodeTextCase: (flag) => dispatch(actions.showWXCodeTextCase(flag)),
|
|
|
|
|
changeWXCodeEvaluateLoading: (flag) => dispatch(actions.changeWXCodeEvaluateLoading(flag))
|
|
|
|
|
changeWXCodeEvaluateLoading: (flag) => dispatch(actions.changeWXCodeEvaluateLoading(flag)),
|
|
|
|
|
changeWXCodeEvaluateDialog: (flag) => dispatch(actions.changeWXCodeEvaluateDialog(flag))
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export default connect(
|
|
|
|
|