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

video_transcode
harry 5 years ago
parent 50b0a907e4
commit 282557ef53

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

@ -72,25 +72,15 @@ const CommitRecord = (props) => {
identifier, identifier,
pages, pages,
commitRecord, commitRecord,
// excuteState,
language, language,
operateType,
commitRecordDetail, commitRecordDetail,
getUserCommitRecord, getUserCommitRecord,
changeRecordPagination changeRecordPagination
} = props; } = props;
const [current, setCurrent] = useState(1); const [current, setCurrent] = useState(pages.page);
// const [pagination, setPagination] = useState(paginationConfig);
// const [tableData, setTableData] = useState([]);
// 复制面板 // 复制面板
let clipboard; let clipboard;
// const [recordDetail, setRecordDetail] = useState({});
// const [renderCtx, setRenderCtx] = useState(() => {
// return function () {
// return '';
// }
// });
// 渲染提交记录详情 // 渲染提交记录详情
const renderRecordDetail = (commitRecordDetail = {}) => { const renderRecordDetail = (commitRecordDetail = {}) => {
const { id, status } = commitRecordDetail; const { id, status } = commitRecordDetail;
@ -131,7 +121,7 @@ const CommitRecord = (props) => {
// 根据id获取用户提交记录 // 根据id获取用户提交记录
useEffect(() => { useEffect(() => {
getUserCommitRecord(identifier); getUserCommitRecord(identifier);
}, []); }, [identifier]);
// 提交记录变化时,同步到表单数据 // 提交记录变化时,同步到表单数据
// useEffect(() => { // useEffect(() => {
// // const len = commitRecord.length; // // const len = commitRecord.length;
@ -174,69 +164,20 @@ const CommitRecord = (props) => {
changeRecordPagination(page); changeRecordPagination(page);
// 调用查询接口 // 调用查询接口
getUserCommitRecord(identifier); getUserCommitRecord(identifier);
// setPagination(Object.assign({}, pagination, { current: page}));
// console.log('======>>>>>>', pagination)
} }
// console.log(commitRecord);
const _style = { const _style = {
display: pages.total > pages.limit ? 'block' : 'none' 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 ( return (
<div className={'commit_record_area'}> <div className={'commit_record_area'}>
{renderRecordDetail(commitRecordDetail)} {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"> <div className="commit_record_table_pagination">
<Table <Table
columns={columns} columns={columns}
rowKey={function (record) { return `key_${record.id}` }} rowKey={function (record) { return `key_${record.id}` }}
dataSource={commitRecord} dataSource={commitRecord}
// pagination={pagination}
// onChange={handleTableChange}
pagination={false} pagination={false}
/> />
<div className="commit_record_pagination" style={_style}> <div className="commit_record_pagination" style={_style}>

@ -133,15 +133,15 @@ export const saveUserCodeForInterval = (identifier, code) => {
* @param {*} inputValue 输入值: 自定义 | 系统返回的 * @param {*} inputValue 输入值: 自定义 | 系统返回的
* @param {*} type 测评类型 debug | submit * @param {*} type 测评类型 debug | submit
*/ */
//原来的方法未能区分从编辑入口进来的情况,这时代码也是更新了的。
export const updateCode = (identifier, inputValue, type) => { export const updateCode = (identifier, inputValue, type) => {
return (dispatch, getState) => { return (dispatch, getState) => {
const { userCode, isUpdateCode } = getState().ojForUserReducer; const { editor_code, isUpdateCode } = getState().ojForUserReducer;
if (isUpdateCode) { if (isUpdateCode) {
fetchUpdateCode(identifier, { fetchUpdateCode(identifier, {
code: Base64.encode(userCode) code: Base64.encode(editor_code)
}).then(res => { }).then(res => {
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现 if (res) {
// TODO 需要优化
if (res.data.status === 401) { if (res.data.status === 401) {
dispatch({ // 改变 loading 值 dispatch({ // 改变 loading 值
type: types.LOADING_STATUS, type: types.LOADING_STATUS,
@ -153,8 +153,8 @@ export const updateCode = (identifier, inputValue, type) => {
type: types.IS_UPDATE_CODE, type: types.IS_UPDATE_CODE,
flag: false flag: false
}); });
// debuggerCode(identifier, inputValue);
dispatch(debuggerCode(identifier, inputValue, type)); dispatch(debuggerCode(identifier, inputValue, type));
}
}); });
} else { } else {
// 没有更新时,直接调用调试接口 // 没有更新时,直接调用调试接口
@ -393,7 +393,6 @@ export const changeUserCodeTab = (key) => {
export const submitUserCode = (identifier, inputValue, type) => { export const submitUserCode = (identifier, inputValue, type) => {
return (dispatch, getState) => { return (dispatch, getState) => {
const { editor_code, isUpdateCode, hack } = getState().ojForUserReducer; const { editor_code, isUpdateCode, hack } = getState().ojForUserReducer;
function userCodeSubmit() { function userCodeSubmit() {
fetchUserCodeSubmit(identifier).then(res => { fetchUserCodeSubmit(identifier).then(res => {
if (res.status === 200) { if (res.status === 200) {

@ -151,7 +151,8 @@ const ojForUserReducer = (state = initialState, action) => {
case types.SAVE_EDITOR_CODE: case types.SAVE_EDITOR_CODE:
return { return {
...state, ...state,
editor_code: action.payload editor_code: action.payload,
isUpdateCode: true
} }
case types.SAVE_USE_TEST_CASE_VALUE: case types.SAVE_USE_TEST_CASE_VALUE:
return { return {

Loading…
Cancel
Save