fix 从编辑入口代码未更新的bug

video_transcode
harry 5 years ago
parent 50b0a907e4
commit 282557ef53

@ -18,12 +18,12 @@ const { TabPane } = Tabs;
const ControlSetting = (props) => {
const {
editor_code,
inputValue,
loading,
submitLoading,
identifier,
excuteState,
editor_code,
// showOrHideControl,
commitTestRecordDetail,
changeLoadingState,

@ -72,25 +72,15 @@ 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;
@ -131,7 +121,7 @@ const CommitRecord = (props) => {
// 根据id获取用户提交记录
useEffect(() => {
getUserCommitRecord(identifier);
}, []);
}, [identifier]);
// 提交记录变化时,同步到表单数据
// useEffect(() => {
// // const len = commitRecord.length;
@ -174,69 +164,20 @@ 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 (
<div className={'commit_record_area'}>
{renderRecordDetail(commitRecordDetail)}
{/* <div className={'record_header'}>
<p className={'record_result'}>
执行结果: <span className={classes}>{reviewResult[status]}</span>
</p>
<p
id="copyError"
onClick={clickCopyErrInfo}
className={showErrorCopy} data-clipboard-target="#errcode">
<span>
复制错误信息 <Icon type="copy" className={'icon_style'}/>
</span>
</p>
<p className={'show_detail'} style={{ visibility: id ? 'visible' : 'hidden' }}>
<Link to={`/myproblems/record_detail/${id}`}>
显示详情 <Icon type="right" className={'icon_style'}/>
</Link>
</p>
</div>
<div id="errcode" className={showErrorCode}>
<ErrorResult detail={commitRecordDetail} language={language}/>
</div> */}
<div className="commit_record_table_pagination">
<Table
columns={columns}
rowKey={function (record) { return `key_${record.id}` }}
dataSource={commitRecord}
// pagination={pagination}
// onChange={handleTableChange}
pagination={false}
/>
<div className="commit_record_pagination" style={_style}>

@ -133,15 +133,15 @@ 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) {
if (res.data.status === 401) {
dispatch({ // 改变 loading 值
type: types.LOADING_STATUS,
@ -153,8 +153,8 @@ export const updateCode = (identifier, inputValue, type) => {
type: types.IS_UPDATE_CODE,
flag: false
});
// debuggerCode(identifier, inputValue);
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) {

@ -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 {

Loading…
Cancel
Save