|
|
|
@ -133,33 +133,29 @@ export const saveUserCodeForInterval = (identifier, code) => {
|
|
|
|
|
* @param {*} inputValue 输入值: 自定义 | 系统返回的
|
|
|
|
|
* @param {*} type 测评类型 debug | submit
|
|
|
|
|
*/
|
|
|
|
|
//原来的方法未能区分从编辑入口进来的情况,这时代码也是更新了的。
|
|
|
|
|
//原来的方法未能区分从编辑入口进来的情况,这时代码也是更新了的。以及ctrl+z undo未能触发chnage事件 monaco-editor的bug。 这里去除isUpdateCode
|
|
|
|
|
export const updateCode = (identifier, inputValue, type) => {
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
const { editor_code, isUpdateCode } = getState().ojForUserReducer;
|
|
|
|
|
if (isUpdateCode) {
|
|
|
|
|
fetchUpdateCode(identifier, {
|
|
|
|
|
code: Base64.encode(editor_code)
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res) {
|
|
|
|
|
if (res.data.status === 401) {
|
|
|
|
|
dispatch({ // 改变 loading 值
|
|
|
|
|
type: types.LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.IS_UPDATE_CODE,
|
|
|
|
|
flag: false
|
|
|
|
|
const { editor_code } = getState().ojForUserReducer;
|
|
|
|
|
fetchUpdateCode(identifier, {
|
|
|
|
|
code: Base64.encode(editor_code)
|
|
|
|
|
}).then(res => {
|
|
|
|
|
if (res) {
|
|
|
|
|
if (res.data.status === 401) {
|
|
|
|
|
dispatch({ // 改变 loading 值
|
|
|
|
|
type: types.LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
dispatch(debuggerCode(identifier, inputValue, type));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// 没有更新时,直接调用调试接口
|
|
|
|
|
dispatch(debuggerCode(identifier, inputValue, type));
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.IS_UPDATE_CODE,
|
|
|
|
|
flag: false
|
|
|
|
|
});
|
|
|
|
|
dispatch(debuggerCode(identifier, inputValue, type));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -370,14 +366,6 @@ export const saveUserInputCode = (code) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 监听是否更新代码块内容
|
|
|
|
|
// export const isUpdateCodeCtx = (flag) => {
|
|
|
|
|
// return {
|
|
|
|
|
// type: types.IS_UPDATE_CODE,
|
|
|
|
|
// payload: flag
|
|
|
|
|
// };
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// 改变学员测评 tab 值
|
|
|
|
|
export const changeUserCodeTab = (key) => {
|
|
|
|
|
return {
|
|
|
|
@ -392,7 +380,7 @@ export const changeUserCodeTab = (key) => {
|
|
|
|
|
*/
|
|
|
|
|
export const submitUserCode = (identifier, inputValue, type) => {
|
|
|
|
|
return (dispatch, getState) => {
|
|
|
|
|
const { editor_code, isUpdateCode, hack } = getState().ojForUserReducer;
|
|
|
|
|
const { editor_code, hack } = getState().ojForUserReducer;
|
|
|
|
|
function userCodeSubmit() {
|
|
|
|
|
fetchUserCodeSubmit(identifier).then(res => {
|
|
|
|
|
if (res.status === 200) {
|
|
|
|
@ -413,32 +401,29 @@ export const submitUserCode = (identifier, inputValue, type) => {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (isUpdateCode) {
|
|
|
|
|
fetchUpdateCode(identifier, {
|
|
|
|
|
code: Base64.encode(editor_code)
|
|
|
|
|
}).then(res => {
|
|
|
|
|
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
|
|
|
|
|
if (res.data.status === 401) {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.SUBMIT_LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.IS_UPDATE_CODE,
|
|
|
|
|
flag: false
|
|
|
|
|
});
|
|
|
|
|
userCodeSubmit();
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
fetchUpdateCode(identifier, {
|
|
|
|
|
code: Base64.encode(editor_code)
|
|
|
|
|
}).then(res => {
|
|
|
|
|
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
|
|
|
|
|
if (res.data.status === 401) {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.SUBMIT_LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
return;
|
|
|
|
|
};
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.IS_UPDATE_CODE,
|
|
|
|
|
flag: false
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
userCodeSubmit();
|
|
|
|
|
}
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
dispatch({
|
|
|
|
|
type: types.SUBMIT_LOADING_STATUS,
|
|
|
|
|
payload: false
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|