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 [height, setHeight] = useState('calc(100% - 56px)');
const editorRef = useRef(null); const editorRef = useRef(null);
console.log(language, code, '-------========----------')
// useEffect(() => {
// setEditCode(props.code || '');
// }, [props]);
useEffect(() => { useEffect(() => {
setHeight(showOrHideControl ? 'calc(100% - 378px)' : 'calc(100% - 56px)'); setHeight(showOrHideControl ? 'calc(100% - 378px)' : 'calc(100% - 56px)');

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

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

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

Loading…
Cancel
Save