fix 提交代码与编辑代码不一致情况

video_transcode
harry 5 years ago
parent f2282ece47
commit 1b236352e9

@ -8,7 +8,7 @@
*/
import './index.scss';
import React, { useState, useRef, useEffect } from 'react';
import { Tabs, Button, Icon, notification } from 'antd';
import { Tabs, Button, Icon, notification } from 'antd';
import { connect } from 'react-redux';
import InitTabCtx from '../initTabCtx';
import ExecResult from '../execResult';
@ -18,8 +18,7 @@ const { TabPane } = Tabs;
const ControlSetting = (props) => {
const {
hack,
userCode,
editor_code,
inputValue,
loading,
submitLoading,
@ -59,7 +58,7 @@ const ControlSetting = (props) => {
// 调试代码
const handleTestCode = (e) => {
if (!userCode) {
if (!editor_code) {
notification.warning({
message: '提示',
description: '代码块内容不能为空'
@ -78,7 +77,7 @@ const ControlSetting = (props) => {
// 提交
const handleSubmit = (e) => {
e.preventDefault();
if (!userCode) {
if (!editor_code) {
notification.warning({
message: '提示',
description: '代码块内容不能为空'
@ -108,7 +107,7 @@ const ControlSetting = (props) => {
style={{ top: showTextResult ? '-267px' : 0 }}
>
{/* <i className="iconfont icon-xiajiantou icon"></i> */}
<Icon type={ showTextResult ? "down" : "up" } />
<Icon type={showTextResult ? "down" : "up"} />
</div>
<Tabs
className={classNames}
@ -134,10 +133,8 @@ const ControlSetting = (props) => {
<Button
type="link"
style={{ color: '#fff' }}
// onClick={handleShowControl}
>
控制台
{/* <Icon type={ showTextResult ? "down" : "up" } /> */}
控制台
</Button>
<p>
<Button ghost
@ -150,9 +147,8 @@ const ControlSetting = (props) => {
loading={submitLoading}
type="primary"
onClick={handleSubmit}
>
{/* {props.identifier ? '更新' : '提交'} */}
提交
>
提交
</Button>
</p>
</div>
@ -161,12 +157,12 @@ const ControlSetting = (props) => {
}
const mapStateToProps = (state) => {
const {commonReducer, ojForUserReducer} = state;
const {loading, excuteState, submitLoading, showOrHideControl } = commonReducer;
const { commitTestRecordDetail, hack, userCode } = ojForUserReducer;
const { commonReducer, ojForUserReducer } = state;
const { loading, excuteState, submitLoading, showOrHideControl } = commonReducer;
const { commitTestRecordDetail, hack, editor_code } = ojForUserReducer;
return {
hack,
userCode,
editor_code,
loading,
submitLoading,
excuteState,

@ -108,18 +108,12 @@ function StudentStudy(props) {
return (
<div className={'student_study_warp'}>
<div className={'student_study_header'}>
{/* <div className={'avator_nicker'}>
<img alt="用户头像" className={'student_img'} src={getImageUrl((mygetHelmetapi && mygetHelmetapi.nav_logo_url) || 'images/educoder/headNavLogo.png?1526520218')} />
<span className={'student_nicker'}>
{(mygetHelmetapi &&mygetHelmetapi.name) || ''}
</span>
</div> */}
<UserInfo userInfo={userInfo} />
<div className={'study_name'}>
<span>{hack.name}</span>
</div>
<div className={'study_quit'}>
{/* to={`/problems/${_hack_id}/edit`} */}
<span
style={{ display: userInfo.hack_manager ? 'inline-block' : 'none' }}
onClick={() => handleClickEditor(hack.identifier)}
@ -127,16 +121,9 @@ function StudentStudy(props) {
>
<Icon type="form" className="quit-icon" /> 编辑
</span>
{/* to="/problems" */}
<span onClick={handleClickQuit} className="quit-btn">
<Icon type="poweroff" className="quit-icon" /> 退出
</span>
{/* <Button type="link" icon="form" className='quit-btn'>
<Link to="/problems">编辑</Link>
</Button>
<Button type="link" icon="poweroff" className='quit-btn'>
<Link to="/problems">退出</Link>
</Button> */}
</div>
</div>
<div className="split-pane-area">

@ -122,9 +122,6 @@ const RightPane = (props) => {
onClick={handleClickNote}
></span>
{/* <div className="student_notes">
<TextArea rows={5} />
</div> */}
<div className={noteClazz}>
<Form>
<FormItem>

@ -392,7 +392,7 @@ export const changeUserCodeTab = (key) => {
*/
export const submitUserCode = (identifier, inputValue, type) => {
return (dispatch, getState) => {
const { userCode, isUpdateCode, hack } = getState().ojForUserReducer;
const { editor_code, isUpdateCode, hack } = getState().ojForUserReducer;
function userCodeSubmit() {
fetchUserCodeSubmit(identifier).then(res => {
@ -416,7 +416,7 @@ export const submitUserCode = (identifier, inputValue, type) => {
}
if (isUpdateCode) {
fetchUpdateCode(identifier, {
code: Base64.encode(userCode)
code: Base64.encode(editor_code)
}).then(res => {
// 是否更新了代码, 目的是当代码没有更新时不调用更新代码接口,目录没有实现
if (res.data.status === 401) {

Loading…
Cancel
Save