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

video_transcode
harry 5 years ago
parent f2282ece47
commit 1b236352e9

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

@ -108,18 +108,12 @@ function StudentStudy(props) {
return ( return (
<div className={'student_study_warp'}> <div className={'student_study_warp'}>
<div className={'student_study_header'}> <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} /> <UserInfo userInfo={userInfo} />
<div className={'study_name'}> <div className={'study_name'}>
<span>{hack.name}</span> <span>{hack.name}</span>
</div> </div>
<div className={'study_quit'}> <div className={'study_quit'}>
{/* to={`/problems/${_hack_id}/edit`} */}
<span <span
style={{ display: userInfo.hack_manager ? 'inline-block' : 'none' }} style={{ display: userInfo.hack_manager ? 'inline-block' : 'none' }}
onClick={() => handleClickEditor(hack.identifier)} onClick={() => handleClickEditor(hack.identifier)}
@ -127,16 +121,9 @@ function StudentStudy(props) {
> >
<Icon type="form" className="quit-icon" /> 编辑 <Icon type="form" className="quit-icon" /> 编辑
</span> </span>
{/* to="/problems" */}
<span onClick={handleClickQuit} className="quit-btn"> <span onClick={handleClickQuit} className="quit-btn">
<Icon type="poweroff" className="quit-icon" /> 退出 <Icon type="poweroff" className="quit-icon" /> 退出
</span> </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> </div>
<div className="split-pane-area"> <div className="split-pane-area">

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

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

Loading…
Cancel
Save