From 15dff68e15e75487a26562d8144531aa2bd996d8 Mon Sep 17 00:00:00 2001 From: harry Date: Sat, 7 Mar 2020 23:42:08 +0800 Subject: [PATCH] fix issues/28420 --- .../components/myMonacoEditor/index.js | 5 +-- .../newOrEditTask/leftpane/editorTab/index.js | 10 ++--- .../newOrEditTask/rightpane/index.js | 40 +++---------------- .../react/src/redux/reducers/ojFormReducer.js | 38 +++++++++--------- 4 files changed, 28 insertions(+), 65 deletions(-) diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js index d9acbe5ee..383c4dd63 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.js +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js @@ -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)'); diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js index 1ea3a3907..5150de25f 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js @@ -22,20 +22,17 @@ const FormItem = Form.Item; const { Option } = Select; const maps = { language: [ - { title: (请选择), key: '' }, { title: 'C', key: 'C' }, { title: 'C++', key: 'C++' }, { title: 'Python', key: 'Python' }, { title: 'Java', key: 'Java' } ], difficult: [ - { title: (请选择), key: '' }, { title: '简单', key: '1' }, { title: '中等', key: '2' }, { title: '困难', key: '3' } ], category: [ - { title: (请选择), 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} > - {getOptions('language')} @@ -478,7 +475,6 @@ class EditTab extends React.Component { /> - {/* 添加测试用例 */} diff --git a/public/react/src/modules/developer/newOrEditTask/rightpane/index.js b/public/react/src/modules/developer/newOrEditTask/rightpane/index.js index 18d80c9d7..33e368c4a 100644 --- a/public/react/src/modules/developer/newOrEditTask/rightpane/index.js +++ b/public/react/src/modules/developer/newOrEditTask/rightpane/index.js @@ -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 (
- {/* */}
) } diff --git a/public/react/src/redux/reducers/ojFormReducer.js b/public/react/src/redux/reducers/ojFormReducer.js index adbbcfa92..e0f8a7d8d 100644 --- a/public/react/src/redux/reducers/ojFormReducer.js +++ b/public/react/src/redux/reducers/ojFormReducer.js @@ -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: