diff --git a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js index e9674b2ac..d3aa910b8 100644 --- a/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js +++ b/public/react/src/modules/tpm/shixunchild/Challenges/Challengesjupyter.js @@ -8,7 +8,7 @@ import '../shixunchildCss/Challenges.css'; import axios from 'axios'; const $ = window.$; - +//12.20,14:11 class Challengesjupyter extends Component { constructor(props) { super(props) @@ -48,54 +48,33 @@ class Challengesjupyter extends Component { isopentitletype:"Less", }) } - this.getjianjiesize() } } }).catch((error) => { //console.log(error) }); } - - - getjianjiesize=()=>{ - let {ChallengesDataList}=this.state; - let boxoffsetHeigh; - let box=document.getElementById("shixunchallengesid"); - - if(box){ - boxoffsetHeigh=box.offsetHeight - if(ChallengesDataList === undefined || ChallengesDataList&&ChallengesDataList.description=== ""||ChallengesDataList&&ChallengesDataList.description===null||ChallengesDataList&&ChallengesDataList.description===undefined){ - - }else{ - if(this.state.isopentitletype==="greater"){ - - }else{ - if(boxoffsetHeigh>=300){ - this.setState({ - opentitletype:true, - isopentitletype:"greater", - boxoffsetHeigh:boxoffsetHeigh - }) - }else{ - this.setState({ - isopentitletype:"Less", - boxoffsetHeigh:boxoffsetHeigh - }) - } - } - - } - - } - } componentDidUpdate = (prevProps,prevState) => { //防止陷入无限循环 if(prevState.ChallengesDataList!=this.state.ChallengesDataList){ - if(this.state.isopentitletype==="greater"){ + let boxoffsetHeigh; + let box=document.getElementById("shixunchallengesid"); + if(box){ + boxoffsetHeigh=box.offsetHeight + if(boxoffsetHeigh<300){ + this.setState({ + isopentitletype:"Less", + boxoffsetHeigh:boxoffsetHeigh + }) + }else{ + this.setState({ + isopentitletype:"greater", + opentitletype:true, + boxoffsetHeigh:boxoffsetHeigh + }) + } - }else{ - this.getjianjiesize() } } @@ -105,9 +84,9 @@ class Challengesjupyter extends Component { setTimeout(this.ChallengesList(), 1000); let id = this.props.match.params.shixunId; let ChallengesURL = `/jupyters/get_info_with_tpm.json`; - let datas={ - identifier:id, - } + let datas={ + identifier:id, + } axios.get(ChallengesURL, {params: datas}).then((response) => { if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { setTimeout(() => { @@ -115,26 +94,26 @@ class Challengesjupyter extends Component { booljupyterurls:true, }) }, 600) + }else{ + if(response.data.status===0){ + + setTimeout(() => { + this.setState({ + jupyter_url:response.data.url, + jupyter_port:response.data.port, + booljupyterurls:true, + }) + }, 800) + }else{ - if(response.data.status===0){ - - setTimeout(() => { - this.setState({ - jupyter_url:response.data.url, - jupyter_port:response.data.port, - booljupyterurls:true, - }) - }, 800) - - }else{ - setTimeout(() => { - this.setState({ - booljupyterurls:true, - }) - }, 600) + setTimeout(() => { + this.setState({ + booljupyterurls:true, + }) + }, 600) - } } + } }).catch((error) => { @@ -145,10 +124,6 @@ class Challengesjupyter extends Component { }, 600) }); - setTimeout(this.getjianjiesize(), 1000); - - - window.addEventListener('message', (e) => { console.log("触发了jupytermessage"); @@ -163,8 +138,6 @@ class Challengesjupyter extends Component { } }); - setTimeout(this.getjianjiesize(), 1000); - } updatamakedowns = () => { @@ -218,13 +191,13 @@ class Challengesjupyter extends Component { modifyjupyter=()=>{ let id=this.props.match.params.shixunId; - var jupyter_port=""; - try{ - jupyter_port= parseInt(this.state.jupyter_port); - }catch (e) { - jupyter_port=this.state.jupyter_port; + var jupyter_port=""; + try{ + jupyter_port= parseInt(this.state.jupyter_port); + }catch (e) { + jupyter_port=this.state.jupyter_port; - } + } const url=`/jupyters/save_with_tpm.json`; const data={ identifier:id, @@ -234,7 +207,6 @@ class Challengesjupyter extends Component { .then((result) => { if (result.data.status === 0) { this.props.showNotification(`应用成功`); - console.log("触发了jupytermessage调用了应用成功"); } }).catch((error) => { }) @@ -245,15 +217,12 @@ class Challengesjupyter extends Component { opentitletype:!this.state.opentitletype }) } - onclki=(bool)=>{ this.setState({ enlarge:bool }) } - - render() { let{ChallengesDataList,booljupyterurls,enlarge}=this.state; let id = this.props.match.params.shixunId; @@ -263,8 +232,6 @@ class Challengesjupyter extends Component { const business = this.props&&this.props.current_user&&this.props.current_user.business?this.props.current_user.business:false; //管理员 const admin = this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; - //用户 - const login = this.props&&this.props.current_user&&this.props.current_user.login?this.props.current_user.login:""; let mysidentity =false; try { @@ -286,39 +253,17 @@ class Challengesjupyter extends Component { - -
@@ -385,9 +330,8 @@ class Challengesjupyter extends Component { display: flex; flex-direction:row-reverse; } - ; - } + } ` } @@ -396,29 +340,33 @@ class Challengesjupyter extends Component { "" : ( - admin===true||business===true||mysidentity===true? -
任务详情
(请将实训题目写在下方并保存)
导入
*/} - {/*任务详情
(请将实训题目写在下方并保存)
导入
*/} + {/*