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';
@ -17,9 +17,8 @@ import actions from '../../../../redux/actions';
const { TabPane } = Tabs;
const ControlSetting = (props) => {
const {
hack,
userCode,
const {
editor_code,
inputValue,
loading,
submitLoading,
@ -59,7 +58,7 @@ const ControlSetting = (props) => {
// 调试代码
const handleTestCode = (e) => {
if (!userCode) {
if (!editor_code) {
notification.warning({
message: '提示',
description: '代码块内容不能为空'
@ -74,11 +73,11 @@ const ControlSetting = (props) => {
setDefaultActiveKey('2');
});
}
// 提交
const handleSubmit = (e) => {
e.preventDefault();
if (!userCode) {
if (!editor_code) {
notification.warning({
message: '提示',
description: '代码块内容不能为空'
@ -103,56 +102,53 @@ const ControlSetting = (props) => {
return (
<div className="pane_control_area">
<div
className="pane_control_collapse"
className="pane_control_collapse"
onClick={handleShowControl}
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}
activeKey={defaultActiveKey}
activeKey={defaultActiveKey}
tabBarStyle={{ backgroundColor: 'rgba(18,28,36,1)', color: '#fff' }}
onChange={handleTabChange}
>
<TabPane tab={'自定义测试用例'} key={'1'} style={{ height: '280px', overflowY: 'auto' }}>
<InitTabCtx
inputValue={inputValue}
<InitTabCtx
inputValue={inputValue}
wrappedComponentRef={(form) => formRef.current = form}
onDebuggerCode={handleDebuggerCode}
/>
</TabPane>
<TabPane tab={'代码执行结果'} key={'2'} style={{ height: '280px', overflowY: 'auto' }}>
<ExecResult
<ExecResult
excuteState={excuteState}
excuteDetail={commitTestRecordDetail}
/>
</TabPane>
</Tabs>
<div className="pane_control_opts">
<Button
type="link"
style={{ color: '#fff' }}
// onClick={handleShowControl}
<Button
type="link"
style={{ color: '#fff' }}
>
控制台
{/* <Icon type={ showTextResult ? "down" : "up" } /> */}
控制台
</Button>
<p>
<Button ghost
<Button ghost
loading={loading}
style={{ marginRight: '10px', color: '#28BD8B', borderColor: '#28BD8B' }}
style={{ marginRight: '10px', color: '#28BD8B', borderColor: '#28BD8B' }}
onClick={handleTestCode}
disabled={!identifier}
>调试代码</Button>
<Button
<Button
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