fix issues/28420

dev_aliyun2
harry 5 years ago
parent 593b973217
commit 15dff68e15

@ -48,10 +48,7 @@ function MyMonacoEditor(props, ref) {
});
const [height, setHeight] = useState('calc(100% - 56px)');
const editorRef = useRef(null);
// useEffect(() => {
// setEditCode(props.code || '');
// }, [props]);
console.log(language, code, '-------========----------')
useEffect(() => {
setHeight(showOrHideControl ? 'calc(100% - 378px)' : 'calc(100% - 56px)');

@ -22,20 +22,17 @@ const FormItem = Form.Item;
const { Option } = Select;
const maps = {
language: [
{ title: (<span style={{ color: 'rgba(0, 0, 0, 0.35)' }}>请选择</span>), key: '' },
{ title: 'C', key: 'C' },
{ title: 'C++', key: 'C++' },
{ title: 'Python', key: 'Python' },
{ title: 'Java', key: 'Java' }
],
difficult: [
{ title: (<span style={{ color: 'rgba(0, 0, 0, 0.35)' }}>请选择</span>), key: '' },
{ title: '简单', key: '1' },
{ title: '中等', key: '2' },
{ title: '困难', key: '3' }
],
category: [
{ title: (<span style={{ color: 'rgba(0, 0, 0, 0.35)' }}>请选择</span>), key: '' },
{ title: '程序设计', key: '1' },
{ title: '算法', key: '2' }
],
@ -58,7 +55,7 @@ class EditTab extends React.Component {
top: 500,
bottom: 20,
offsetTop: 0,
showAdd: props.tag_discipline_id || false
showAdd: props.tag_discipline_id || false
// knowledges: [],
// coursers: [] // 选中的课程
}
@ -100,7 +97,7 @@ class EditTab extends React.Component {
}
// this.scrollRef.current.scrollTo(1000);
this.props.addTestCase({testCase: obj, tcValidate: validateObj});
this.props.addTestCase({ testCase: obj, tcValidate: validateObj });
}
// componentDidUpdate (nextProp) {
@ -440,7 +437,7 @@ class EditTab extends React.Component {
help={ojFormValidate.language.errMsg}
colon={false}
>
<Select onChange={this.handleLanguageChange} value={`${ojForm.language}`}>
<Select onChange={this.handleLanguageChange} defaultValue={'C'} value={`${ojForm.language}`}>
{getOptions('language')}
</Select>
</FormItem>
@ -478,7 +475,6 @@ class EditTab extends React.Component {
/>
</FormItem>
</Form>
{/* 添加测试用例 */}

@ -6,56 +6,26 @@
* @LastEditors : tangjiang
* @LastEditTime : 2019-12-27 19:33:50
*/
import './index.less';
import React, { useState, useEffect } from 'react';
import './index.scss';
import React from 'react';
import { connect } from 'react-redux';
import MyMonacoEditor from '../../components/myMonacoEditor';
// import ControlSetting from '../../components/controlSetting';
import actions from '../../../../redux/actions';
function RightPane(props, ref) {
function RightPane(props) {
const {
// identifier,
code,
showCode,
language,
// onSubmitForm,
saveOjFormCode
} = props;
const { code, language = 'C', saveOjFormCode } = props;
// let timer = null;
// 代码改变时,保存
const handleCodeChange = (updateCode) => {
// if (props.identifier) {
// // 保存用户输入的代码
// if (!timer) {
// timer = setInterval(() => {
// clearInterval(timer);
// timer = null;
// }, 3000);
// }
// }
saveOjFormCode(updateCode);
}
// 启动调试代码
// const handleDebuggerCode = (value) => {
// console.log('调用的代码调试====', value);
// }
return (
<div className={'right_pane_code_wrap'}>
<MyMonacoEditor
language={language}
code={showCode}
code={code}
onCodeChange={handleCodeChange} />
{/* <ControlSetting
// identifier={identifier}
inputValue={props.input}
onSubmitForm={onSubmitForm}
// onDebuggerCode={handleDebuggerCode}
/> */}
</div>
)
}

@ -12,9 +12,9 @@ import types from '../actions/actionTypes';
const init = {
ojForm: {
name: '', // 任务名称
language: '',
language: 'C',
description: '',
difficult: '',
difficult: '1',
sub_discipline_id: '', // 方向
// category: '',
// openOrNot: 1,
@ -114,7 +114,7 @@ const ojFormReducer = (state = initialState, action) => {
};
}
switch (action.type) {
case types.VALIDATE_OJ_FORM:
case types.VALIDATE_OJ_FORM:
// 验证成功后,调用后台接口
return returnState(state, ojForm, ojFormValidate);
case types.SAVE_OJ_FORM_CODE:
@ -278,7 +278,7 @@ const ojFormReducer = (state = initialState, action) => {
// 更新验证消息
const curIOjTestValidate = state.testCasesValidate.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, {input});
return Object.assign({}, tc, { input });
}
return tc;
});
@ -294,20 +294,20 @@ const ojFormReducer = (state = initialState, action) => {
testCases: [...curITestValues]
}
case types.TEST_CASE_OUTPUT_CHANGE:
const { output } = action.payload;
// 更新验证消息
const curOOjTestValidate = state.testCasesValidate.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, {output});
}
return tc;
});
let curOTestValues = state.testCases.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, { output: action.payload.value })
}
return tc;
});
const { output } = action.payload;
// 更新验证消息
const curOOjTestValidate = state.testCasesValidate.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, { output });
}
return tc;
});
let curOTestValues = state.testCases.map((tc, i) => {
if (i === action.payload.index) {
return Object.assign({}, tc, { output: action.payload.value })
}
return tc;
});
return {
...state,
testCasesValidate: [...curOOjTestValidate],
@ -355,7 +355,7 @@ const ojFormReducer = (state = initialState, action) => {
console.log(_p.tag_discipline_id);
return {
...state,
ojForm: Object.assign({}, state.ojForm, {difficult: _p.difficult, sub_discipline_id: _p.sub_discipline_id}),
ojForm: Object.assign({}, state.ojForm, { difficult: _p.difficult, sub_discipline_id: _p.sub_discipline_id }),
tag_discipline_id: _p.tag_discipline_id || []
}
case types.SET_SEARCH_PARAMS:

Loading…
Cancel
Save