|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2020-01-15 09:56:34
|
|
|
|
|
* @LastEditors : tangjiang
|
|
|
|
|
* @LastEditTime : 2020-01-17 21:10:23
|
|
|
|
|
* @LastEditTime : 2020-01-18 09:54:54
|
|
|
|
|
*/
|
|
|
|
|
import './index.scss';
|
|
|
|
|
import React, {useState, useEffect, useRef} from 'react';
|
|
|
|
@ -12,7 +12,7 @@ import MonacoEditor from '@monaco-editor/react';
|
|
|
|
|
import { Input, Icon } from 'antd';
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
import actions from '../../redux/actions';
|
|
|
|
|
import cookie from 'react-cookies';
|
|
|
|
|
// import cookie from 'react-cookies';
|
|
|
|
|
|
|
|
|
|
const { TextArea } = Input;
|
|
|
|
|
const App = (props) => {
|
|
|
|
@ -63,7 +63,15 @@ const App = (props) => {
|
|
|
|
|
}
|
|
|
|
|
setCookier();
|
|
|
|
|
const [isActive, setIsActive] = useState(-1);
|
|
|
|
|
const [tip, setTip] = useState('');
|
|
|
|
|
const [codes, setCodes] = useState(wxCode);
|
|
|
|
|
// const [isVisible, setIsVisible] = useState(false);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (codes !== props.wxCode) {
|
|
|
|
|
setCodes(props.wxCode);
|
|
|
|
|
}
|
|
|
|
|
}, [props]);
|
|
|
|
|
const editorRef = useRef(null);
|
|
|
|
|
let timer = null;
|
|
|
|
|
|
|
|
|
@ -129,6 +137,8 @@ const App = (props) => {
|
|
|
|
|
const handleResetCode = () => {
|
|
|
|
|
const result = window.confirm('你在本文件中修改的内容将丢失, 是否确定重新加载初始代码?');
|
|
|
|
|
if (result) {
|
|
|
|
|
setTip('初始化中...');
|
|
|
|
|
changeWXCodeEvaluateLoading(true);
|
|
|
|
|
identifier && restoreWXCode(identifier, { path });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -136,6 +146,7 @@ const App = (props) => {
|
|
|
|
|
const handleEvalateCode = () => {
|
|
|
|
|
changeWXCodeEvaluateLoading(true);
|
|
|
|
|
evaluateWxCode(identifier, path);
|
|
|
|
|
setTip('评测中...');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 关闭弹框
|
|
|
|
@ -171,7 +182,7 @@ const App = (props) => {
|
|
|
|
|
height="100%"
|
|
|
|
|
width="100%"
|
|
|
|
|
language="python"
|
|
|
|
|
value={wxCode}
|
|
|
|
|
value={codes}
|
|
|
|
|
options={{
|
|
|
|
|
selectOnLineNumbers: true,
|
|
|
|
|
automaticLayout: true,
|
|
|
|
@ -184,11 +195,11 @@ const App = (props) => {
|
|
|
|
|
<div className="wx-code-test">
|
|
|
|
|
<div className="flex-btn">
|
|
|
|
|
<span className="icon-btn" onClick={handleResetCode}>
|
|
|
|
|
<i className="iconfont icon-reset icon"></i>
|
|
|
|
|
<i className="iconfont icon-chushihua icon"></i>
|
|
|
|
|
<span className="icon-txt">初始化</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span className="icon-btn" onClick={handleClickTestCase}>
|
|
|
|
|
<i className="iconfont icon-base icon"></i>
|
|
|
|
|
<i className="iconfont icon-ceshiji icon"></i>
|
|
|
|
|
<span className="icon-txt">测试集</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
@ -224,10 +235,10 @@ const App = (props) => {
|
|
|
|
|
测试集{i + 1}
|
|
|
|
|
</h2>
|
|
|
|
|
{
|
|
|
|
|
is_public && last_compile_output
|
|
|
|
|
? (result
|
|
|
|
|
? <span className="iconfont icon-wancheng case_item_success"></span>
|
|
|
|
|
: <span className="iconfont icon-jinggao1 case_item_fail"></span>)
|
|
|
|
|
is_public
|
|
|
|
|
? (last_compile_output ?
|
|
|
|
|
(result ? <span className="iconfont icon-wancheng case_item_success"></span>
|
|
|
|
|
: <span className="iconfont icon-jinggao1 case_item_fail"></span>) : '')
|
|
|
|
|
: (<span className="case-item-tips">
|
|
|
|
|
隐藏测试集,暂不支持解锁和查看
|
|
|
|
|
{/* {result
|
|
|
|
@ -271,7 +282,7 @@ const App = (props) => {
|
|
|
|
|
<div className={loading}>
|
|
|
|
|
<span className="loading-flex">
|
|
|
|
|
<Icon className="loading-icon" type="loading" />
|
|
|
|
|
<span className="loading-txt">测评中...</span>
|
|
|
|
|
<span className="loading-txt">{tip}</span>
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
{/* 通过弹框 */}
|
|
|
|
@ -322,7 +333,7 @@ const mapStateToProps = (state) => {
|
|
|
|
|
test_sets_count,
|
|
|
|
|
sets_error_count
|
|
|
|
|
} = state.wxcodeReducer;
|
|
|
|
|
console.log(state);
|
|
|
|
|
// console.log(state);
|
|
|
|
|
return {
|
|
|
|
|
path,
|
|
|
|
|
isShow,
|
|
|
|
|