Merge branch 'dev_tj' into dev_aliyun

merge oj
dev_cxt
tangjiang 5 years ago
commit b8d27d1c5c

@ -4,10 +4,10 @@
* @Github:
* @Date: 2019-11-27 16:02:36
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-19 10:47:44
* @LastEditTime: 2019-12-19 19:47:32
*/
import './index.scss';
import React, { useState, useRef } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import { Tabs, Button, Icon } from 'antd';
import { connect } from 'react-redux';
import InitTabCtx from '../initTabCtx';
@ -23,10 +23,11 @@ const ControlSetting = (props) => {
submitLoading,
identifier,
excuteState,
showOrHideControl,
commitRecordDetail,
changeLoadingState,
changeSubmitLoadingStatus,
showOrHideControl,
changeShowOrHideControl,
// debuggerCode,
// startDebuggerCode, // 外部存入
onDebuggerCode,
@ -44,10 +45,14 @@ const ControlSetting = (props) => {
setDefaultActiveKey(key);
}
useEffect(() => {
setShowTextResult(props.showOrHideControl);
}, [props]);
// 显示/隐藏tab
const handleShowControl = () => {
setShowTextResult(!showTextResult);
showOrHideControl(!showTextResult);
changeShowOrHideControl(!showTextResult);
}
// 调试代码
@ -55,7 +60,7 @@ const ControlSetting = (props) => {
// console.log(formRef.current.handleTestCodeFormSubmit);
// 调出控制台界面
setShowTextResult(true);
showOrHideControl(true);
changeShowOrHideControl(true);
formRef.current.handleTestCodeFormSubmit(() => {
setDefaultActiveKey('2');
});
@ -131,19 +136,20 @@ const ControlSetting = (props) => {
const mapStateToProps = (state) => {
const {commonReducer, ojForUserReducer} = state;
const {loading, excuteState, submitLoading } = commonReducer;
const {loading, excuteState, submitLoading, showOrHideControl } = commonReducer;
const { commitRecordDetail } = ojForUserReducer;
return {
loading,
submitLoading,
excuteState,
showOrHideControl,
// identifier: user_program_identifier,
commitRecordDetail // 提交详情
};
};
// changeSubmitLoadingStatus
const mapDispatchToProps = (dispatch) => ({
showOrHideControl: (flag) => dispatch(actions.showOrHideControl(flag)),
changeShowOrHideControl: (flag) => dispatch(actions.changeShowOrHideControl(flag)),
changeLoadingState: (flag) => dispatch(actions.changeLoadingState(flag)),
changeSubmitLoadingStatus: (flag) => dispatch(actions.changeSubmitLoadingStatus(flag)),
debuggerCode: (identifier, values) => dispatch(actions.debuggerCode(identifier, values)),

@ -4,11 +4,11 @@
* @Github:
* @Date: 2019-11-25 17:50:33
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-19 15:26:46
* @LastEditTime: 2019-12-19 19:32:08
*/
import React, { useState } from 'react';
import { fromStore, toStore } from 'educoder';
import { Icon } from 'antd';
// import { Icon } from 'antd';
// import { Select } from 'antd';
// const { Option } = Select;
const SettingDrawer = (props) => {

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 15:02:52
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-19 17:52:31
* @LastEditTime: 2019-12-19 19:36:24
*/
import './index.scss';
import React, { useState, useRef, useEffect } from 'react';
@ -146,7 +146,7 @@ function MyMonacoEditor (props, ref) {
>
<Icon type="bell" />
</Badge>
<span onClick={handleRestoreCode} className="flex_normal">{renderRestore}</span>
<span onClick={handleRestoreCode} className="flex_normal" style={{ display: identifier ? 'inline-block' : 'none'}}>{renderRestore}</span>
<MyIcon className='code-icon' type="iconshezhi" onClick={handleShowDrawer}/>
</div>
<MonacoEditor

@ -11,7 +11,8 @@
align-items: center;
justify-content: space-between;
// padding: 0 30px;
background: #000;
// background: #000;
background: rgba(18,28,36,1);
color: #fff;
}
.code-title,

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-23 10:53:19
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-19 17:51:19
* @LastEditTime: 2019-12-19 19:48:20
*/
import './index.scss';
import React, { useEffect, useState } from 'react';
@ -29,7 +29,8 @@ function StudentStudy (props) {
userInfo,
hack_identifier,
// user_program_identifier,
restoreInitialCode
restoreInitialCode,
changeShowOrHideControl
} = props;
const {
@ -88,11 +89,14 @@ function StudentStudy (props) {
// 处理编辑
const handleClickEditor = () => {
changeShowOrHideControl(false);
props.saveEditorCodeForDetail();
props.history.push(`/problems/${_hack_id}/edit`);
}
// 处理退出
const handleClickQuit = () => {
// 将控制台关闭
changeShowOrHideControl(false);
props.saveEditorCodeForDetail();
props.history.push('/problems');
}
@ -164,6 +168,7 @@ const mapDispatchToProps = (dispatch) => ({
saveEditorCodeForDetail: (code) => dispatch(actions.saveEditorCodeForDetail(code)),
// 恢复初始代码
restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)),
changeShowOrHideControl: (flag) => dispatch(actions.changeShowOrHideControl(flag))
});
export default withRouter(connect(

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 14:59:51
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-19 15:06:49
* @LastEditTime: 2019-12-19 19:13:05
*/
import React, { useState, useEffect } from 'react';
import {connect} from 'react-redux';
@ -32,6 +32,7 @@ const RightPane = (props) => {
const [editorCode, setEditorCode] = useState('');
let initFlag = true;
useEffect(() => {
if (editor_code) {
setEditorCode(editor_code);
@ -51,8 +52,12 @@ const RightPane = (props) => {
// 代码块内容变化时
const handleCodeChange = (code) => {
// 保存用户提交的代码块
// console.log(code);
setEditorCode(code);
// 第一次回填代码内容时不更新;
if (initFlag) {
initFlag = false;
return;
}
if (!timer) {
timer = setInterval(() => {
clearInterval(timer);

@ -4,12 +4,12 @@
* @Github:
* @Date: 2019-11-27 16:30:50
* @LastEditors: tangjiang
* @LastEditTime: 2019-11-28 21:15:34
* @LastEditTime: 2019-12-19 19:42:10
*/
import types from "./actionTypes";
// 切换控制台显示与隐藏
export const showOrHideControl = (flag) => {
export const changeShowOrHideControl = (flag) => {
return {
type: types.SHOW_OR_HIDE_CONTROL,
payload: flag

@ -52,7 +52,7 @@ import {
} from './ojForUser';
import {
showOrHideControl,
changeShowOrHideControl,
changeLoadingState,
changeSubmitLoadingStatus,
changePublishLoadingStatus,
@ -97,7 +97,7 @@ export default {
testCaseOutputChange,
debuggerCode,
startProgramQuestion,
showOrHideControl,
changeShowOrHideControl,
changeLoadingState,
getUserCommitRecord,
getUserCommitRecordDetail,

@ -4,7 +4,7 @@
* @Github:
* @Date: 2019-11-27 13:41:48
* @LastEditors: tangjiang
* @LastEditTime: 2019-12-19 14:49:03
* @LastEditTime: 2019-12-19 20:10:39
*/
import types from "../actions/actionTypes";
import { Base64 } from 'js-base64';
@ -38,7 +38,12 @@ const ojForUserReducer = (state = initialState, action) => {
const { hack, test_case } = action.payload;
const { code }= hack;
let tempCode = Base64.decode(code)
let tempDesc = JSON.parse(hack.description);
let tempDesc;
try {
tempDesc = JSON.parse(hack.description);
} catch (error) {
tempDesc = hack.description;
}
Object.assign(hack, {code: tempCode, description: tempDesc});
return {
...state,

Loading…
Cancel
Save