Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_tj
杨树林 5 years ago
commit 687017821d

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

@ -14,7 +14,7 @@
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
align-items: center; align-items: center;
height: 120px; height: 150px;
background-color: #052645; background-color: #052645;
padding: 0 50px; padding: 0 50px;
} }
@ -33,7 +33,7 @@
font-size: 32px !important; font-size: 32px !important;
transform: scale(2); transform: scale(2);
position: relative; position: relative;
top: 10px; // top: 10px;
} }
// .icon-reset{ // .icon-reset{
// transform: scale(2.4); // transform: scale(2.4);
@ -43,10 +43,11 @@
// } // }
&:last-child{ &:last-child{
margin-left: 50px; margin-left: 60px;
} }
.icon-txt{ .icon-txt{
font-size: 32px; // margin-top: 5px;
font-size: 28px;
} }
} }
} }
@ -55,11 +56,12 @@
border: none; border: none;
outline: none; outline: none;
border-radius: 9999px; border-radius: 9999px;
padding: 0 40px; padding: 0 50px;
line-height: 72px; line-height: 92px;
font-size: 36px; font-size: 38px;
color: #fff; color: #fff;
background:#2EA4FF; background:#2EA4FF;
letter-spacing: 2;
} }
.wx-code-test-case{ .wx-code-test-case{
@ -107,7 +109,7 @@
font-size: 36px; font-size: 36px;
} }
.header-close{ .header-close{
// font-size: 28px; // font-size: 36px;
font-size: 36px; font-size: 36px;
color: #2EA4FF; color: #2EA4FF;
} }
@ -208,12 +210,12 @@
} }
.case-item-tips{ .case-item-tips{
font-size: 28px; font-size: 36px;
} }
.case-item-desc{ .case-item-desc{
display: none; display: none;
flex-direction: column; flex-direction: column;
font-size: 28px; font-size: 36px;
line-height: 1.5; line-height: 1.5;
&.active{ &.active{
@ -227,7 +229,7 @@
.text-area-style{ .text-area-style{
background:#010E1F !important; background:#010E1F !important;
color: #fff; color: #fff;
font-size: 28px; font-size: 36px;
line-height: 1.5; line-height: 1.5;
border: none; border: none;
} }

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2020-01-15 15:41:10 * @Date: 2020-01-15 15:41:10
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-17 21:06:46 * @LastEditTime : 2020-01-18 09:52:55
*/ */
import types from './actionTypes.js'; import types from './actionTypes.js';
import { import {
@ -46,7 +46,7 @@ export const getWXCodeTestCase = (identifier, params) => {
game_id: data.game && data.game.id, game_id: data.game && data.game.id,
myIdentifier: data.myshixun.identifier, myIdentifier: data.myshixun.identifier,
exec_time: data.challenge.exec_time, 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, last_compile_output: data.last_compile_output,
test_sets_count: data.test_sets_count, test_sets_count: data.test_sets_count,
sets_error_count: data.sets_error_count sets_error_count: data.sets_error_count
@ -65,6 +65,10 @@ export const restoreWXCode = (identifier, params) => {
fetchRestoreWxCode(identifier, params).then(res => { fetchRestoreWxCode(identifier, params).then(res => {
console.log('点击了初始化代码: ', res); console.log('点击了初始化代码: ', res);
const {data} = res; const {data} = res;
dispatch({
type: types.SHOW_WX_CODE_LOADING,
payload: false
})
dispatch({ dispatch({
type: types.GET_WXCODE_BY_IDENTIFIER, type: types.GET_WXCODE_BY_IDENTIFIER,
payload: data.content || '' 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) => { return (dispatch, getState) => {
const {wxCode, userCode, game_id, myIdentifier} = getState().wxcodeReducer; const {wxCode, userCode, game_id, myIdentifier, path} = getState().wxcodeReducer;
if (wxCode !== userCode) { 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
});
});
} }
} }
} }
@ -133,10 +142,12 @@ export const evaluateWxCode = (identifier, path) => {
// 定时调用 game_status fetchWxCodeGameStatus // 定时调用 game_status fetchWxCodeGameStatus
let count = 1; let count = 1;
const intervalTime = 500; const intervalTime = 500;
let time_out = false;
function wxCodeGameStatus (intervalTime, finalTime, count, timer) { function wxCodeGameStatus (intervalTime, finalTime, count, timer) {
const excuteTime = (count++) * intervalTime; // 当前执行时间 const excuteTime = (count++) * intervalTime; // 当前执行时间
console.log(finalTime, count, excuteTime); console.log(finalTime, count, excuteTime);
fetchWxCodeGameStatus(identifier, {resubmit: _resubmit}).then(r => { if ((excuteTime / 1000) > (finalTime + 1)) time_out = true;
fetchWxCodeGameStatus(identifier, {resubmit: _resubmit, time_out}).then(r => {
const { status, test_sets = [], gold, experience, next_game, sets_error_count } = r.data; const { status, test_sets = [], gold, experience, next_game, sets_error_count } = r.data;
if (+status > -1 || ((excuteTime / 1000) > (finalTime + 1))) { if (+status > -1 || ((excuteTime / 1000) > (finalTime + 1))) {
clearInterval(timer); clearInterval(timer);

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2020-01-15 15:37:44 * @Date: 2020-01-15 15:37:44
* @LastEditors : tangjiang * @LastEditors : tangjiang
* @LastEditTime : 2020-01-17 19:50:00 * @LastEditTime : 2020-01-18 09:46:04
*/ */
import types from "../actions/actionTypes"; import types from "../actions/actionTypes";
const initialState = { const initialState = {
@ -30,6 +30,7 @@ const wxcodeReducer = (state = initialState, action) => {
const { payload, type } = action; const { payload, type } = action;
switch (type) { switch (type) {
case types.GET_WXCODE_BY_IDENTIFIER: case types.GET_WXCODE_BY_IDENTIFIER:
console.log('=====>>>>>', payload);
return { return {
...state, ...state,
wxCode: payload, wxCode: payload,

Loading…
Cancel
Save