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 r=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:o})=>{const[S,w]=(0,r.useState)(o);function P(b){w(b.target.value)}function M(){n(S)}return(0,r.useEffect)(()=>{w(o)},[o]),r.createElement("div",{className:"clipboard-box"},r.createElement("h3",null,"\u5B9E\u9A8C\u73AF\u5883\u526A\u5207\u677F\uFF1A"),r.createElement(Ee,{value:S,onChange:P,className:"clipboard"}),r.createElement("p",null," ",r.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 "),r.createElement("p",null," ",r.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 "),r.createElement("div",{className:"btn-action-container"},r.createElement(q.ZP,{type:"ghost",onClick:e,style:{marginRight:10}},"\u53D6\u6D88"),r.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,A=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,d=(e,n,o)=>n in e?re(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,C=(e,n)=>{for(var o in n||(n={}))A.call(n,o)&&d(e,o,n[o]);if(ae)for(var o of ae(n))g.call(n,o)&&d(e,o,n[o]);return e},i=(e,n)=>ne(e,Ce(n)),T=(e,n,o)=>new Promise((S,w)=>{var P=v=>{try{b(o.next(v))}catch(J){w(J)}},M=v=>{try{b(o.throw(v))}catch(J){w(J)}},b=v=>v.done?S(v.value):Promise.resolve(v.value).then(P,M);b((o=o.apply(e,n)).next())});function V(e){return e.replace(/\\u([\dA-Za-z]{4})/g,function(n,o){return String.fromCharCode(parseInt("0x"+o))})}function U(e){e||(e=window.location.search);let n=e.substr(1),o={};return n.split("&").forEach(function(S){let w=S.split("=");o[w[0]]=decodeURIComponent(w[1])}),o}const y={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(C({},e),{loading:n.payload});case 1:return C({},i(C({},e),{isLarge:n.payload}));case 2:return i(C({},e),{mes:n.payload});case 3:return C(C({},e),n.payload);case 5:return i(C({},e),{transferContent:n.payload});case 4:return i(C({},e),{showClipBoardBox:n.payload});case 6:return C({loading:e.loading},n.payload);default:throw new Error}}var x=({vnc_url:e,window_vnc_url:n,linux_vnc:o,virtual_machine:S,taskData:w,shixun_environment_id:P,tab_type:M,instance_startup_type:b,index_tab:v,tpi_type:J})=>{const R=(0,r.useRef)(),Fe=(0,r.useRef)(),t=(0,r.useRef)(),F=(0,r.useRef)(),m=(0,r.useRef)(),p=(0,r.useRef)(),E=(0,r.useRef)(),u=(0,r.useRef)(),[B,h]=(0,r.useReducer)(ye,y),[G,ie]=(0,r.useState)(0),{mes:Le,loading:ce,showClipBoardBox:Ze,isLarge:L,transferContent:Ne}=B,be=(0,r.useRef)(),Pe=(0,r.useRef)(),[Re]=(0,se.useSearchParams)();let[Z,ue]=(0,r.useState)(0),oe=(0,r.useRef)();const N=(0,se.useParams)();(0,r.useEffect)(()=>()=>{var s,f;(f=(s=Fe.current)==null?void 0:s.disconnect)==null||f.call(s),clearTimeout(u.current),clearInterval(be.current)},[]),(0,r.useEffect)(()=>{Pe.current=B.loading},[B.loading]);const Ie=()=>{var s;b===2?setTimeout(()=>{Be()},1500):((s=t==null?void 0:t.current)==null?void 0:s.resizeSession)!==void 0&&((0,ee.vp)()?t.current.resizeSession=!0:setTimeout(()=>{t.current.resizeSession=!1},900))};(0,r.useEffect)(()=>(document.addEventListener((0,ee.gH)(),Ie),()=>{document.removeEventListener((0,ee.gH)(),Ie)}),[]);function de(){h({type:4,payload:!1})}function ze(){h({type:1,payload:!L})}function Oe(s){return R.current&&(F.current=new I.Z(f=>{for(let z of f)b===2&&Be(),(z.target.offsetHeight>0||z.target.offsetWidth>0)&&(s.scaleViewport=!0)}),F.current.observe(R.current)),F.current}const $e=()=>T(void 0,null,function*(){var s,f,z,D,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)((s=w.myshixun)==null?void 0:s.identifier,C(i(C({},N),{taskId:N.taskId,shixun_environment_id:P,tab_type:M}),Q));if((z=(f=a==null?void 0:a.data)==null?void 0:f.data_list)!=null&&z.length)return O.Z.publish("pod-restrict-data",{identifier:(D=a==null?void 0:a.data)==null?void 0:D.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(($,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(C({},a==null?void 0:a.data),{index_tab:v})),a});function De(){ue(100),clearTimeout(oe.current),setTimeout(()=>{t.current.resizeSession=!1,h({type:0,payload:!1})},1300),clearTimeout(be.current)}const ke=()=>{t.current=new ge.Z(R.current,E.current,{credentials:{password:p.current},wsProtocols:["binary"],show_dot:!0}),t.current.removeEventListener("disconnect",we),t.current.removeEventListener("connect",De),t.current.removeEventListener("clipboard",Ae),window.rfbs2=t.current,F.current=Oe(t.current),t.current.viewOnly=N.view_only||!1,t.current.scaleViewport=N.scale||!0,t.current.showDotCursor=!0,t.current.resizeSession=!0,t.current.addEventListener("disconnect",we),t.current.addEventListener("connect",De),t.current.addEventListener("clipboard",Ae)};function Ae(s){const f=V(s.detail.text);h({type:5,payload:f})}function we(){if(n)h({type:0,payload:!0}),ie(G+1);else{if(clearTimeout(u.current),Pe.current)return;u.current=setTimeout(()=>{ie(G+1)},6e3)}setTimeout(()=>{var s,f;(f=(s=t.current)==null?void 0:s.connect)==null||f.call(s)},3e3)}(0,r.useEffect)(()=>{if(O.Z.subscribe(`reset-linux-windows-vnc-${v}`,()=>{ie(G+1)}),(n||e||o||S)&&R.current){clearTimeout(oe.current),b===2&&Be(),new Promise(()=>T(void 0,null,function*(){var D,j,W,H,Q;const a=U();let $=yield $e();if(o||S){const X=(j=(D=$==null?void 0:$.data)==null?void 0:D.link_url)!=null&&j.includes("?")?"&":"?";m.current.src=((W=$==null?void 0:$.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=$==null?void 0:$.data)==null?void 0:H.link_url);else{const X=new URL(decodeURIComponent((Q=$==null?void 0:$.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(b===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=w==null?void 0:w.myshixun)==null?void 0:X.id}&envId=${P}&tpiType=${J}`,h({type:0,payload:!1})},5e3);return}ke()}));const s=O.Z.subscribe(`vnc-reset-${v}`,D=>{if(D==="\u53D6\u6D88"){h({type:0,payload:!1});return}ue(0),h({type:3,payload:{loading:!0,mes:D||"\u5B9E\u9A8C\u73AF\u5883\u91CD\u7F6E\u4E2D"}})}),f=O.Z.subscribe(`send-ctrl-alt-delete-${v}`,()=>{var D;(D=t.current)==null||D.sendCtrlAltDel(),Y.ZP.success("\u53D1\u9001\u6210\u529F")}),z=O.Z.subscribe(`show-clipboard-box-${v}`,()=>{h({type:4,payload:!0})});return ue(0),()=>{var D,j,W,H;(D=t.current)==null||D.removeEventListener("disconnect",we),(j=t.current)==null||j.removeEventListener("connect",De),(W=t.current)==null||W.removeEventListener("clipboard",Ae),s(),f(),z(),R.current&&((H=F.current)==null||H.unobserve(R.current))}}},[e,n,o,G,P,M]);function Me(){var s,f;(f=(s=t.current)==null?void 0:s.sendKey)==null||f.call(s,135)}function je(s){return T(this,null,function*(){var f;if(e){const z=s,D=yield(0,le.ZP)(`/api/tasks/${N.taskId}/vnc_paste.json`,{method:"post",body:{content:Base64.encode(z),shixun_environment_id:P}});(D==null?void 0:D.status)===0&&(h({type:5,payload:s}),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=t.current)==null||f.clipboardPasteFrom(s),h({type:5,payload:s}),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 s,f;s=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(${s});transform-origin:center center`,R.current.style.cssText="translate(-50%, -50%) scale("+s+")"}(0,r.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,r.useMemo)(()=>ce?"none":o||S||n&&b===2?"block":"none",[o,ce,S,n]);return c.createElement(r.Fragment,null,L&&c.createElement("a",{className:"btn-vnc-resize",onClick:ze},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:s=>c.createElement("span",{className:"c-white"},s,"%")}))):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 r=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=(A,g,d)=>g in A?Ee(A,g,{enumerable:!0,configurable:!0,writable:!0,value:d}):A[g]=d,c=(A,g)=>{for(var d in g||(g={}))ge.call(g,d)&&le(A,d,g[d]);if(te)for(var d of te(g))O.call(g,d)&&le(A,d,g[d]);return A},re=(A,g)=>he(A,ee(g)),ne=(A,g,d)=>new Promise((C,i)=>{var T=y=>{try{U(d.next(y))}catch(k){i(k)}},V=y=>{try{U(d.throw(y))}catch(k){i(k)}},U=y=>y.done?C(y.value):Promise.resolve(y.value).then(T,V);U((d=d.apply(A,g)).next())});const Ce=3e4;var ae=({itemData:A={},game:g,myshixun:d})=>{const C=(0,_.useParams)(),[i,T]=(0,r.useState)(null),[V,U]=(0,r.useState)({}),{link_url:y,password:k,port:ye}=V,x=(0,r.useRef)(),e=(0,r.useRef)(),n=(0,r.useRef)(!1),o=(0,r.useRef)(!1),S=(0,pe.oP)(),[w]=(0,_.useSearchParams)(),{shixun_environment_id:P,position:M,tab_type:b,index_tab:v}=A;(0,r.useEffect)(()=>{Fe()},[]);function J(t,F,m){let p=m._core._renderService.dimensions.actualCellWidth||9.5,E=m._core._renderService.dimensions.actualCellHeight||18;const u=Math.floor(F/E);return[Math.floor(t/p),u]}function R(t,F){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,t);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}),t.resize(u,B);const h=K.Base64.decode("IA=="),G=K.Base64.decode("CBtbSw==");t.write(h),t.write(G)}});return m.observe(F),m}function Fe(){return ne(this,null,function*(){var t,F,m,p;let E={};w.get("type")==="exercises"?E.exercise_id=w.get("exercisesId"):C.courseId&&C.homeworkId&&(E.homework_common_id=C.homeworkId);const u=yield(0,se.sA)(d==null?void 0:d.identifier,c(c({shixun_environment_id:P,tab_type:b,game_id:g.id},S),E));if((F=(t=u==null?void 0:u.data)==null?void 0:t.data_list)!=null&&F.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(C.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,r.useEffect)(()=>{if(x.current&&y){const t=new Y.Terminal({fontSize:16,rendererType:"dom"});t.open(x.current),t.onData(m=>{e.current&&e.current.readyState===1&&e.current.send(JSON.stringify({tp:"client",data:m}))}),t.write("Connecting..."),T(t);const F=R(t,x.current);return()=>{t.dispose(),x.current&&(F==null||F.unobserve(x.current))}}},[y,x.current]),(0,r.useEffect)(()=>{if(i&&y){let t=function(){const p=new WebSocket(y);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,y)},p.onmessage=u=>{o.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),o.current||i.write(`\r
|
|
connection closed`),o.current=!0,setTimeout(()=>{t()},1e4)}};const F=I.Z.subscribe(`create-socket-${v}`,()=>{t()}),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()=>{F(),m(),e.current&&(e.current.close(),n.current=!1)}}},[i,y,ye]),q.createElement("div",{ref:x,className:ve["xterm-panel"]},y?null:q.createElement("p",{style:{color:"#fff"}},"\u6B63\u5728\u8FDE\u63A5\u547D\u4EE4\u884C\u670D\u52A1..."))}}}]);
|