From 83679cb3cc6874ae2b9c5ea13bab3f78392dcb67 Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Wed, 4 Dec 2019 15:53:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/developer/DeveloperHome.js | 1 + .../modules/developer/newOrEditTask/index.js | 61 +------------------ .../leftpane/editorTab/AddTestDemo.js | 5 +- .../newOrEditTask/leftpane/editorTab/index.js | 11 ++-- public/react/src/redux/actions/ojForUser.js | 3 +- .../react/src/redux/reducers/ojFormReducer.js | 14 ++--- 6 files changed, 19 insertions(+), 76 deletions(-) diff --git a/public/react/src/modules/developer/DeveloperHome.js b/public/react/src/modules/developer/DeveloperHome.js index b6167d497..d7d3960b2 100644 --- a/public/react/src/modules/developer/DeveloperHome.js +++ b/public/react/src/modules/developer/DeveloperHome.js @@ -374,6 +374,7 @@ class DeveloperHome extends React.PureComponent { // console.log('name has click', record); // 先调用start接口获取返回的 identifier, 再跳转到开启编辑 if (this.isLogin()) { + // console.log(record); this.props.startProgramQuestion(record.identifier, this.props); } } diff --git a/public/react/src/modules/developer/newOrEditTask/index.js b/public/react/src/modules/developer/newOrEditTask/index.js index b06279bc7..6091f66c2 100644 --- a/public/react/src/modules/developer/newOrEditTask/index.js +++ b/public/react/src/modules/developer/newOrEditTask/index.js @@ -28,69 +28,10 @@ const NewOrEditTask = (props) => { identifier, } = props; - // console.log('props =====>>>>', 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; - // } + console.log('props =====>>>>', props); // 表单提交 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 { diff --git a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js index b4b5983f9..279333d1d 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/AddTestDemo.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-21 09:19:38 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-02 19:20:30 + * @LastEditTime: 2019-12-04 15:44:12 */ import './index.scss'; import React, { useState } from 'react'; @@ -29,13 +29,14 @@ const AddTestDemo = (props) => { // 删除操作 const handleDeletePanel = (e) => { // console.log('点击的删除按钮') + e.preventDefault(); + e.stopPropagation(); Modal.confirm({ title: '删除', content: '确定要删除当前测试用例吗?', okText: '确定', cancelText: '取消', onOk() { - console.log('确定删除'); onDeleteTest(testCase); } }) 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 702e78040..6048d773b 100644 --- a/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js +++ b/public/react/src/modules/developer/newOrEditTask/leftpane/editorTab/index.js @@ -4,14 +4,14 @@ * @Github: * @Date: 2019-11-20 10:35:40 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-03 08:41:14 + * @LastEditTime: 2019-12-04 15:49:37 */ import 'quill/dist/quill.core.css'; import 'quill/dist/quill.bubble.css'; import 'quill/dist/quill.snow.css'; import './index.scss'; // import 'katex/dist/katex.css'; -import React, { PureComponent } from 'react'; +import React from 'react'; import { Form, Input, Select, InputNumber, Button } from 'antd'; import { connect } from 'react-redux'; import AddTestDemo from './AddTestDemo'; @@ -43,7 +43,7 @@ const maps = { { title: '私有', key: '0' } ] } -class EditTab extends PureComponent { +class EditTab extends React.Component { constructor (props) { super(props); @@ -88,7 +88,7 @@ class EditTab extends PureComponent { const scrollTop = e.target.scrollTop; const { scrollHeight, offsetTop} = this.state; // 滚动距离 + 元素的高度 大于 offsetTop值时, 添加 fix_top 样式 - console.log(tOffsetTop, tOffsetHeight, scrollTop, scrollHeight, offsetTop); + // console.log(tOffsetTop, tOffsetHeight, scrollTop, scrollHeight, offsetTop); if ((scrollTop + tOffsetHeight > tOffsetTop) && (tOffsetTop >= offsetTop)) { oTarget.className = `test_demo_title fix_top`; } else if ((scrollHeight + scrollTop < offsetTop) && (scrollHeight <= offsetTop)){ @@ -181,8 +181,7 @@ class EditTab extends PureComponent { deleteTestCase(obj); }; const renderTestCase = () => { - console.log(openTestCodeIndex); - return testCases.map((item, i) => { + return this.props.testCases.map((item, i) => { return { payload: identifier }); // 跳转至开启编程 + debugger; props.history.push(`/myproblems/${identifier}`); // Redirect.to } diff --git a/public/react/src/redux/reducers/ojFormReducer.js b/public/react/src/redux/reducers/ojFormReducer.js index bdf67af1b..8b73a28b0 100644 --- a/public/react/src/redux/reducers/ojFormReducer.js +++ b/public/react/src/redux/reducers/ojFormReducer.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-20 16:40:32 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-02 19:22:30 + * @LastEditTime: 2019-12-04 15:36:26 */ import { Base64 } from 'js-base64'; import types from '../actions/actionTypes'; @@ -147,7 +147,7 @@ const ojFormReducer = (state = initialState, action) => { const index = state.testCases.findIndex((item) => item.position === position); if (index > -1) { state.testCases.splice(index, 1); // 删除当前元素 - state.ojTestCaseValidate.splice(index, 1); // 删除测试用例对应的校验 + state.testCasesValidate.splice(index, 1); // 删除测试用例对应的校验 } return { ...state @@ -218,12 +218,12 @@ const ojFormReducer = (state = initialState, action) => { case types.VALIDATE_TEST_CODE_ARRS: return { ...state, - ojTestCaseValidate: action.payload + testCasesValidate: action.payload } case types.TEST_CASE_INPUT_CHANGE: const { input } = action.payload; // 更新验证消息 - const curIOjTestValidate = state.ojTestCaseValidate.map((tc, i) => { + const curIOjTestValidate = state.testCasesValidate.map((tc, i) => { if (i === action.payload.index) { return Object.assign({}, tc, {input}); } @@ -237,13 +237,13 @@ const ojFormReducer = (state = initialState, action) => { }); return { ...state, - ojTestCaseValidate: [...curIOjTestValidate], + testCasesValidate: [...curIOjTestValidate], testCases: [...curITestValues] } case types.TEST_CASE_OUTPUT_CHANGE: const { output } = action.payload; // 更新验证消息 - const curOOjTestValidate = state.ojTestCaseValidate.map((tc, i) => { + const curOOjTestValidate = state.testCasesValidate.map((tc, i) => { if (i === action.payload.index) { return Object.assign({}, tc, {output}); } @@ -257,7 +257,7 @@ const ojFormReducer = (state = initialState, action) => { }); return { ...state, - ojTestCaseValidate: [...curOOjTestValidate], + testCasesValidate: [...curOOjTestValidate], testCases: [...curOTestValues] } case types.UPDATE_TEST_AND_VALIDATE: // 保存或更新测试用例值