From b7db555654fa0f7122c23e950c4396ca0e90cac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 19 Dec 2019 20:08:59 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tpm/shixunchild/Challenges/Challenges.js | 23 +++++++++-- .../Challenges/Challengesjupyter.js | 39 ++++++++++++++----- .../Collaborators/Collaborators.js | 2 +- 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js index e7b7ef261..0480c208a 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challenges.js @@ -53,6 +53,13 @@ class Challenges extends Component { ChallengesDataList: response.data, sumidtype: false, }); + + if(response.data.description=== ""||response.data.description===null||response.data.description===undefined){ + this.setState({ + isopentitletype:"Less", + }) + } + } } }).catch((error) => { @@ -72,7 +79,7 @@ class Challenges extends Component { let box=document.getElementById("shixunchallengesid"); if(box){ boxoffsetHeigh=box.offsetHeight - if(boxoffsetHeigh<260){ + if(boxoffsetHeigh<300){ this.setState({ isopentitletype:"Less", boxoffsetHeigh:boxoffsetHeigh @@ -338,6 +345,7 @@ class Challenges extends Component { } let id = this.props.match.params.shixunId; const antIcon = ; + return ( {AccountProfiletype===true? -

+ {ChallengesDataList === undefined || ChallengesDataList&&ChallengesDataList.description=== ""||ChallengesDataList&&ChallengesDataList.description===null||ChallengesDataList&&ChallengesDataList.description===undefined? +

+ {this.props.identity < 5?:} +

暂时还没有相关数据哦!

+
+ :

{ChallengesDataList === undefined ? "" :ChallengesDataList&&ChallengesDataList.description===null?"":

} -

+

} diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js index fcdbed408..c8cbc2fbc 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; import { Link } from "react-router-dom"; -import { markdownToHTML, configShareForCustom} from 'educoder' +import { markdownToHTML, configShareForCustom,getImageUrl} from 'educoder' import { Divider, Tooltip } from 'antd'; import LoadingSpin from '../../../../common/LoadingSpin'; import 'antd/lib/pagination/style/index.css'; @@ -23,7 +23,8 @@ class Challengesjupyter extends Component { booljupyterurls:false, loading:false, boxoffsetHeigh:0, - opentitletype:true + opentitletype:true, + isopentitletype:"Less", } } @@ -41,6 +42,11 @@ class Challengesjupyter extends Component { ChallengesDataList: response.data, sumidtype: false, }); + if(response.data.description=== ""||response.data.description===null||response.data.description===undefined){ + this.setState({ + isopentitletype:"Less", + }) + } } } }).catch((error) => { @@ -55,13 +61,15 @@ class Challengesjupyter extends Component { let box=document.getElementById("shixunchallengesid"); if(box){ boxoffsetHeigh=box.offsetHeight - if(boxoffsetHeigh<260){ + if(boxoffsetHeigh<300){ this.setState({ - opentitletype:false, + isopentitletype:"Less", boxoffsetHeigh:boxoffsetHeigh }) }else{ this.setState({ + isopentitletype:"greater", + opentitletype:true, boxoffsetHeigh:boxoffsetHeigh }) } @@ -229,7 +237,7 @@ class Challengesjupyter extends Component { { ` #shixunchallengesid{ - max-height: 260px; + max-height: 300px; overflow: hidden; } ` @@ -239,9 +247,22 @@ class Challengesjupyter extends Component {

- {ChallengesDataList === undefined ? "" :ChallengesDataList&&ChallengesDataList.description===null?"": -

- } + {/*{ChallengesDataList === undefined ? "" :ChallengesDataList&&ChallengesDataList.description===null?"":*/} + {/*
*/} + {/*}*/} + + {ChallengesDataList === undefined || ChallengesDataList&&ChallengesDataList.description=== ""||ChallengesDataList&&ChallengesDataList.description===null||ChallengesDataList&&ChallengesDataList.description===undefined? +
+ {this.props.identity < 5?:} +

暂时还没有相关数据哦!

+
+ :

+ {ChallengesDataList === undefined ? "" :ChallengesDataList&&ChallengesDataList.description===null?"": +

+ } +

}

{ booljupyterurls===true? @@ -259,7 +280,7 @@ class Challengesjupyter extends Component { }
- {this.state.opentitletype===true?this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> + {this.state.isopentitletype==="Less"?"":this.state.opentitletype===true?this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> 阅读全文 :this.opentitle()} className={"pointer Breadcrumbfont color-grey-9 "}> 收起全文 diff --git a/public/react/src/modules/tpm/shixunchild/Collaborators/Collaborators.js b/public/react/src/modules/tpm/shixunchild/Collaborators/Collaborators.js index 17b083cf7..9799d060c 100644 --- a/public/react/src/modules/tpm/shixunchild/Collaborators/Collaborators.js +++ b/public/react/src/modules/tpm/shixunchild/Collaborators/Collaborators.js @@ -656,7 +656,7 @@ class Collaborators extends Component { 用户头像 -

{item.user.shixun_manager === true ? "创建者" : ""}

From e6a0239c2970eb3c31c830ed0de4bbe14aa84a0c Mon Sep 17 00:00:00 2001 From: tangjiang <465264938@qq.com> Date: Thu, 19 Dec 2019 20:11:12 +0800 Subject: [PATCH 2/2] update oj --- .../components/controlSetting/index.js | 20 ++++++++++++------- .../components/monacoSetting/index.js | 4 ++-- .../components/myMonacoEditor/index.js | 4 ++-- .../newOrEditTask/rightpane/index.scss | 3 ++- .../modules/developer/studentStudy/index.js | 9 +++++++-- .../developer/studentStudy/rightpane/index.js | 9 +++++++-- public/react/src/redux/actions/common.js | 4 ++-- public/react/src/redux/actions/index.js | 4 ++-- .../src/redux/reducers/ojForUserReducer.js | 9 +++++++-- 9 files changed, 44 insertions(+), 22 deletions(-) diff --git a/public/react/src/modules/developer/components/controlSetting/index.js b/public/react/src/modules/developer/components/controlSetting/index.js index b5c9222ef..1d4d7834c 100644 --- a/public/react/src/modules/developer/components/controlSetting/index.js +++ b/public/react/src/modules/developer/components/controlSetting/index.js @@ -4,10 +4,10 @@ * @Github: * @Date: 2019-11-27 16:02:36 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-19 10:47:44 + * @LastEditTime: 2019-12-19 19:47:32 */ import './index.scss'; -import React, { useState, useRef } from 'react'; +import React, { useState, useRef, useEffect } from 'react'; import { Tabs, Button, Icon } from 'antd'; import { connect } from 'react-redux'; import InitTabCtx from '../initTabCtx'; @@ -23,10 +23,11 @@ const ControlSetting = (props) => { submitLoading, identifier, excuteState, + showOrHideControl, commitRecordDetail, changeLoadingState, changeSubmitLoadingStatus, - showOrHideControl, + changeShowOrHideControl, // debuggerCode, // startDebuggerCode, // 外部存入 onDebuggerCode, @@ -44,10 +45,14 @@ const ControlSetting = (props) => { setDefaultActiveKey(key); } + useEffect(() => { + setShowTextResult(props.showOrHideControl); + }, [props]); + // 显示/隐藏tab const handleShowControl = () => { setShowTextResult(!showTextResult); - showOrHideControl(!showTextResult); + changeShowOrHideControl(!showTextResult); } // 调试代码 @@ -55,7 +60,7 @@ const ControlSetting = (props) => { // console.log(formRef.current.handleTestCodeFormSubmit); // 调出控制台界面 setShowTextResult(true); - showOrHideControl(true); + changeShowOrHideControl(true); formRef.current.handleTestCodeFormSubmit(() => { setDefaultActiveKey('2'); }); @@ -131,19 +136,20 @@ const ControlSetting = (props) => { const mapStateToProps = (state) => { const {commonReducer, ojForUserReducer} = state; - const {loading, excuteState, submitLoading } = commonReducer; + const {loading, excuteState, submitLoading, showOrHideControl } = commonReducer; const { commitRecordDetail } = ojForUserReducer; return { loading, submitLoading, excuteState, + showOrHideControl, // identifier: user_program_identifier, commitRecordDetail // 提交详情 }; }; // changeSubmitLoadingStatus const mapDispatchToProps = (dispatch) => ({ - showOrHideControl: (flag) => dispatch(actions.showOrHideControl(flag)), + changeShowOrHideControl: (flag) => dispatch(actions.changeShowOrHideControl(flag)), changeLoadingState: (flag) => dispatch(actions.changeLoadingState(flag)), changeSubmitLoadingStatus: (flag) => dispatch(actions.changeSubmitLoadingStatus(flag)), debuggerCode: (identifier, values) => dispatch(actions.debuggerCode(identifier, values)), diff --git a/public/react/src/modules/developer/components/monacoSetting/index.js b/public/react/src/modules/developer/components/monacoSetting/index.js index c1215f9af..669439577 100644 --- a/public/react/src/modules/developer/components/monacoSetting/index.js +++ b/public/react/src/modules/developer/components/monacoSetting/index.js @@ -4,11 +4,11 @@ * @Github: * @Date: 2019-11-25 17:50:33 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-19 15:26:46 + * @LastEditTime: 2019-12-19 19:32:08 */ import React, { useState } from 'react'; import { fromStore, toStore } from 'educoder'; -import { Icon } from 'antd'; +// import { Icon } from 'antd'; // import { Select } from 'antd'; // const { Option } = Select; const SettingDrawer = (props) => { diff --git a/public/react/src/modules/developer/components/myMonacoEditor/index.js b/public/react/src/modules/developer/components/myMonacoEditor/index.js index df3c2b5e3..948d5a4f5 100644 --- a/public/react/src/modules/developer/components/myMonacoEditor/index.js +++ b/public/react/src/modules/developer/components/myMonacoEditor/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 15:02:52 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-19 17:52:31 + * @LastEditTime: 2019-12-19 19:36:24 */ import './index.scss'; import React, { useState, useRef, useEffect } from 'react'; @@ -146,7 +146,7 @@ function MyMonacoEditor (props, ref) { > - {renderRestore} + {renderRestore} { + changeShowOrHideControl(false); props.saveEditorCodeForDetail(); props.history.push(`/problems/${_hack_id}/edit`); } // 处理退出 const handleClickQuit = () => { + // 将控制台关闭 + changeShowOrHideControl(false); props.saveEditorCodeForDetail(); props.history.push('/problems'); } @@ -164,6 +168,7 @@ const mapDispatchToProps = (dispatch) => ({ saveEditorCodeForDetail: (code) => dispatch(actions.saveEditorCodeForDetail(code)), // 恢复初始代码 restoreInitialCode: (identifier, msg) => dispatch(actions.restoreInitialCode(identifier, msg)), + changeShowOrHideControl: (flag) => dispatch(actions.changeShowOrHideControl(flag)) }); export default withRouter(connect( diff --git a/public/react/src/modules/developer/studentStudy/rightpane/index.js b/public/react/src/modules/developer/studentStudy/rightpane/index.js index 5661ea32e..af46d0aef 100644 --- a/public/react/src/modules/developer/studentStudy/rightpane/index.js +++ b/public/react/src/modules/developer/studentStudy/rightpane/index.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 14:59:51 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-19 15:06:49 + * @LastEditTime: 2019-12-19 19:13:05 */ import React, { useState, useEffect } from 'react'; import {connect} from 'react-redux'; @@ -32,6 +32,7 @@ const RightPane = (props) => { const [editorCode, setEditorCode] = useState(''); + let initFlag = true; useEffect(() => { if (editor_code) { setEditorCode(editor_code); @@ -51,8 +52,12 @@ const RightPane = (props) => { // 代码块内容变化时 const handleCodeChange = (code) => { // 保存用户提交的代码块 - // console.log(code); setEditorCode(code); + // 第一次回填代码内容时不更新; + if (initFlag) { + initFlag = false; + return; + } if (!timer) { timer = setInterval(() => { clearInterval(timer); diff --git a/public/react/src/redux/actions/common.js b/public/react/src/redux/actions/common.js index bcd451481..b95d2d2bb 100644 --- a/public/react/src/redux/actions/common.js +++ b/public/react/src/redux/actions/common.js @@ -4,12 +4,12 @@ * @Github: * @Date: 2019-11-27 16:30:50 * @LastEditors: tangjiang - * @LastEditTime: 2019-11-28 21:15:34 + * @LastEditTime: 2019-12-19 19:42:10 */ import types from "./actionTypes"; // 切换控制台显示与隐藏 -export const showOrHideControl = (flag) => { +export const changeShowOrHideControl = (flag) => { return { type: types.SHOW_OR_HIDE_CONTROL, payload: flag diff --git a/public/react/src/redux/actions/index.js b/public/react/src/redux/actions/index.js index ad33061ba..b42c4c2b6 100644 --- a/public/react/src/redux/actions/index.js +++ b/public/react/src/redux/actions/index.js @@ -52,7 +52,7 @@ import { } from './ojForUser'; import { - showOrHideControl, + changeShowOrHideControl, changeLoadingState, changeSubmitLoadingStatus, changePublishLoadingStatus, @@ -97,7 +97,7 @@ export default { testCaseOutputChange, debuggerCode, startProgramQuestion, - showOrHideControl, + changeShowOrHideControl, changeLoadingState, getUserCommitRecord, getUserCommitRecordDetail, diff --git a/public/react/src/redux/reducers/ojForUserReducer.js b/public/react/src/redux/reducers/ojForUserReducer.js index 60e7e6fd1..0c7594dd2 100644 --- a/public/react/src/redux/reducers/ojForUserReducer.js +++ b/public/react/src/redux/reducers/ojForUserReducer.js @@ -4,7 +4,7 @@ * @Github: * @Date: 2019-11-27 13:41:48 * @LastEditors: tangjiang - * @LastEditTime: 2019-12-19 14:49:03 + * @LastEditTime: 2019-12-19 20:10:39 */ import types from "../actions/actionTypes"; import { Base64 } from 'js-base64'; @@ -38,7 +38,12 @@ const ojForUserReducer = (state = initialState, action) => { const { hack, test_case } = action.payload; const { code }= hack; let tempCode = Base64.decode(code) - let tempDesc = JSON.parse(hack.description); + let tempDesc; + try { + tempDesc = JSON.parse(hack.description); + } catch (error) { + tempDesc = hack.description; + } Object.assign(hack, {code: tempCode, description: tempDesc}); return { ...state,