diff --git a/public/javascripts/jupyter.js b/public/javascripts/jupyter.js index 3141fc3c5..7f5e97b0f 100644 --- a/public/javascripts/jupyter.js +++ b/public/javascripts/jupyter.js @@ -23,27 +23,23 @@ function runEvery10Sec() { } $(function(){ -document.addEventListener('keydown', (e) => { - if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)){ - e.preventDefault(); - console.log("点击了ctrl+s"); - console.log("开始发送消息了ctrl+s"); - window.parent.postMessage('jupytermessage','*'); - } -}); -}) -$(function(){ + document.addEventListener('keydown', (e) => { + if (e.keyCode == 83 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)){ + e.preventDefault(); + console.log("点击了ctrl+s"); + console.log("开始发送消息了ctrl+s"); + window.parent.postMessage('jupytermessage','*'); + } + }); + window.addEventListener('message', (e) => { - console.log("触发了Parentwindow"); - console.log(e); + if(e){ if(e.data){ - if(e.data==="Parentwindow"){ + if(e.data==="stopParent"){ //重置停止 timebool=false; - console.log("父窗口调我了"); - }else if(e.data==="Parentwindow"){ - console.log("父窗口调我了"); + }else if(e.data==="clonsParent"){ //取消启动 timebool=true; this.runEvery10Sec(); @@ -53,5 +49,6 @@ $(function(){ } }); + }) diff --git a/public/react/src/modules/tpm/jupyter/index.js b/public/react/src/modules/tpm/jupyter/index.js index 0e209523f..b5c1ff217 100644 --- a/public/react/src/modules/tpm/jupyter/index.js +++ b/public/react/src/modules/tpm/jupyter/index.js @@ -135,6 +135,14 @@ function JupyterTPI (props) { // 重置实训 const handleClickResetTpi = () => { + + var _iframe = document.getElementById("rightPaneframe"); + if(_iframe == null || _iframe == undefined || _iframe == ""){ + return; + } + _iframe.contentWindow.postMessage("stopParent", "*"); + + Modal.confirm({ title: '重置实训', content: ( @@ -150,7 +158,10 @@ function JupyterTPI (props) { if (myIdentifier) { syncJupyterCode(myIdentifier, '重置成功'); } - } + }, + onCancel() { + _iframe.contentWindow.postMessage("clonsParent", "*"); + }, }) } diff --git a/public/react/src/modules/tpm/jupyter/rightPane/index.js b/public/react/src/modules/tpm/jupyter/rightPane/index.js index d23849369..da3a548d2 100644 --- a/public/react/src/modules/tpm/jupyter/rightPane/index.js +++ b/public/react/src/modules/tpm/jupyter/rightPane/index.js @@ -57,7 +57,8 @@ function RightPane (props) {