diff --git a/public/react/package.json b/public/react/package.json index b06c70e5f..66db5e6f8 100644 --- a/public/react/package.json +++ b/public/react/package.json @@ -89,6 +89,7 @@ "redux-thunk": "2.3.0", "rsuite": "^4.0.1", "sass-loader": "7.3.1", + "scroll-into-view": "^1.12.3", "store": "^2.0.12", "style-loader": "0.19.0", "styled-components": "^4.1.3", diff --git a/public/react/src/App.js b/public/react/src/App.js index 217848308..1c15b3dab 100644 --- a/public/react/src/App.js +++ b/public/react/src/App.js @@ -667,8 +667,15 @@ class App extends Component { }/> - - + () + } /> + () + } /> { changeLoadingState, changeSubmitLoadingStatus, showOrHideControl, - // debuggerCode + // debuggerCode, + // startDebuggerCode, // 外部存入 + onDebuggerCode, updateCode, onSubmitForm } = props; @@ -62,7 +64,7 @@ const ControlSetting = (props) => { // 提交 const handleSubmit = (e) => { e.preventDefault(); - changeSubmitLoadingStatus(true) + changeSubmitLoadingStatus(true); onSubmitForm && onSubmitForm(); } @@ -71,9 +73,10 @@ const ControlSetting = (props) => { // 改变状态值 changeLoadingState(true); // 调用代码保存接口, 成功后再调用调试接口 - updateCode(identifier, values, 'debug'); + // updateCode(identifier, values, 'debug'); // 调用调试接口 // debuggerCode(identifier, values); + onDebuggerCode(values); } return ( @@ -128,13 +131,13 @@ const ControlSetting = (props) => { const mapStateToProps = (state) => { const {commonReducer, ojForUserReducer} = state; - const { loading, excuteState, submitLoading } = commonReducer; - const { user_program_identifier, commitRecordDetail } = ojForUserReducer; + const {loading, excuteState, submitLoading } = commonReducer; + const { commitRecordDetail } = ojForUserReducer; return { loading, submitLoading, excuteState, - identifier: user_program_identifier, + // identifier: user_program_identifier, commitRecordDetail // 提交详情 }; }; diff --git a/public/react/src/modules/developer/components/errorResult/index.js b/public/react/src/modules/developer/components/errorResult/index.js new file mode 100644 index 000000000..236a0cb9d --- /dev/null +++ b/public/react/src/modules/developer/components/errorResult/index.js @@ -0,0 +1,64 @@ +/* + * @Description: + * @Author: tangjiang + * @Github: + * @Date: 2019-12-03 15:20:55 + * @LastEditors: tangjiang + * @LastEditTime: 2019-12-03 15:31:15 + */ +import React from 'react'; + +function ErrorResult (props) { + + const { detail } = props; + + const renderError = (detail = {}) => { + const { + status, + error_line, + error_msg, + expected_output, + input, + output, + execute_time, + execute_memory + } = detail; + // 根据状态渲染不同的错误信息 + let result = null; + switch (status) { + case -1: + result = ( +
+

输入: [input]

+

输出: [output]

+

预期: [expected_output]

+
+ ); + break; + case 2: // 评测超时 + return ( +
+

执行超时,限制时限: {`${execute_time}s`}

+
+ ); + break; + case 3: // 创建pod失败 + break; + case 4: // 编译失败 + break; + case 5: // 执行失败 + break; + default: + return result; + } + return result; + } + + return ( + + {renderError(detail)} + + ); +} + +export default ErrorResult; diff --git a/public/react/src/modules/developer/components/errorResult/index.scss b/public/react/src/modules/developer/components/errorResult/index.scss new file mode 100644 index 000000000..e69de29bb diff --git a/public/react/src/modules/developer/components/execResult/index.js b/public/react/src/modules/developer/components/execResult/index.js index c659021ed..5f8526ca4 100644 --- a/public/react/src/modules/developer/components/execResult/index.js +++ b/public/react/src/modules/developer/components/execResult/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-28 08:44:54 * @LastEditors: tangjiang - * @LastEditTime: 2019-11-28 15:14:42 + * @LastEditTime: 2019-12-03 12:38:27 */ import './index.scss'; import React, { useState, useEffect } from 'react'; @@ -15,6 +15,7 @@ const {reviewResult} = CONST; function ExecResult (props) { const { excuteState, excuteDetail } = props; + // console.log('执行状态: ======', excuteState); // 指定渲染初始, 加载中, 加载完成页面内容 const renderInit = () => (
@@ -65,6 +66,7 @@ function ExecResult (props) {

输入: {input}

输出: {output}

+

执行用时: {`${execute_time}s`}

); } else if (state === 4){ @@ -109,6 +111,7 @@ function ExecResult (props) { // 渲染状态变化时渲染相应的内容 useEffect(() => { + // console.log('执行状态====》》》》', excuteState); if ('loading' === excuteState) { setRenderCtx(() => (renderLoading)); } else if ('loaded' === excuteState) { @@ -120,7 +123,7 @@ function ExecResult (props) { // 提交详情变化时 useEffect(() => { - console.log('提交记录详情=====>>>>>', excuteDetail); + // console.log('提交记录详情=====>>>>>', excuteDetail); setCodeResult(excuteDetail); }, [excuteDetail]); diff --git a/public/react/src/modules/developer/components/initTabCtx/index.js b/public/react/src/modules/developer/components/initTabCtx/index.js index c4b989354..221558cdc 100644 --- a/public/react/src/modules/developer/components/initTabCtx/index.js +++ b/public/react/src/modules/developer/components/initTabCtx/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 19:46:14 * @LastEditors: tangjiang - * @LastEditTime: 2019-11-27 23:49:21 + * @LastEditTime: 2019-12-03 09:14:59 */ import './index.scss'; import React, { useState, useEffect, useRef, useImperativeHandle, forwardRef } from 'react'; @@ -28,7 +28,7 @@ function InitTabCtx (props, ref) { useImperativeHandle(ref, () => ({ handleTestCodeFormSubmit: (cb) => { - console.log('父组件调用我啦~~~~~~~~~'); + // console.log('父组件调用我啦~~~~~~~~~'); _handleTestCodeFormSubmit(cb); } })); diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js index 56f30ea2e..989fc07ba 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.js +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 15:02:52 * @LastEditors: tangjiang - * @LastEditTime: 2019-11-28 12:39:39 + * @LastEditTime: 2019-12-03 09:29:54 */ import './index.scss'; import React, { useState, useRef, useEffect } from 'react'; @@ -13,17 +13,18 @@ import { connect } from 'react-redux'; import MonacoEditor from '@monaco-editor/react'; import SettingDrawer from '../../components/monacoSetting'; import CONST from '../../../../constants'; -import actions from '../../../../redux/actions'; +// import actions from '../../../../redux/actions'; const { fontSetting, opacitySetting } = CONST; -const MyMonacoEditor = (props) => { +function MyMonacoEditor (props, ref) { const { language, code, showOrHideControl, - saveUserInputCode + // saveUserInputCode, + onCodeChange } = props; const [showDrawer, setShowDrawer] = useState(false); // 控制配置滑框 const [editCode, setEditCode] = useState(''); @@ -41,6 +42,7 @@ const MyMonacoEditor = (props) => { useEffect(() => { setHeight(showOrHideControl ? 'calc(100% - 382px)' : 'calc(100% - 112px)'); }, [showOrHideControl]); + // 控制侧边栏设置的显示 const handleShowDrawer = () => { setShowDrawer(true); @@ -62,8 +64,9 @@ const MyMonacoEditor = (props) => { // TODO 需要优化 节流 const val = editorRef.current.getValue(); setEditCode(val); + onCodeChange(val); // 值一变化保存当前代码值 - saveUserInputCode(val); + // saveUserInputCode(val); }); } @@ -104,7 +107,7 @@ const MyMonacoEditor = (props) => { ) -} +}; const mapStateToProps = (state) => { const { showOrHideControl } = state.commonReducer; @@ -114,9 +117,10 @@ const mapStateToProps = (state) => { }; const mapDispatchToProps = (dispatch) => ({ - saveUserInputCode: (code) => dispatch(actions.saveUserInputCode(code)), + // saveUserInputCode: (code) => dispatch(actions.saveUserInputCode(code)), }); +// MyMonacoEditor = React.forwardRef(MyMonacoEditor); export default connect( mapStateToProps, mapDispatchToProps diff --git a/public/react/src/modules/developer/newOrEditTask/index.js b/public/react/src/modules/developer/newOrEditTask/index.js index 1c6da31c1..6e1ec7a4a 100644 --- a/public/react/src/modules/developer/newOrEditTask/index.js +++ b/public/react/src/modules/developer/newOrEditTask/index.js @@ -6,10 +6,10 @@ * @Last Modified time: 2019-11-19 23:23:41 */ import './index.scss'; -import React, { useCallback, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import { connect } from 'react-redux'; import SplitPane from 'react-split-pane';// import { Form } from 'antd'; -import { Button, Icon } from 'antd'; +import { Button, Icon, notification } from 'antd'; import { Link } from 'react-router-dom'; import LeftPane from './leftpane'; import RightPane from './rightpane'; @@ -20,15 +20,76 @@ const NewOrEditTask = (props) => { const { publishLoading, handlePublish, + testCases = [], + // ojTestCaseValidate = [], changeSubmitLoadingStatus, changePublishLoadingStatus, + updateTestAndValidate, identifier, } = props; + + const leftRef = useRef(null); + const rightRef = useRef(null); + + const [formDate, setFormData] = useState({}); + + // const isNullOrUndefiendOrZero = (value) => { + // if ([undefined, null, ''].includes(value)) { + // return true; + // } + // return false; + // } // 表单提交 - const handleSubmitForm = (code) => { - props.saveOjFormCode(code); // 保存代码块值 - // TODO - // identifier 存在时 + const handleSubmitForm = () => { + // 调用输入表单验证功能 + + + // let hasErrorForTestCase = false; + // const tempTestCaseValidate = []; + // // 验证测试用例 + // testCases.forEach(tc => { + // const obj = {}; + // if (isNullOrUndefiendOrZero(tc.input)) { + // hasErrorForTestCase = true; + // obj['input'] = { + // validateStatus: 'error', + // errMsg: '输入值不能为空' + // } + // } else { + // obj['input'] = { + // validateStatus: '', + // errMsg: '' + // } + // } + // if (isNullOrUndefiendOrZero(tc.output)) { + // hasErrorForTestCase = true; + // obj['output'] = { + // validateStatus: 'error', + // errMsg: '输出值不能为空' + // } + // } else { + // obj['output'] = { + // validateStatus: '', + // errMsg: '' + // } + // } + // // 更改测试用例值 + // tempTestCaseValidate.push(obj); + // }); + // // 验证代码块 + // if (!formValue || hasErrorForTestCase) { + // // 验证不通过时, 回滚按钮状态 + // changeSubmitLoadingStatus(false); + // changePublishLoadingStatus(false); + // updateTestAndValidate({ // 测试用例 + // testCaseValidate: tempTestCaseValidate + // }); + // return; + // } + // console.log('调用提交接口===========》》》》》》》》》》》》'); + // props.saveOjFormCode(code); // 保存代码块值 + // // TODO + // // identifier 存在时 if (props.identifier) { props.handleUpdateOjForm(props); } else { @@ -65,7 +126,7 @@ const NewOrEditTask = (props) => { 后退 - {props.name || ''} +

{props.name || ''}