优化按钮状态

dev_forge
tangjiang 5 years ago
parent 5725837d15
commit 8686a514a1

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 09:49:33 * @Date: 2019-11-27 09:49:33
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-11-28 19:54:56 * @LastEditTime: 2019-11-29 12:06:01
*/ */
import './index.scss'; import './index.scss';
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
@ -92,7 +92,7 @@ const CommitRecord = (props) => {
const classes = status === 0 ? 'record_result_suc' : 'record_result_err'; const classes = status === 0 ? 'record_result_suc' : 'record_result_err';
return ( return (
<React.Fragment> <React.Fragment>
<div className={'record_header'}> {/* <div className={'record_header'}>
<span className={'record_result'}> <span className={'record_result'}>
执行结果: <span className={classes}>{reviewResult[status]}</span> 执行结果: <span className={classes}>{reviewResult[status]}</span>
</span> </span>
@ -102,7 +102,7 @@ const CommitRecord = (props) => {
<span className={'show_detail'}> <span className={'show_detail'}>
显示详情 <Icon type="right" className={'icon_style'}/> 显示详情 <Icon type="right" className={'icon_style'}/>
</span> </span>
</div> </div> */}
{/* <div className={'record_error_info'}>错误代码</div> */} {/* <div className={'record_error_info'}>错误代码</div> */}
</React.Fragment> </React.Fragment>
); );

@ -4,7 +4,7 @@
* @Github: * @Github:
* @Date: 2019-11-27 13:42:11 * @Date: 2019-11-27 13:42:11
* @LastEditors: tangjiang * @LastEditors: tangjiang
* @LastEditTime: 2019-11-29 11:11:13 * @LastEditTime: 2019-11-29 12:03:51
*/ */
import types from "./actionTypes"; import types from "./actionTypes";
import { Base64 } from 'js-base64'; import { Base64 } from 'js-base64';
@ -90,7 +90,7 @@ export const debuggerCode = (identifier,value, type) => {
} }
fetchDebuggerCode(identifier, value).then(res => { fetchDebuggerCode(identifier, value).then(res => {
console.log('调用调试代码成功并返回结果: ', res); // console.log('调用调试代码成功并返回结果: ', res);
const { status } = res; const { status } = res;
if (status === 200) { if (status === 200) {
// 调试代码成功后,调用轮循接口, 注意: 代码执行的时间要小于设置的时间限制 // 调试代码成功后,调用轮循接口, 注意: 代码执行的时间要小于设置的时间限制
@ -141,6 +141,12 @@ export const debuggerCode = (identifier,value, type) => {
type: types.CHANGE_USER_CODE_TAB, type: types.CHANGE_USER_CODE_TAB,
payload: 'record' payload: 'record'
}); });
// 将按钮状态回滚
dispatch({
type: types.SUBMIT_LOADING_STATUS,
payload: false
});
// 重新调用一下提交记录接口 // 重新调用一下提交记录接口
dispatch(getUserCommitRecord(identifier)); dispatch(getUserCommitRecord(identifier));
} }
@ -153,6 +159,15 @@ export const debuggerCode = (identifier,value, type) => {
getCodeSubmit(intervalTime, time_limit, count++, timer); getCodeSubmit(intervalTime, time_limit, count++, timer);
}, intervalTime); }, intervalTime);
} }
}).catch(() => {
dispatch({
type: types.TEST_CODE_STATUS,
payload: ''
});
dispatch({
type: types.LOADING_STATUS,
payload: false
});
}); });
} }
} }
@ -222,10 +237,20 @@ export const submitUserCode = (identifier, inputValue, type) => {
flag: false flag: false
}); });
fetchUserCodeSubmit(identifier).then(res => { fetchUserCodeSubmit(identifier).then(res => {
console.log('用户提交代码成功======》》》》》', res); // console.log('用户提交代码成功======》》》》》', res);
if (res.status === 200) { if (res.status === 200) {
dispatch(debuggerCode(identifier, inputValue, type || 'submit')); dispatch(debuggerCode(identifier, inputValue, type || 'submit'));
} }
}).catch(() => {
dispatch({
type: types.SUBMIT_LOADING_STATUS,
payload: false
});
});
}).catch(() => {
dispatch({
type: types.SUBMIT_LOADING_STATUS,
payload: false
}) })
}); });
} }

Loading…
Cancel
Save