You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3 lines
16 KiB
3 lines
16 KiB
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[7903],{68967:function(){},45363:function(xe,fe,l){l.d(fe,{Z:function(){return x}});var t=l(59301),K=l(43418),Y=l(8591),Se=l(93948),ve=l(77353),I=l(76374),me=l(38134),se=l(63144),_=l(15826),pe=l(98135),q=l(3113);const Ee=pe.default.TextArea;var he=({onCancel:e,onSave:n,content:s})=>{const[S,A]=(0,t.useState)(s);function b(P){A(P.target.value)}function M(){n(S)}return(0,t.useEffect)(()=>{A(s)},[s]),t.createElement("div",{className:"clipboard-box"},t.createElement("h3",null,"\u5B9E\u9A8C\u73AF\u5883\u526A\u5207\u677F\uFF1A"),t.createElement(Ee,{value:S,onChange:b,className:"clipboard"}),t.createElement("p",null," ",t.createElement("b",null," 1.\u4ECE\u5916\u90E8\u590D\u5236\u5185\u5BB9\u5230\u5B9E\u9A8C\u73AF\u5883\u5185\uFF1A ")," \u7C98\u8D34\u5185\u5BB9\u5230\u4E0A\u9762\u6587\u672C\u6846\uFF0C\u70B9\u51FB\u4FDD\u5B58\uFF0C\u7136\u540E\u5728\u5B9E\u9A8C\u73AF\u5883\u4E2D\u8FDB\u884C\u7C98\u8D34\u3002 "),t.createElement("p",null," ",t.createElement("b",null," 2.\u83B7\u53D6\u5B9E\u9A8C\u73AF\u5883\u4E2D\u7684\u5185\u5BB9\uFF1A ")," \u8BF7\u5148\u5728\u73AF\u5883\u4E2D\u590D\u5236\u5185\u5BB9\uFF0C\u590D\u5236\u52A8\u4F5C\u5B8C\u6210\u540E\u5185\u5BB9\u4F1A\u663E\u793A\u5728\u4E0A\u9762\u6587\u672C\u6846\uFF0C\u7136\u540E\u5728\u4E0A\u9762\u6587\u672C\u6846\u4E2D\u518D\u6B21\u590D\u5236\u3002 "),t.createElement("div",{className:"btn-action-container"},t.createElement(q.ZP,{type:"ghost",onClick:e,style:{marginRight:10}},"\u53D6\u6D88"),t.createElement(q.ZP,{type:"primary",onClick:M},"\u4FDD\u5B58")))},ee=l(49457),te=l(73),ge=l(62013),O=l(44259),le=l(76265),c=l(59301),re=Object.defineProperty,ne=Object.defineProperties,Ce=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,w=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,d=(e,n,s)=>n in e?re(e,n,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[n]=s,y=(e,n)=>{for(var s in n||(n={}))w.call(n,s)&&d(e,s,n[s]);if(ae)for(var s of ae(n))C.call(n,s)&&d(e,s,n[s]);return e},i=(e,n)=>ne(e,Ce(n)),T=(e,n,s)=>new Promise((S,A)=>{var b=v=>{try{P(s.next(v))}catch(J){A(J)}},M=v=>{try{P(s.throw(v))}catch(J){A(J)}},P=v=>v.done?S(v.value):Promise.resolve(v.value).then(b,M);P((s=s.apply(e,n)).next())});function V(e){return e.replace(/\\u([\dA-Za-z]{4})/g,function(n,s){return String.fromCharCode(parseInt("0x"+s))})}function U(e){e||(e=window.location.search);let n=e.substr(1),s={};return n.split("&").forEach(function(S){let A=S.split("=");s[A[0]]=decodeURIComponent(A[1])}),s}const F={loading:!0,isLarge:!1,showClipBoardBox:!1,transferContent:"",mes:"\u5B9E\u9A8C\u73AF\u5883\u51C6\u5907\u4E2D"};var k=(e=>(e[e.SET_LOADING=0]="SET_LOADING",e[e.SET_IS_LARGE=1]="SET_IS_LARGE",e[e.SET_MES=2]="SET_MES",e[e.SET_STATE=3]="SET_STATE",e[e.SHOW_CLIPBOARD_BOX=4]="SHOW_CLIPBOARD_BOX",e[e.SET_TRANSFER_CONTENT=5]="SET_TRANSFER_CONTENT",e[e.UPDATE_ALL=6]="UPDATE_ALL",e))(k||{});function ye(e,n){switch(n.type){case 0:return i(y({},e),{loading:n.payload});case 1:return y({},i(y({},e),{isLarge:n.payload}));case 2:return i(y({},e),{mes:n.payload});case 3:return y(y({},e),n.payload);case 5:return i(y({},e),{transferContent:n.payload});case 4:return i(y({},e),{showClipBoardBox:n.payload});case 6:return y({loading:e.loading},n.payload);default:throw new Error}}var x=({vnc_url:e,window_vnc_url:n,linux_vnc:s,virtual_machine:S,taskData:A,shixun_environment_id:b,tab_type:M,instance_startup_type:P,index_tab:v,tpi_type:J})=>{const R=(0,t.useRef)(),Fe=(0,t.useRef)(),r=(0,t.useRef)(),D=(0,t.useRef)(),m=(0,t.useRef)(),p=(0,t.useRef)(),E=(0,t.useRef)(),u=(0,t.useRef)(),[B,h]=(0,t.useReducer)(ye,F),[G,ie]=(0,t.useState)(0),{mes:Le,loading:ce,showClipBoardBox:Ze,isLarge:L,transferContent:Ne}=B,Pe=(0,t.useRef)(),be=(0,t.useRef)(),[Re]=(0,se.useSearchParams)();let[Z,ue]=(0,t.useState)(0),oe=(0,t.useRef)();const N=(0,se.useParams)();(0,t.useEffect)(()=>()=>{var o,f;(f=(o=Fe.current)==null?void 0:o.disconnect)==null||f.call(o),clearTimeout(u.current),clearInterval(Pe.current)},[]),(0,t.useEffect)(()=>{be.current=B.loading},[B.loading]);const Ie=()=>{var o;P===2?setTimeout(()=>{Be()},1500):((o=r==null?void 0:r.current)==null?void 0:o.resizeSession)!==void 0&&((0,ee.vp)()?r.current.resizeSession=!0:setTimeout(()=>{},900))};(0,t.useEffect)(()=>(document.addEventListener((0,ee.gH)(),Ie),()=>{document.removeEventListener((0,ee.gH)(),Ie)}),[]);function de(){h({type:4,payload:!1})}function $e(){h({type:1,payload:!L})}function Oe(o){return R.current&&(D.current=new I.Z(f=>{var $;for(let g of f)P===2&&Be(),(g.target.offsetHeight>0||g.target.offsetWidth>0)&&(o.scaleViewport=!0,($=o==null?void 0:o._eventHandlers)==null||$.windowResize())}),D.current.observe(R.current)),D.current}const ze=()=>T(void 0,null,function*(){var o,f,$,g,j,W,H;let Q={};Re.get("type")==="exercises"?Q.exercise_id=Re.get("exercisesId"):N.courseId&&N.homeworkId&&(Q.homework_common_id=N.homeworkId);const a=yield(0,te.sA)((o=A.myshixun)==null?void 0:o.identifier,y(i(y({},N),{taskId:N.taskId,shixun_environment_id:b,tab_type:M}),Q));if(($=(f=a==null?void 0:a.data)==null?void 0:f.data_list)!=null&&$.length)return O.Z.publish("pod-restrict-data",{identifier:(g=a==null?void 0:a.data)==null?void 0:g.identifier,data_list:(j=a==null?void 0:a.data)==null?void 0:j.data_list}),Promise.reject();if((a==null?void 0:a.status)===-3)return new Promise((z,X)=>T(void 0,null,function*(){K.default.confirm({content:"\u68C0\u6D4B\u5230\u60A8\u5DF2\u7ECF\u5F00\u542F\u4E86\u5176\u4ED6\u5B9E\u9A8C\u73AF\u5883\uFF0C\u8BF7\u5148\u5173\u95ED\u73AF\u5883\u540E\uFF0C\u518D\u8FDE\u63A5",okText:"\u7ACB\u5373\u5173\u95ED",cancelText:"\u7A0D\u540E\u5173\u95ED",onOk:()=>T(void 0,null,function*(){clearTimeout(oe.current),ue(0),yield(0,te.fA)(N.taskId,a==null?void 0:a.message),ie(G+1)})})}));if((a==null?void 0:a.status)===-1)throw new String(a==null?void 0:a.message);if((a==null?void 0:a.status)===0)return S&&((0,_.d8)("PVEAuthCookie",(H=(W=a==null?void 0:a.data)==null?void 0:W.cookie_options)==null?void 0:H.cookies_value,1),(0,_.d8)("PVELangCookie","zh_CN",1)),O.Z.publish("update-windows-time",a==null?void 0:a.data),O.Z.publish("send-tabs-result-data",i(y({},a==null?void 0:a.data),{index_tab:v})),a});function De(){ue(100),clearTimeout(oe.current),setTimeout(()=>{h({type:0,payload:!1})},1300),clearTimeout(Pe.current)}const ke=()=>{r.current=new ge.Z(R.current,E.current,{credentials:{password:p.current},wsProtocols:["binary"],show_dot:!0}),r.current.removeEventListener("disconnect",Ae),r.current.removeEventListener("connect",De),r.current.removeEventListener("clipboard",we),window.rfbs2=r.current,D.current=Oe(r.current),r.current.viewOnly=N.view_only||!1,r.current.scaleViewport=N.scale||!0,r.current.showDotCursor=!0,r.current.resizeSession=!0,r.current.addEventListener("disconnect",Ae),r.current.addEventListener("connect",De),r.current.addEventListener("clipboard",we)};function we(o){const f=V(o.detail.text);h({type:5,payload:f})}function Ae(){if(n)h({type:0,payload:!0}),ie(G+1);else{if(clearTimeout(u.current),be.current)return;u.current=setTimeout(()=>{ie(G+1)},6e3)}setTimeout(()=>{var o,f;(f=(o=r.current)==null?void 0:o.connect)==null||f.call(o)},3e3)}(0,t.useEffect)(()=>{if(O.Z.subscribe(`reset-linux-windows-vnc-${v}`,()=>{ie(G+1)}),(n||e||s||S)&&R.current){clearTimeout(oe.current),P===2&&Be(),new Promise(()=>T(void 0,null,function*(){var g,j,W,H,Q;const a=U();let z=yield ze();if(s||S){const X=(j=(g=z==null?void 0:z.data)==null?void 0:g.link_url)!=null&&j.includes("?")?"&":"?";m.current.src=((W=z==null?void 0:z.data)==null?void 0:W.link_url)+X+"time="+Date.now(),h({type:0,payload:!1});return}else if(n)p.current="Edu123",E.current=decodeURIComponent((H=z==null?void 0:z.data)==null?void 0:H.link_url);else{const X=new URL(decodeURIComponent((Q=z==null?void 0:z.data)==null?void 0:Q.link_url)),{protocol:He,searchParams:Ve,host:Ue}=X;p.current=Ve.get("password"),E.current=`${He==="https:"?"wss":"ws"}://${Ue}/${a.path||"websockify"}`}if(P===2){setTimeout(()=>{var X;Oe(),m.current.style.cssText=m.current.style.cssText+"width:1920px;height:1080px;position:initial",m.current.src=`/rdp.html?tpiId=${(X=A==null?void 0:A.myshixun)==null?void 0:X.id}&envId=${b}&tpiType=${J}`,h({type:0,payload:!1})},5e3);return}ke()}));const o=O.Z.subscribe(`vnc-reset-${v}`,g=>{if(g==="\u53D6\u6D88"){h({type:0,payload:!1});return}ue(0),h({type:3,payload:{loading:!0,mes:g||"\u5B9E\u9A8C\u73AF\u5883\u91CD\u7F6E\u4E2D"}})}),f=O.Z.subscribe(`send-ctrl-alt-delete-${v}`,()=>{var g;(g=r.current)==null||g.sendCtrlAltDel(),Y.ZP.success("\u53D1\u9001\u6210\u529F")}),$=O.Z.subscribe(`show-clipboard-box-${v}`,()=>{h({type:4,payload:!0})});return ue(0),()=>{var g,j,W,H;(g=r.current)==null||g.removeEventListener("disconnect",Ae),(j=r.current)==null||j.removeEventListener("connect",De),(W=r.current)==null||W.removeEventListener("clipboard",we),o(),f(),$(),R.current&&((H=D.current)==null||H.unobserve(R.current))}}},[e,n,s,G,b,M]);function Me(){var o,f;(f=(o=r.current)==null?void 0:o.sendKey)==null||f.call(o,135)}function je(o){return T(this,null,function*(){var f;if(e){const $=o,g=yield(0,le.ZP)(`/api/tasks/${N.taskId}/vnc_paste.json`,{method:"post",body:{content:Base64.encode($),shixun_environment_id:b}});(g==null?void 0:g.status)===0&&(h({type:5,payload:o}),Y.ZP.success("\u4FDD\u5B58\u6210\u529F\uFF01\u4F60\u53EF\u4EE5\u5728\u5B9E\u9A8C\u73AF\u5883\u4E2D\u7C98\u8D34\u8BE5\u5185\u5BB9"),de())}else(f=r.current)==null||f.clipboardPasteFrom(o),h({type:5,payload:o}),Y.ZP.success("\u4FDD\u5B58\u6210\u529F\uFF01\u4F60\u53EF\u4EE5\u5728\u5B9E\u9A8C\u73AF\u5883\u4E2D\u7C98\u8D34\u8BE5\u5185\u5BB9"),de()})}function Be(){var o,f;o=Math.min(document.getElementById("task-right-panel").clientWidth/1920,document.getElementById("task-right-panel").clientHeight/1260),m.current.parentElement.className="wh1080p",m.current.parentElement.style.cssText=`transform:scale(${o});transform-origin:center center`,R.current.style.cssText="translate(-50%, -50%) scale("+o+")"}(0,t.useEffect)(()=>{Z==0&&(clearTimeout(oe.current),Te())},[Z]);const Te=()=>{Z>99?Z=99:(Z=Z+1,oe.current=setTimeout(()=>{Te()},1500)),Z<100&&ue(Z)},We=(0,t.useMemo)(()=>ce?"none":s||S||n&&P===2?"block":"none",[s,ce,S,n]);return c.createElement(t.Fragment,null,L&&c.createElement("a",{className:"btn-vnc-resize",onClick:$e},c.createElement("i",{className:"iconfont icon-tuichuquanping"})),c.createElement("div",{style:{width:"100%",height:"100%",overflow:"hidden",position:"absolute",display:We==="block"?"flex":"none",alignItems:"center",justifyContent:"center",zIndex:6}},c.createElement("div",null,c.createElement("iframe",{style:{position:L?"fixed":"absolute",left:0,top:L?40:0,width:"100%",height:`calc(100% - ${L?"100px":"0px"})`},frameBorder:"0",ref:m,allowFullScreen:!0}))),c.createElement("div",{style:{position:L?"fixed":"absolute",left:0,top:L?40:0,zIndex:5,width:"100%",height:`calc(100% - ${L?"100px":"0px"})`},className:`${n?"vnc-panel-wrapper-windows":"vnc-panel-wrapper"} ${L?"full-screen":""}`},ce?c.createElement(ve.Z,{message:Le,style:{color:"#0152d9"}},c.createElement("div",{className:"tc",style:{width:500,margin:"0 auto",color:"#FFF"}},c.createElement(Se.Z,{percent:Z,format:o=>c.createElement("span",{className:"c-white"},o,"%")}))):null,c.createElement("div",{ref:R,className:`vnc-panel ${ce?"hidden zIndexf1":"animated fadeIn"}`})),c.createElement(me.Z,null,c.createElement(K.default,{title:"\u590D\u5236\u7C98\u8D34",centered:!0,maskClosable:!1,open:Ze,onCancel:de,footer:null},c.createElement(he,{onCancel:de,onSave:je,content:Ne}))))}},73080:function(xe,fe,l){l.d(fe,{Z:function(){return ae}});var t=l(59301),K=l(24334),Y=l(34376),Se=l(75531),ve={"xterm-panel":"xterm-panel___XA0p9"},I=l(44259),me=l(76374),se=l(73),_=l(63144),pe=l(15826),q=l(59301),Ee=Object.defineProperty,he=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,te=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,le=(w,C,d)=>C in w?Ee(w,C,{enumerable:!0,configurable:!0,writable:!0,value:d}):w[C]=d,c=(w,C)=>{for(var d in C||(C={}))ge.call(C,d)&&le(w,d,C[d]);if(te)for(var d of te(C))O.call(C,d)&&le(w,d,C[d]);return w},re=(w,C)=>he(w,ee(C)),ne=(w,C,d)=>new Promise((y,i)=>{var T=F=>{try{U(d.next(F))}catch(k){i(k)}},V=F=>{try{U(d.throw(F))}catch(k){i(k)}},U=F=>F.done?y(F.value):Promise.resolve(F.value).then(T,V);U((d=d.apply(w,C)).next())});const Ce=3e4;var ae=({itemData:w={},game:C,myshixun:d})=>{const y=(0,_.useParams)(),[i,T]=(0,t.useState)(null),[V,U]=(0,t.useState)({}),{link_url:F,password:k,port:ye}=V,x=(0,t.useRef)(),e=(0,t.useRef)(),n=(0,t.useRef)(!1),s=(0,t.useRef)(!1),S=(0,pe.oP)(),[A]=(0,_.useSearchParams)(),{shixun_environment_id:b,position:M,tab_type:P,index_tab:v}=w;(0,t.useEffect)(()=>{Fe()},[]);function J(r,D,m){let p=m._core._renderService.dimensions.actualCellWidth||9.5,E=m._core._renderService.dimensions.actualCellHeight||18;const u=Math.floor(D/E);return[Math.floor(r/p),u]}function R(r,D){const m=new me.Z(p=>{for(let E of p)if(E.target.offsetHeight>0||E.target.offsetWidth>0){const[u,B]=J(E.target.offsetWidth,E.target.offsetHeight,r);console.log("cols, rows",u,B),I.Z.publish(`ssh-xterm-resize-${v}`,{columns:u,rows:B,width:E.target.offsetWidth,height:E.target.offsetHeight}),r.resize(u,B);const h=K.Base64.decode("IA=="),G=K.Base64.decode("CBtbSw==");r.write(h),r.write(G)}});return m.observe(D),m}function Fe(){return ne(this,null,function*(){var r,D,m,p;let E={};A.get("type")==="exercises"?E.exercise_id=A.get("exercisesId"):y.courseId&&y.homeworkId&&(E.homework_common_id=y.homeworkId);const u=yield(0,se.sA)(d==null?void 0:d.identifier,c(c({shixun_environment_id:b,tab_type:P,game_id:C.id},S),E));if((D=(r=u==null?void 0:u.data)==null?void 0:r.data_list)!=null&&D.length){I.Z.publish("pod-restrict-data",{identifier:(m=u==null?void 0:u.data)==null?void 0:m.identifier,data_list:(p=u==null?void 0:u.data)==null?void 0:p.data_list});return}if((u==null?void 0:u.status)===-3)return new Promise((B,h)=>ne(this,null,function*(){Modal.confirm({content:"\u68C0\u6D4B\u5230\u60A8\u5DF2\u7ECF\u5F00\u542F\u4E86\u5176\u4ED6\u5B9E\u9A8C\u73AF\u5883\uFF0C\u8BF7\u5148\u5173\u95ED\u73AF\u5883\u540E\uFF0C\u518D\u8FDE\u63A5",okText:"\u7ACB\u5373\u5173\u95ED",cancelText:"\u7A0D\u540E\u5173\u95ED",onOk:()=>ne(this,null,function*(){yield closeWindowsVnc(y.taskId,u==null?void 0:u.message),init()})})}));(u==null?void 0:u.status)===0&&(I.Z.publish("update-windows-time",u==null?void 0:u.data),I.Z.publish("send-tabs-result-data",re(c({},u==null?void 0:u.data),{index_tab:v})),U(u.data),setTimeout(()=>I.Z.publish(`create-socket-${v}`),300))})}return(0,t.useEffect)(()=>{if(x.current&&F){const r=new Y.Terminal({fontSize:16,rendererType:"dom"});r.open(x.current),r.onData(m=>{e.current&&e.current.readyState===1&&e.current.send(JSON.stringify({tp:"client",data:m}))}),r.write("Connecting..."),T(r);const D=R(r,x.current);return()=>{r.dispose(),x.current&&(D==null||D.unobserve(x.current))}}},[F,x.current]),(0,t.useEffect)(()=>{if(i&&F){let r=function(){const p=new WebSocket(F);e.current=p,p.onopen=()=>{let u=i.element.parentElement;if(u){let B=u.offsetWidth,h=u.offsetHeight;console.log("init",{tp:"init",data:re(c({},V),{secret:k,width:B,height:h,rows:i.rows,columns:i.cols})}),p.send(JSON.stringify({tp:"init",data:re(c({},V),{secret:k,width:B,height:h,rows:i.rows,columns:i.cols})}))}i.focus()},p.onerror=u=>{console.log("------in socket error----",u,p,F)},p.onmessage=u=>{s.current=!1,n.current||(i.write("\r"),setTimeout(()=>{},1e3)),n.current=!0,console.log("event:",u);const B=K.Base64.decode(u.data.toString());let h=i._core._renderService.dimensions.actualCellWidth||9.5;console.log("data:",B,h,i),i.write(B)};const E=setInterval(()=>{var u;e.current&&((u=e.current)==null||u.send(JSON.stringify({tp:"h"})))},Ce);p.onclose=u=>{E&&clearInterval(E),console.log(E,"tid",v),s.current||i.write(`\r
|
|
connection closed`),s.current=!0,setTimeout(()=>{r()},1e4)}};const D=I.Z.subscribe(`create-socket-${v}`,()=>{r()}),m=I.Z.subscribe(`ssh-xterm-resize-${v}`,p=>{e.current&&e.current.readyState===1&&e.current.send(JSON.stringify({tp:"resize",data:c({},p)}))});return()=>{D(),m(),e.current&&(e.current.close(),n.current=!1)}}},[i,F,ye]),q.createElement("div",{ref:x,className:ve["xterm-panel"]},F?null:q.createElement("p",{style:{color:"#fff"}},"\u6B63\u5728\u8FDE\u63A5\u547D\u4EE4\u884C\u670D\u52A1..."))}}}]);
|