|
|
|
@ -4,7 +4,7 @@
|
|
|
|
|
* @Github:
|
|
|
|
|
* @Date: 2019-11-27 13:42:11
|
|
|
|
|
* @LastEditors: tangjiang
|
|
|
|
|
* @LastEditTime: 2019-12-04 15:50:54
|
|
|
|
|
* @LastEditTime: 2019-12-05 10:44:17
|
|
|
|
|
*/
|
|
|
|
|
import types from "./actionTypes";
|
|
|
|
|
import { Base64 } from 'js-base64';
|
|
|
|
@ -32,9 +32,18 @@ export const startProgramQuestion = (id, props) => {
|
|
|
|
|
payload: identifier
|
|
|
|
|
});
|
|
|
|
|
// 跳转至开启编程
|
|
|
|
|
debugger;
|
|
|
|
|
props.history.push(`/myproblems/${identifier}`);
|
|
|
|
|
// Redirect.to
|
|
|
|
|
if (identifier) {
|
|
|
|
|
// let data = Object.assign({}, props);
|
|
|
|
|
// const path = {
|
|
|
|
|
// pathname: `/myproblems/${identifier}`,
|
|
|
|
|
// state: data
|
|
|
|
|
// }
|
|
|
|
|
// console.log(path);
|
|
|
|
|
// props.history.push(`/myproblems/${identifier}`);
|
|
|
|
|
props.history.push({
|
|
|
|
|
pathname: `/myproblems/${identifier}`,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
@ -55,6 +64,7 @@ export const getUserProgramDetail = (identifier, type) => {
|
|
|
|
|
fetchUserProgramDetail(identifier).then(res => {
|
|
|
|
|
const { status, data = {} } = res;
|
|
|
|
|
if (status === 200) {
|
|
|
|
|
if (data.status === 401) return;
|
|
|
|
|
if (!type) {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.USER_PROGRAM_DETAIL,
|
|
|
|
@ -86,6 +96,13 @@ export const updateCode = (identifier, inputValue, type) => {
|
|
|
|
|
}).then(res => {
|
|
|
|
|
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
|
|
|
|
|
// TODO 需要优化
|
|
|
|
|
if (res.data.status === 401) {
|
|
|
|
|
dispatch({ // 改变 loading 值
|
|
|
|
|
type: types.LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.IS_UPDATE_CODE,
|
|
|
|
|
flag: false
|
|
|
|
@ -118,7 +135,7 @@ export const debuggerCode = (identifier,value, type) => {
|
|
|
|
|
payload: 'loading'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fetchDebuggerCode(identifier, value).then(res => {
|
|
|
|
|
// console.log('调用调试代码成功并返回结果: ', res);
|
|
|
|
|
const { status } = res;
|
|
|
|
@ -132,7 +149,13 @@ export const debuggerCode = (identifier,value, type) => {
|
|
|
|
|
* @param {*} count 执行次数
|
|
|
|
|
* @param {*} timer 定时器
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
if (res.data.status === 401) {
|
|
|
|
|
dispatch({ // 改变 loading 值
|
|
|
|
|
type: types.LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
function getCodeSubmit (intervalTime, finalTime, count, timer){
|
|
|
|
|
const excuteTime = (count++) * intervalTime; // 当前执行时间
|
|
|
|
|
fetchCodeSubmit(identifier, { mode: type }).then(res => {
|
|
|
|
@ -241,6 +264,10 @@ export const getUserCommitRecordDetail = (identifier) => {
|
|
|
|
|
return (dispatch) => {
|
|
|
|
|
fetchUserCommitRecordDetail(identifier).then(res => {
|
|
|
|
|
console.log('提交记录详情======》》》》', res);
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.GET_COMMIT_RECORD_DETAIL_BY_ID,
|
|
|
|
|
payload: res.data
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -280,6 +307,13 @@ export const submitUserCode = (identifier, inputValue, type) => {
|
|
|
|
|
fetchUserCodeSubmit(identifier).then(res => {
|
|
|
|
|
// console.log('用户提交代码成功======》》》》》', res);
|
|
|
|
|
if (res.status === 200) {
|
|
|
|
|
if (res.data.status === 401) {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.SUBMIT_LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
dispatch(debuggerCode(identifier, inputValue, type || 'submit'));
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
@ -295,6 +329,13 @@ export const submitUserCode = (identifier, inputValue, type) => {
|
|
|
|
|
}).then(res => {
|
|
|
|
|
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
|
|
|
|
|
// TODO 需要优化
|
|
|
|
|
if (res.data.status === 401) {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.SUBMIT_LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.IS_UPDATE_CODE,
|
|
|
|
|
flag: false
|
|
|
|
@ -312,10 +353,19 @@ export const submitUserCode = (identifier, inputValue, type) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 恢复初始代码
|
|
|
|
|
export const restoreInitialCode = (identifier) => {
|
|
|
|
|
return (dispatch) => {
|
|
|
|
|
fetchRestoreInitialCode(identifier).then(res => {
|
|
|
|
|
if (res.data.status === 401) return;
|
|
|
|
|
console.log('恢复初始代码====》》》》', res);
|
|
|
|
|
const {status, data} = res;
|
|
|
|
|
if (status === 200) {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.RESTORE_INITIAL_CODE,
|
|
|
|
|
payload: data.code
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|