diff --git a/public/react/src/modules/developer/components/controlSetting/index.js b/public/react/src/modules/developer/components/controlSetting/index.js index 41a28ba25..f179953d1 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.js +++ b/public/react/src/modules/developer/components/controlSetting/index.js @@ -18,12 +18,12 @@ const { TabPane } = Tabs; const ControlSetting = (props) => { const { - editor_code, inputValue, loading, submitLoading, identifier, excuteState, + editor_code, // showOrHideControl, commitTestRecordDetail, changeLoadingState, diff --git a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js index 07ecdf7f3..917cbfae4 100644 --- a/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js +++ b/public/react/src/modules/developer/studentStudy/leftpane/commitRecord/index.js @@ -19,7 +19,7 @@ import ErrorResult from '../../../components/errorResult'; const numberal = require('numeral'); -const {reviewResult} = CONST; +const { reviewResult } = CONST; // 表格列 const columns = [ { @@ -35,7 +35,7 @@ const columns = [ dataIndex: 'status', render: (value, record) => ( - {reviewResult[value]} + {reviewResult[value]} ) }, @@ -72,28 +72,18 @@ const CommitRecord = (props) => { identifier, pages, commitRecord, - // excuteState, language, - operateType, commitRecordDetail, getUserCommitRecord, changeRecordPagination } = props; - const [current, setCurrent] = useState(1); - // const [pagination, setPagination] = useState(paginationConfig); - // const [tableData, setTableData] = useState([]); + const [current, setCurrent] = useState(pages.page); // 复制面板 let clipboard; - // const [recordDetail, setRecordDetail] = useState({}); - // const [renderCtx, setRenderCtx] = useState(() => { - // return function () { - // return ''; - // } - // }); // 渲染提交记录详情 const renderRecordDetail = (commitRecordDetail = {}) => { - const {id, status} = commitRecordDetail; + const { id, status } = commitRecordDetail; if (Object.keys(commitRecordDetail).length > 0) { // console.log('当前状态====》》》', status); const classes = status === 0 ? 'record_result_suc' : 'record_result_err'; @@ -105,22 +95,22 @@ const CommitRecord = (props) => {

执行结果: {reviewResult[status]}

-

- 复制错误信息 + 复制错误信息

- 显示详情 + 显示详情

- +
); @@ -131,7 +121,7 @@ const CommitRecord = (props) => { // 根据id获取用户提交记录 useEffect(() => { getUserCommitRecord(identifier); - }, []); + }, [identifier]); // 提交记录变化时,同步到表单数据 // useEffect(() => { // // const len = commitRecord.length; @@ -149,9 +139,9 @@ const CommitRecord = (props) => { // 复制功能 let count = 0; // useEffect(() => { - + // }, []); - + const clickCopyErrInfo = () => { count = 0; if (!clipboard) { @@ -174,76 +164,27 @@ const CommitRecord = (props) => { changeRecordPagination(page); // 调用查询接口 getUserCommitRecord(identifier); - // setPagination(Object.assign({}, pagination, { current: page})); - // console.log('======>>>>>>', pagination) } - // console.log(commitRecord); const _style = { display: pages.total > pages.limit ? 'block' : 'none' }; - const {status, id} = commitRecordDetail || {}; - const classes = status === 0 ? 'record_result_suc' : 'record_result_err'; - const showErrorCode = status !== 0 ? `ecord_error_info show_error_code` : `ecord_error_info`; - const showErrorCopy = status !== 0 ? `copy_error show_error_copy` : `copy_error`; - - // if (!clipboard) { - // console.log('==========>>>>>>>', 11111111111); - // clipboard = new ClipboardJS('#copyError'); - // } - // clipboard.on('success', (e) => { - // e.clearSelection(); - // // if (count > 0) return; - // // count++; - // message.success('复制成功'); - // setTimeout(() => { - // message.destroy(); - // }, 3000); - // }); - - // return () => { - // clipboard = null; - // } - return (
{renderRecordDetail(commitRecordDetail)} - {/*
-

- 执行结果: {reviewResult[status]} -

-

- - 复制错误信息 - -

-

- - 显示详情 - -

-
-
- -
*/}
-
- diff --git a/public/react/src/redux/actions/ojForUser.js b/public/react/src/redux/actions/ojForUser.js index 85b384950..b53498e42 100644 --- a/public/react/src/redux/actions/ojForUser.js +++ b/public/react/src/redux/actions/ojForUser.js @@ -133,28 +133,28 @@ export const saveUserCodeForInterval = (identifier, code) => { * @param {*} inputValue 输入值: 自定义 | 系统返回的 * @param {*} type 测评类型 debug | submit */ +//原来的方法未能区分从编辑入口进来的情况,这时代码也是更新了的。 export const updateCode = (identifier, inputValue, type) => { return (dispatch, getState) => { - const { userCode, isUpdateCode } = getState().ojForUserReducer; + const { editor_code, isUpdateCode } = getState().ojForUserReducer; if (isUpdateCode) { fetchUpdateCode(identifier, { - code: Base64.encode(userCode) + code: Base64.encode(editor_code) }).then(res => { - // 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现 - // TODO 需要优化 - if (res.data.status === 401) { - dispatch({ // 改变 loading 值 - type: types.LOADING_STATUS, - payload: false + if (res) { + if (res.data.status === 401) { + dispatch({ // 改变 loading 值 + type: types.LOADING_STATUS, + payload: false + }); + return; + }; + dispatch({ + type: types.IS_UPDATE_CODE, + flag: false }); - return; - }; - dispatch({ - type: types.IS_UPDATE_CODE, - flag: false - }); - // debuggerCode(identifier, inputValue); - dispatch(debuggerCode(identifier, inputValue, type)); + dispatch(debuggerCode(identifier, inputValue, type)); + } }); } else { // 没有更新时,直接调用调试接口 @@ -393,7 +393,6 @@ export const changeUserCodeTab = (key) => { export const submitUserCode = (identifier, inputValue, type) => { return (dispatch, getState) => { const { editor_code, isUpdateCode, hack } = getState().ojForUserReducer; - function userCodeSubmit() { fetchUserCodeSubmit(identifier).then(res => { if (res.status === 200) { diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js index 768d1f6ef..d20656513 100644 --- a/public/react/src/redux/reducers/ojForUserReducer.js +++ b/public/react/src/redux/reducers/ojForUserReducer.js @@ -151,7 +151,8 @@ const ojForUserReducer = (state = initialState, action) => { case types.SAVE_EDITOR_CODE: return { ...state, - editor_code: action.payload + editor_code: action.payload, + isUpdateCode: true } case types.SAVE_USE_TEST_CASE_VALUE: return {