diff --git a/public/react/src/modules/wxcode/index.js b/public/react/src/modules/wxcode/index.js
index 7e5c9362b..60eb973d3 100644
--- a/public/react/src/modules/wxcode/index.js
+++ b/public/react/src/modules/wxcode/index.js
@@ -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) => {
@@ -65,7 +65,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;
@@ -131,6 +139,8 @@ const App = (props) => {
const handleResetCode = () => {
const result = window.confirm('你在本文件中修改的内容将丢失, 是否确定重新加载初始代码?');
if (result) {
+ setTip('初始化中...');
+ changeWXCodeEvaluateLoading(true);
identifier && restoreWXCode(identifier, { path });
}
}
@@ -138,6 +148,7 @@ const App = (props) => {
const handleEvalateCode = () => {
changeWXCodeEvaluateLoading(true);
evaluateWxCode(identifier, path);
+ setTip('评测中...');
}
// 关闭弹框
@@ -173,7 +184,7 @@ const App = (props) => {
height="100%"
width="100%"
language="python"
- value={wxCode}
+ value={codes}
options={{
selectOnLineNumbers: true,
automaticLayout: true,
@@ -186,11 +197,11 @@ const App = (props) => {
-
+
初始化
-
+
测试集
@@ -226,10 +237,10 @@ const App = (props) => {
测试集{i + 1}
{
- is_public && last_compile_output
- ? (result
- ?
- :
)
+ is_public
+ ? (last_compile_output ?
+ (result ?
+ :
) : '')
: (
隐藏测试集,暂不支持解锁和查看
{/* {result
@@ -273,7 +284,7 @@ const App = (props) => {
- 测评中...
+ {tip}
{/* 通过弹框 */}
@@ -324,7 +335,7 @@ const mapStateToProps = (state) => {
test_sets_count,
sets_error_count
} = state.wxcodeReducer;
- console.log(state);
+ // console.log(state);
return {
path,
isShow,
diff --git a/public/react/src/modules/wxcode/index.scss b/public/react/src/modules/wxcode/index.scss
index d31b3c55d..0c487e0c3 100644
--- a/public/react/src/modules/wxcode/index.scss
+++ b/public/react/src/modules/wxcode/index.scss
@@ -107,7 +107,7 @@
font-size: 36px;
}
.header-close{
- // font-size: 28px;
+ // font-size: 36px;
font-size: 36px;
color: #2EA4FF;
}
@@ -208,12 +208,12 @@
}
.case-item-tips{
- font-size: 28px;
+ font-size: 36px;
}
.case-item-desc{
display: none;
flex-direction: column;
- font-size: 28px;
+ font-size: 36px;
line-height: 1.5;
&.active{
@@ -227,7 +227,7 @@
.text-area-style{
background:#010E1F !important;
color: #fff;
- font-size: 28px;
+ font-size: 36px;
line-height: 1.5;
border: none;
}
diff --git a/public/react/src/redux/actions/wxCode.js b/public/react/src/redux/actions/wxCode.js
index 89b813e7b..8d240b0d9 100644
--- a/public/react/src/redux/actions/wxCode.js
+++ b/public/react/src/redux/actions/wxCode.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2020-01-15 15:41:10
* @LastEditors : tangjiang
- * @LastEditTime : 2020-01-17 21:28:23
+ * @LastEditTime : 2020-01-18 09:52:55
*/
import types from './actionTypes.js';
import {
@@ -46,7 +46,7 @@ export const getWXCodeTestCase = (identifier, params) => {
game_id: data.game && data.game.id,
myIdentifier: data.myshixun.identifier,
exec_time: data.challenge.exec_time,
- path: _path.split(';')[0] || _path.split(';')[0],
+ path: _path.split(';')[0] || _path.split(';')[0] || _path,
last_compile_output: data.last_compile_output,
test_sets_count: data.test_sets_count,
sets_error_count: data.sets_error_count
@@ -65,6 +65,10 @@ export const restoreWXCode = (identifier, params) => {
fetchRestoreWxCode(identifier, params).then(res => {
console.log('点击了初始化代码: ', res);
const {data} = res;
+ dispatch({
+ type: types.SHOW_WX_CODE_LOADING,
+ payload: false
+ })
dispatch({
type: types.GET_WXCODE_BY_IDENTIFIER,
payload: data.content || ''
@@ -90,11 +94,16 @@ export const updateWxCode = (path, identifier, userCode, game_id, evaluate = 0,)
});
}
// 定时更新代码内容
-export const updateWXCodeForInterval = (identifier, path) => {
+export const updateWXCodeForInterval = (identifier, $path) => {
return (dispatch, getState) => {
- const {wxCode, userCode, game_id, myIdentifier} = getState().wxcodeReducer;
+ const {wxCode, userCode, game_id, myIdentifier, path} = getState().wxcodeReducer;
if (wxCode !== userCode) {
- updateWxCode(path, myIdentifier, userCode, game_id, 0);
+ updateWxCode(path, myIdentifier, userCode, game_id, 0).then(res => {
+ dispatch({
+ type: types.GET_WXCODE_BY_IDENTIFIER,
+ payload: userCode
+ });
+ });
}
}
}
diff --git a/public/react/src/redux/reducers/wxcodeReducer.js b/public/react/src/redux/reducers/wxcodeReducer.js
index 24aa4a58b..2caf25a84 100644
--- a/public/react/src/redux/reducers/wxcodeReducer.js
+++ b/public/react/src/redux/reducers/wxcodeReducer.js
@@ -4,7 +4,7 @@
* @Github:
* @Date: 2020-01-15 15:37:44
* @LastEditors : tangjiang
- * @LastEditTime : 2020-01-17 19:50:00
+ * @LastEditTime : 2020-01-18 09:46:04
*/
import types from "../actions/actionTypes";
const initialState = {
@@ -30,6 +30,7 @@ const wxcodeReducer = (state = initialState, action) => {
const { payload, type } = action;
switch (type) {
case types.GET_WXCODE_BY_IDENTIFIER:
+ console.log('=====>>>>>', payload);
return {
...state,
wxCode: payload,