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.
NewEduCoderBuild/p__Terminal__.20417bf7.asyn...

162 lines
46 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[199],{"07cG":function(je,_,e){je.exports={ldsRing:"ldsRing___2F8W7",idsRingWrapper:"idsRingWrapper___fC2cF",ldsring:"ldsring___3A88y"}},AKST:function(je,_,e){},Dqnf:function(je,_,e){"use strict";var x=e("k1fw"),p=e("tJVT"),fe=e("rAM+"),k=e("q1tI"),K=e.n(k),C=e("J66h"),se=e.n(C),_e=e("/POA"),ie=e.n(_e),A=e("q7KB"),F=e.n(A),y=e("dhSg"),ve=e("bdgK");function ee(P,X,D){var de=D._core._renderService.dimensions.actualCellWidth||9.5,H=D._core._renderService.dimensions.actualCellHeight||18,L=Math.floor(X/H),Y=Math.floor(P/de);return[Y,L]}function ge(P,X){var D=new ve.default(function(de){var H=Object(fe.a)(de),L;try{for(H.s();!(L=H.n()).done;){var Y=L.value;if(Y.target.offsetHeight>0||Y.target.offsetWidth>0){var J=ee(Y.target.offsetWidth,Y.target.offsetHeight,P),M=Object(p.a)(J,2),ue=M[0],G=M[1];console.log("cols, rows",ue,G),P.resize(ue,G),y.a.publish("ssh-xterm-resize",{columns:ue,rows:G,width:Y.target.offsetWidth,height:Y.target.offsetHeight})}}}catch(T){H.e(T)}finally{H.f()}});return D.observe(X),D}var W=3e4;_.a=function(P){var X=P.sshConfigData,D=P.sid,de=Object(k.useState)(null),H=Object(p.a)(de,2),L=H[0],Y=H[1],J=X.ws_url,M=X.password,ue=X.port,G=Object(k.useRef)(),T=Object(k.useRef)(),me=Object(k.useRef)(!1);return Object(k.useEffect)(function(){if(G.current&&J){var te=new _e.Terminal({fontSize:16,rendererType:"dom"});te.open(G.current),te.onData(function(g){T.current&&(T.current.readyState===1&&(T.current.send(JSON.stringify({tp:"client",data:g})),y.a.publish("on-operating-ssh")))}),te.write("Connecting..."),Y(te);var oe=ge(te,G.current);return function(){te.dispose(),oe.unobserve(G.current)}}},[J,G.current]),Object(k.useEffect)(function(){if(L&&J){var te=function(){var b=new WebSocket(J);T.current=b,b.onopen=function(){var V=L.element.parentElement;if(V){var N=V.offsetWidth,m=V.offsetHeight;console.log("init",{tp:"init",data:Object(x.a)(Object(x.a)({},X),{},{secret:M,width:N,height:m,rows:L.rows,columns:L.cols})}),b.send(JSON.stringify({tp:"init",data:Object(x.a)(Object(x.a)({},X),{},{secret:M,width:N,height:m,rows:L.rows,columns:L.cols})}))}L.focus()},b.onerror=function(V){console.log("------in socket error----",V,b,J)},b.onmessage=function(V){me.current||(L.write("\r"),setTimeout(function(){},1e3)),me.current=!0,console.log("event:",V);var N=C.Base64.decode(V.data.toString()),m=L._core._renderService.dimensions.actualCellWidth||9.5;console.log("data:",N,m,L),L.write(N)},b.onclose=function(V){oe&&clearInterval(oe),L.write(`\r
connection closed`)}},oe=setInterval(function(){T.current&&T.current.send(JSON.stringify({tp:"h"}))},W),g=y.a.subscribe("create-socket",function(Z){D==Z&&(T.current&&T.current.readyState===1?L.focus():te(),L.focus())}),Le=y.a.subscribe("close-socket",function(Z){D===Z&&(T.current&&(T.current.close(),me.current=!1,L.clear()),T.current=null)}),pe=y.a.subscribe("ssh-xterm-resize",function(Z){T.current&&T.current.readyState===1&&T.current.send(JSON.stringify({tp:"resize",data:Object(x.a)({},Z)}))}),$=y.a.subscribe("ssh-add-connect-time",function(){T.current&&T.current.readyState===1&&T.current.send(JSON.stringify({tp:"overtime"}))});return function(){Le(),g(),pe(),$(),T.current&&(T.current.close(),me.current=!1)}}},[L,J,ue]),K.a.createElement("div",{ref:G,className:"xterm-panel"},J?null:K.a.createElement("p",{style:{color:"#fff"}},"\u6B63\u5728\u8FDE\u63A5\u547D\u4EE4\u884C\u670D\u52A1..."))}},IZBM:function(je,_,e){"use strict";e.d(_,"l",function(){return se}),e.d(_,"m",function(){return _e}),e.d(_,"i",function(){return ie}),e.d(_,"D",function(){return A}),e.d(_,"h",function(){return F}),e.d(_,"G",function(){return y}),e.d(_,"C",function(){return ve}),e.d(_,"x",function(){return ee}),e.d(_,"z",function(){return ge}),e.d(_,"f",function(){return W}),e.d(_,"q",function(){return P}),e.d(_,"g",function(){return X}),e.d(_,"j",function(){return D}),e.d(_,"v",function(){return L}),e.d(_,"k",function(){return Y}),e.d(_,"t",function(){return J}),e.d(_,"u",function(){return M}),e.d(_,"d",function(){return ue}),e.d(_,"A",function(){return G}),e.d(_,"B",function(){return T}),e.d(_,"y",function(){return me}),e.d(_,"F",function(){return te}),e.d(_,"n",function(){return oe}),e.d(_,"o",function(){return g}),e.d(_,"p",function(){return Le}),e.d(_,"s",function(){return pe}),e.d(_,"E",function(){return $}),e.d(_,"b",function(){return Z}),e.d(_,"c",function(){return b}),e.d(_,"a",function(){return V}),e.d(_,"r",function(){return N}),e.d(_,"e",function(){return m}),e.d(_,"w",function(){return O});var x=e("k1fw"),p=e("ErOA"),fe=e("1vsH"),k,K,C=((k=Object(fe.z)())===null||k===void 0?void 0:k.homework_common_id)?{homework_common_id:(K=Object(fe.z)())===null||K===void 0?void 0:K.homework_common_id}:{};function se(o){return Object(p.c)("tasks/".concat(o,".json"),C)}function _e(o){return Object(p.c)("myshixuns/".concat(o,"/challenges.json"))}function ie(o,l){return Object(p.c)("myshixuns/".concat(o,"/subject_challenges.json"),l)}function A(o,l,Q){return Object(p.c)("tasks/".concat(o,"/star.json?shixun_id=").concat(l,"&star=").concat(Q))}function F(o,l){return Object(p.c)("tasks/".concat(o,"/rep_content.json"),Object(x.a)(Object(x.a)({},l),C))}function y(o,l){return Object(p.f)("myshixuns/".concat(o,"/update_file.json"),l)}function ve(o,l){return Object(p.c)("tasks/".concat(o,"/reset_original_code.json"),Object(x.a)(Object(x.a)({},l),C))}function ee(o,l){return Object(p.f)("myshixuns/".concat(o,"/reset_repository.json"),l)}function ge(o,l){return Object(p.c)("tasks/".concat(o,"/reset_passed_code.json"),Object(x.a)(Object(x.a)({},l),C))}function W(o,l){return Object(p.f)("tasks/".concat(o,"/game_build.json"),Object(x.a)(Object(x.a)({},l),C))}function P(o,l){return Object(p.c)("tasks/".concat(o,"/game_status.json"),Object(x.a)(Object(x.a)({},l),C))}function X(o,l){return Object(p.f)("tasks/".concat(o,"/choose_build.json"),Object(x.a)(Object(x.a)({},l),C))}function D(o){return Object(p.c)("tasks/".concat(o,"/picture_display.json"),C)}function de(o,l){return Object(p.c)("tasks/".concat(o,"/cost_time.json"),Object(x.a)(Object(x.a)({},l),C))}function H(o,l){return Object(p.c)("courses/".concat(o,"/inform_detail.json"),l)}function L(o){return Object(p.f)("tasks/".concat(o,"/plus_or_cancel_praise.json"))}function Y(o){var l=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object(p.f)("myshixuns/".concat(o,"/repository.json"),l)}function J(o){return Object(p.c)("myshixuns/".concat(o,"/open_webssh.json"))}function M(o,l){return Object(p.c)("myshixuns/".concat(o,"/open_vm_webssh.json"),l)}function ue(o){return Object(p.c)("tasks/".concat(o,"/close_webssh.json"))}function G(o){return Object(p.c)("tasks/".concat(o,"/reset_vnc_link.json"),C)}function T(o){return Object(p.f)("tasks/".concat(o,"/reset_windows_vnc_link.json"))}function me(o,l){return Object(p.f)("tasks/".concat(o,"/reset_linux_vnc_link.json"),l||{})}function te(o){return Object(p.c)("tasks/".concat(o,"/check_test_sets.json"))}function oe(o){return Object(p.c)("tasks/".concat(o,"/get_answer_info.json"))}function g(o){return Object(p.c)("tasks/".concat(o,"/get_choose_answer.json"))}function Le(o){return Object(p.c)("tasks/".concat(o,"/unlock_choose_answer.json"))}function pe(o,l){return Object(p.c)("tasks/".concat(o,"/unlock_answer.json?answer_id=").concat(l))}function $(o,l,Q){return Object(p.f)("tasks/".concat(o,"/set_games_status.json"),{result:l,data:Q})}function Z(o){return Object(p.f)("tasks/".concat(o,"/extend_vnc.json"))}function b(o){return Object(p.f)("tasks/".concat(o,"/extend_windows_vnc.json"))}function V(o){return Object(p.f)("tasks/".concat(o,"/extend_linux_vnc.json"),C)}function N(o,l){return Object(p.c)("tasks/".concat(o,"/rank_list.json"),l)}function m(o,l){return Object(p.f)("tasks/".concat(o,"/close_windows_vnc.json"),{tpi_id:l})}function O(o){return Object(p.c)("tasks/".concat(o,"/pull_files.json"))}},IxHN:function(je,_,e){"use strict";var x=e("q1tI"),p=e.n(x),fe=e("07cG"),k=e.n(fe);_.a=function(K){var C=K.message,se=K.className,_e=K.children,ie=K.style,A=ie===void 0?{}:ie;return p.a.createElement("div",{className:"".concat(k.a.idsRingWrapper," ").concat(se)},p.a.createElement("div",{className:k.a.ldsRing},p.a.createElement("div",null),p.a.createElement("div",null),p.a.createElement("div",null),p.a.createElement("div",null)),C?p.a.createElement("p",{style:A},C):null,_e)}},Lmeb:function(je,_,e){},M8RZ:function(je,_,e){"use strict";e.d(_,"a",function(){return ie});var x=e("fWQN"),p=e("mtLc"),fe=e("yKVA"),k=e("879j"),K=e("q1tI"),C=e.n(K),se=e("i8i4"),_e=e.n(se),ie=function(A){Object(fe.a)(y,A);var F=Object(k.a)(y);function y(ve){var ee;Object(x.a)(this,y),ee=F.call(this,ve);var ge=window.document;return ee.node=ge.createElement("div"),ge.body.appendChild(ee.node),ee}return Object(p.a)(y,[{key:"render",value:function(){var ee=this.props.children;return Object(se.createPortal)(ee,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),y}(C.a.Component)},PYMJ:function(je,_,e){"use strict";e.r(_);var x=e("k1fw"),p=e("9og8"),fe=e("tJVT"),k=e("PpiC"),K=e("q1tI"),C=e.n(K),se=e("9kvl"),_e=e("Dqnf"),ie=e("qZJd"),A=e("Lmeb"),F=e.n(A),y=e("dhSg"),ve=e("ErOA");function ee(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ee=function(){return P};var W,P={},X=Object.prototype,D=X.hasOwnProperty,de=Object.defineProperty||function(s,t,r){s[t]=r.value},H=typeof Symbol=="function"?Symbol:{},L=H.iterator||"@@iterator",Y=H.asyncIterator||"@@asyncIterator",J=H.toStringTag||"@@toStringTag";function M(s,t,r){return Object.defineProperty(s,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),s[t]}try{M({},"")}catch(s){M=function(r,c,v){return r[c]=v}}function ue(s,t,r,c){var v=t&&t.prototype instanceof Le?t:Le,h=Object.create(v.prototype),R=new ce(c||[]);return de(h,"_invoke",{value:o(s,r,R)}),h}function G(s,t,r){try{return{type:"normal",arg:s.call(t,r)}}catch(c){return{type:"throw",arg:c}}}P.wrap=ue;var T="suspendedStart",me="suspendedYield",te="executing",oe="completed",g={};function Le(){}function pe(){}function $(){}var Z={};M(Z,L,function(){return this});var b=Object.getPrototypeOf,V=b&&b(b(ye([])));V&&V!==X&&D.call(V,L)&&(Z=V);var N=$.prototype=Le.prototype=Object.create(Z);function m(s){["next","throw","return"].forEach(function(t){M(s,t,function(r){return this._invoke(t,r)})})}function O(s,t){function r(v,h,R,U){var w=G(s[v],s,h);if(w.type!=="throw"){var ne=w.arg,ae=ne.value;return ae&&typeof ae=="object"&&D.call(ae,"__await")?t.resolve(ae.__await).then(function(S){r("next",S,R,U)},function(S){r("throw",S,R,U)}):t.resolve(ae).then(function(S){ne.value=S,R(ne)},function(S){return r("throw",S,R,U)})}U(w.arg)}var c;de(this,"_invoke",{value:function(h,R){function U(){return new t(function(w,ne){r(h,R,w,ne)})}return c=c?c.then(U,U):U()}})}function o(s,t,r){var c=T;return function(v,h){if(c===te)throw new Error("Generator is already running");if(c===oe){if(v==="throw")throw h;return{value:W,done:!0}}for(r.method=v,r.arg=h;;){var R=r.delegate;if(R){var U=l(R,r);if(U){if(U===g)continue;return U}}if(r.method==="next")r.sent=r._sent=r.arg;else if(r.method==="throw"){if(c===T)throw c=oe,r.arg;r.dispatchException(r.arg)}else r.method==="return"&&r.abrupt("return",r.arg);c=te;var w=G(s,t,r);if(w.type==="normal"){if(c=r.done?oe:me,w.arg===g)continue;return{value:w.arg,done:r.done}}w.type==="throw"&&(c=oe,r.method="throw",r.arg=w.arg)}}}function l(s,t){var r=t.method,c=s.iterator[r];if(c===W)return t.delegate=null,r==="throw"&&s.iterator.return&&(t.method="return",t.arg=W,l(s,t),t.method==="throw")||r!=="return"&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),g;var v=G(c,s.iterator,t.arg);if(v.type==="throw")return t.method="throw",t.arg=v.arg,t.delegate=null,g;var h=v.arg;return h?h.done?(t[s.resultName]=h.value,t.next=s.nextLoc,t.method!=="return"&&(t.method="next",t.arg=W),t.delegate=null,g):h:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,g)}function Q(s){var t={tryLoc:s[0]};1 in s&&(t.catchLoc=s[1]),2 in s&&(t.finallyLoc=s[2],t.afterLoc=s[3]),this.tryEntries.push(t)}function q(s){var t=s.completion||{};t.type="normal",delete t.arg,s.completion=t}function ce(s){this.tryEntries=[{tryLoc:"root"}],s.forEach(Q,this),this.reset(!0)}function ye(s){if(s||s===""){var t=s[L];if(t)return t.call(s);if(typeof s.next=="function")return s;if(!isNaN(s.length)){var r=-1,c=function v(){for(;++r<s.length;)if(D.call(s,r))return v.value=s[r],v.done=!1,v;return v.value=W,v.done=!0,v};return c.next=c}}throw new TypeError(typeof s+" is not iterable")}return pe.prototype=$,de(N,"constructor",{value:$,configurable:!0}),de($,"constructor",{value:pe,configurable:!0}),pe.displayName=M($,J,"GeneratorFunction"),P.isGeneratorFunction=function(s){var t=typeof s=="function"&&s.constructor;return!!t&&(t===pe||(t.displayName||t.name)==="GeneratorFunction")},P.mark=function(s){return Object.setPrototypeOf?Object.setPrototypeOf(s,$):(s.__proto__=$,M(s,J,"GeneratorFunction")),s.prototype=Object.create(N),s},P.awrap=function(s){return{__await:s}},m(O.prototype),M(O.prototype,Y,function(){return this}),P.AsyncIterator=O,P.async=function(s,t,r,c,v){v===void 0&&(v=Promise);var h=new O(ue(s,t,r,c),v);return P.isGeneratorFunction(t)?h:h.next().then(function(R){return R.done?R.value:h.next()})},m(N),M(N,J,"Generator"),M(N,L,function(){return this}),M(N,"toString",function(){return"[object Generator]"}),P.keys=function(s){var t=Object(s),r=[];for(var c in t)r.push(c);return r.reverse(),function v(){for(;r.length;){var h=r.pop();if(h in t)return v.value=h,v.done=!1,v}return v.done=!0,v}},P.values=ye,ce.prototype={constructor:ce,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=W,this.done=!1,this.delegate=null,this.method="next",this.arg=W,this.tryEntries.forEach(q),!t)for(var r in this)r.charAt(0)==="t"&&D.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=W)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if(t.type==="throw")throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function c(ne,ae){return R.type="throw",R.arg=t,r.next=ne,ae&&(r.method="next",r.arg=W),!!ae}for(var v=this.tryEntries.length-1;v>=0;--v){var h=this.tryEntries[v],R=h.completion;if(h.tryLoc==="root")return c("end");if(h.tryLoc<=this.prev){var U=D.call(h,"catchLoc"),w=D.call(h,"finallyLoc");if(U&&w){if(this.prev<h.catchLoc)return c(h.catchLoc,!0);if(this.prev<h.finallyLoc)return c(h.finallyLoc)}else if(U){if(this.prev<h.catchLoc)return c(h.catchLoc,!0)}else{if(!w)throw new Error("try statement without catch or finally");if(this.prev<h.finallyLoc)return c(h.finallyLoc)}}}},abrupt:function(t,r){for(var c=this.tryEntries.length-1;c>=0;--c){var v=this.tryEntries[c];if(v.tryLoc<=this.prev&&D.call(v,"finallyLoc")&&this.prev<v.finallyLoc){var h=v;break}}h&&(t==="break"||t==="continue")&&h.tryLoc<=r&&r<=h.finallyLoc&&(h=null);var R=h?h.completion:{};return R.type=t,R.arg=r,h?(this.method="next",this.next=h.finallyLoc,g):this.complete(R)},complete:function(t,r){if(t.type==="throw")throw t.arg;return t.type==="break"||t.type==="continue"?this.next=t.arg:t.type==="return"?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):t.type==="normal"&&r&&(this.next=r),g},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var c=this.tryEntries[r];if(c.finallyLoc===t)return this.complete(c.completion,c.afterLoc),q(c),g}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var c=this.tryEntries[r];if(c.tryLoc===t){var v=c.completion;if(v.type==="throw"){var h=v.arg;q(c)}return h}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,c){return this.delegate={iterator:ye(t),resultName:r,nextLoc:c},this.method==="next"&&(this.arg=W),g}},P}var ge=function(P){var X=P.classroomList,D=P.globalSetting,de=P.loading,H=P.dispatch,L=Object(k.a)(P,["classroomList","globalSetting","loading","dispatch"]),Y=Object(K.useState)({}),J=Object(fe.a)(Y,2),M=J[0],ue=J[1],G=Object(K.useState)({st:0,discusses_count:0,game_count:4,record_consume_time:null,prev_game:null,next_game:"cfwqv7lsi5pj",praise_count:0,user_praise:!1,time_limit:9,tomcat_url:"http://121.40.224.66",is_teacher:!0,myshixun_manager:!0,game:{id:2192586,myshixun_id:576993,user_id:1,created_at:"2021-03-16T20:38:10.000+08:00",updated_at:"2021-03-16T21:28:37.000+08:00",status:0,final_score:0,challenge_id:11829,open_time:"2021-03-16T20:38:12.000+08:00",identifier:"pcf9t4w6vrnz",answer_open:0,end_time:null,retry_status:0,resubmit_identifier:null,test_sets_view:!1,picture_path:null,accuracy:null,modify_time:"2020-07-20T15:04:34.000+08:00",star:0,cost_time:847,evaluate_count:0,answer_deduction:0,play_time:null,play_sign:0,extend_score:null,score_radio:0,exericse_evaluate_count:0,exercise_finished_at:null,homework_common_answer_open:!1},challenge:{id:11829,shixun_id:5207,subject:"\u5143\u7EC4\u4F7F\u7528\uFF1A\u8FD9\u4EFD\u83DC\u5355\u80FD\u4FEE\u6539\u5417\uFF1F",position:1,task_pass:`[TOC]
---
####\u4EFB\u52A1\u63CF\u8FF0
\u5143\u7EC4\u770B\u8D77\u6765\u72B9\u5982\u5217\u8868\uFF0C\u4F46\u5143\u7EC4\u4F7F\u7528\u5706\u62EC\u53F7\`\uFF08\uFF09\`\u800C\u4E0D\u662F\`[]\`\u6765\u6807\u8BC6\uFF0C\u800C\u4E14\u5217\u8868\u7684\u5143\u7D20\u53EF\u4EE5\u4FEE\u6539\uFF0C\u4F46\u5143\u7EC4\u7684\u5143\u7D20\u4E0D\u80FD\u4FEE\u6539\u3002\u672C\u5173\u4ECB\u7ECD\u5143\u7EC4\u7684\u5E38\u89C1\u4F7F\u7528\u65B9\u6CD5\u4EE5\u53CA\u5143\u7EC4\u548C\u5217\u8868\u7684\u4F7F\u7528\u533A\u522B\u3002\u4E0B\u9762\u7528\u996D\u5E97\u83DC\u5355\u7684\u4F8B\u5B50\u6765\u8BF4\u660E\u5217\u8868\u548C\u5143\u7EC4\u4F7F\u7528\u7684\u5E94\u7528\u573A\u666F\u3002
\u73B0\u5728\u6709\u4E00\u4E2A\u9910\u9986\u8981\u5411\u6BCF\u4E2A\u5305\u53A2\u90FD\u6295\u653E\u4E24\u4EFD\u83DC\u5355\uFF0C\u83DC\u5355\u4E0A\u67094\u79CD\u83DC\u540D\uFF0C\u6211\u4EEC\u60F3\u5C06\u4E24\u4E2A\u83DC\u5355\u4E0A\u6700\u540E\u4E00\u9053\u83DC\u540D\u4E92\u6362\u4E00\u4E0B\uFF0C\u4E5F\u60F3\u5FEB\u901F\u77E5\u9053\u6539\u53D8\u540E\u7684\u4E24\u4EFD\u83DC\u5355\u4E0A\u5355\u8BCD\u9996\u5B57\u6BCD\u6700\u5927\u7684\u83DC\u540D\u3002\u800C\u6211\u4EEC\u9996\u5148\u9700\u8981\u5224\u65AD\u8BE5\u7528\u5217\u8868\u7684\u65B9\u6CD5\u8FD8\u662F\u5143\u7EC4\u7684\u65B9\u6CD5\u5B9E\u73B0\u8FD9\u4E2A\u76EE\u6807\u3002
\u4E3A\u4E86\u5B9E\u73B0\u8FD9\u4E2A\u76EE\u6807\uFF0C\u6211\u4EEC\u9700\u8981\u5148\u5B66\u4E60\u5143\u7EC4\u7684\u76F8\u5173\u4F7F\u7528\u77E5\u8BC6\u4EE5\u53CA\u5143\u7EC4\u4E0E\u5217\u8868\u7684\u533A\u522B\u3002
####\u76F8\u5173\u77E5\u8BC6
#####\u5143\u7EC4\u4E0E\u5217\u8868
\u5143\u7EC4\u4E0E\u5217\u8868\u5F88\u76F8\u4F3C\uFF0C\u4E24\u8005\u4E4B\u95F4\u7684\u5DEE\u522B\u5728\u4E8E\uFF0C\u5217\u8868\u5728\u521D\u59CB\u5316\u540E\u5176\u4E2D\u7684\u5143\u7D20\u8FD8\u53EF\u4EE5\u8FDB\u884C\u589E\u5220\u6539\u7B49\u64CD\u4F5C\uFF0C\u4F46\u662F\u5143\u7EC4\u5728\u521D\u59CB\u5316\u540E\u5176\u4E2D\u7684\u5143\u7D20\u4E0D\u80FD\u8FDB\u884C\u66F4\u6539\uFF0C\u5217\u8868\u5728\u8D4B\u503C\u65F6\u4F7F\u7528\u65B9\u62EC\u53F7\`[]\`\uFF0C\u800C\u5143\u7EC4\u5728\u8D4B\u503C\u65F6\u4F7F\u7528\u5C0F\u62EC\u53F7\`()\`\u3002\u56E0\u4E3A\u5143\u7EC4\u5177\u6709\u4E0D\u53EF\u53D8\u7684\u7279\u6027\uFF0C\u6240\u4EE5\u5728\u80FD\u7528\u5143\u7EC4\u66FF\u4EE3\u5217\u8868\u7684\u5730\u65B9\u6700\u597D\u90FD\u4F7F\u7528\u5143\u7EC4\uFF0C\u8FD9\u6837\u4EE3\u7801\u66F4\u5B89\u5168\u3002
#####\u521B\u5EFA\u5143\u7EC4
\u5143\u7EC4\u521B\u5EFA\u5F88\u7B80\u5355\uFF0C\u53EA\u9700\u8981\u5728\u62EC\u53F7\`()\`\u4E2D\u6DFB\u52A0\u5143\u7D20\uFF0C\u5143\u7D20\u4E4B\u95F4\u7528\u9017\u53F7\u9694\u5F00\u3002\u5143\u7EC4\u4E2D\u53EA\u5305\u542B\u5355\u4E2A\u5143\u7D20\u65F6\uFF0C\u9700\u8981\u5728\u8BE5\u5143\u7D20\u540E\u9762\u6DFB\u52A0\u9017\u53F7\uFF0C\u4F8B\u5982\uFF1A
\`menu1 = ('meat','fish','chicken')\`
\`menu2 = ('meat',)\`
**![,](/api/attachments/386428)**
#####\u8BBF\u95EE\u5143\u7EC4
\u5143\u7EC4\u548C\u5217\u8868\u4E00\u6837\uFF0C\u53EF\u4EE5\u4F7F\u7528\u4E0B\u6807\u7D22\u5F15\u6765\u8BBF\u95EE\u5143\u7EC4\u4E2D\u7684\u503C\uFF0C\u4F8B\u5982:
\`\`\`python
menu = ('meat','fish','chicken','carrot')
print(menu[0])
print(menu[1:3])
\`\`\`
\u8F93\u51FA\u7ED3\u679C\uFF1A
\`meat\`
\`('fish', 'chicken')\`
#####\u4FEE\u6539\u5143\u7EC4
\u5143\u7EC4\u4E2D\u7684\u5143\u7D20\u503C\u662F\u4E0D\u53EF\u4EE5\u4FEE\u6539\u7684\uFF0C\u5982\u679C\u5F3A\u884C\u4FEE\u6539\u4F1A\u62A5\u9519\uFF0C\u4F8B\u5982\u5982\u679C\u6211\u4EEC\u60F3\u4FEE\u6539\u5143\u7EC4\`menu\`\u4E2D\u7684\u67D0\u4E2A\u503C\uFF1A
\`\`\`python
menu = ('meat','fish','chicken','carrot')
menu[0] = 'pizza'
print(menu[0])
\`\`\`
\u8F93\u51FA\u7ED3\u679C\uFF1A
\`TypeError: 'tuple' object does not support item assignment\`
\u7CFB\u7EDF\u4F1A\u81EA\u52A8\u62A5\u9519\uFF0C\u5143\u7EC4\u4E2D\u7684\u5143\u7D20\u503C\u4E0D\u652F\u6301\u4FEE\u6539\u3002
#####\u5143\u7EC4\u5185\u7F6E\u51FD\u6570
\u5143\u7EC4\u548C\u5217\u8868\u4E00\u6837\uFF0C\u90FD\u6709\u4E00\u4E9B\u5185\u7F6E\u51FD\u6570\u65B9\u4FBF\u7F16\u7A0B\u3002\u4F8B\u5982\uFF1A
\`len(tuple)\`\uFF1A\u8BA1\u7B97\u5143\u7EC4\u4E2D\u5143\u7D20\u4E2A\u6570\u3002
\`max(tuple)\`\uFF1A\u8FD4\u56DE\u5143\u7EC4\u4E2D\u5143\u7D20\u7684\u6700\u5927\u503C\u3002
\`min(tuple)\`\uFF1A\u8FD4\u56DE\u5143\u7EC4\u4E2D\u5143\u7D20\u7684\u6700\u5C0F\u503C\u3002
\`tuple(seq)\`\uFF1A\u5C06\u5217\u8868\u8F6C\u6362\u4E3A\u5143\u7EC4\u3002
\u5143\u7EC4\u4E2D\u7684\u5143\u7D20\u662F\u4E0D\u80FD\u6539\u53D8\u7684\uFF0C\u5B83\u4E5F\u6CA1\u6709\`append()\`\uFF0C\`insert()\`\u8FD9\u6837\u7684\u65B9\u6CD5\u3002\u4F46\u5176\u4ED6\u83B7\u53D6\u5143\u7D20\u7684\u65B9\u6CD5\u548C\u5217\u8868\u662F\u4E00\u6837\u7684\u3002
####\u7F16\u7A0B\u8981\u6C42
\u672C\u5173\u7684\u7F16\u7A0B\u4EFB\u52A1\u662F\u8865\u5168\`src/Step1/menu_test.py\`\u6587\u4EF6\u7684\u4EE3\u7801\u5185\u5BB9\uFF0C\u5B9E\u73B0\u5982\u4E0B\u529F\u80FD\uFF1A
- \u5C06\u8F93\u5165\u7684\u83DC\u5355menu_list\u8F6C\u6362\u4E3A\u5143\u7EC4\u7C7B\u578B
- \u6253\u5370\u8F93\u51FA\u751F\u6210\u7684\u5143\u7EC4
- \u6253\u5370\u8F93\u51FA\u5143\u7EC4\u4E2D\u9996\u5B57\u6BCD\u6700\u5927\u7684\u5143\u7D20
\u672C\u5173\u6D89\u53CA\u7684\u4EE3\u7801\u6587\u4EF6\`src/Step1/menu_test.py\`\u7684\u4EE3\u7801\u6846\u67B6\u5982\u4E0B\uFF1A
\`\`\`python
# coding=utf-8
# \u521B\u5EFA\u5E76\u521D\u59CB\u5316munu_list\u5217\u8868
menu_list = []
while True:
try:
food = input()
menu_list.append(food)
except:
break
# \u8BF7\u5728\u6B64\u6DFB\u52A0\u4EE3\u7801\uFF0C\u5BF9menu_list\u8FDB\u884C\u5143\u7EC4\u8F6C\u6362\u4EE5\u53CA\u5143\u7EC4\u8BA1\u7B97\u7B49\u64CD\u4F5C\uFF0C\u5E76\u6253\u5370\u8F93\u51FA\u5143\u7EC4\u53CA\u5143\u7EC4\u6700\u5927\u7684\u5143\u7D20
###### Begin ######
####### End #######
\`\`\`
####\u6D4B\u8BD5\u8BF4\u660E
\u672C\u5173\u7684\u6D4B\u8BD5\u6587\u4EF6\u662F\`src/Step1/menu_test.py\`\uFF0C\u6D4B\u8BD5\u8FC7\u7A0B\u5982\u4E0B\uFF1A
1. \u5E73\u53F0\u81EA\u52A8\u7F16\u8BD1\u5E76\u8FD0\u884C\`menu_test.py\`\uFF0C\u5E76\u4EE5\u6807\u51C6\u8F93\u5165\u65B9\u5F0F\u63D0\u4F9B\u6D4B\u8BC4\u8F93\u5165\uFF1B
3. \u5E73\u53F0\u83B7\u53D6\u7A0B\u5E8F\u7684\u8F93\u51FA\uFF0C\u7136\u540E\u5C06\u5176\u4E0E\u9884\u671F\u8F93\u51FA\u5BF9\u6BD4\uFF0C\u5982\u679C\u4E00\u81F4\u5219\u6D4B\u8BD5\u901A\u8FC7\uFF1B\u5426\u5219\u6D4B\u8BD5\u5931\u8D25\u3002
\u4EE5\u4E0B\u662F\u5E73\u53F0\u5BF9\`src/Step1/menu_test.py\`\u7684\u6837\u4F8B\u6D4B\u8BD5\u96C6\uFF1A
\u6D4B\u8BD5\u8F93\u5165\uFF1A
\`beef\`
\`veal\`
\`lamb\`
\`pork\`
\u9884\u671F\u8F93\u51FA\uFF1A
\`('beef', 'veal', 'lamb', 'pork')\`
\`veal\`
\u6D4B\u8BD5\u8F93\u5165\uFF1A
\`duck\`
\`broth\`
\`fish\`
\`macaroni\`
\u9884\u671F\u8F93\u51FA\uFF1A
\`('duck', 'broth', 'fish', 'macaroni')\`
\`macaroni\`
\u5F00\u59CB\u4F60\u7684\u4EFB\u52A1\u5427\uFF0C\u795D\u4F60\u6210\u529F\uFF01
\u5982\u679C\u4F60\u5E0C\u671B\u6210\u529F\uFF0C\u4EE5\u6052\u5FC3\u4E3A\u826F\u53CB\uFF0C\u4EE5\u7ECF\u9A8C\u4E3A\u53C2\u8C0B\uFF0C\u4EE5\u5C0F\u5FC3\u4E3A\u5144\u5F1F\uFF0C\u4EE5\u5E0C\u671B\u4E3A\u54E8\u5175\u3002
![](/api/attachments/171251)`,score:100,path:"src/step1/menu_test.py",difficulty:1,st:0,web_route:null,modify_time:"2020-07-20T15:04:34.000+08:00",exec_time:9,praises_count:0,ignore_space:1,open_rank:"CLOSE",hide_answer:!1,disable_copy:!1},shixun:{id:5207,name:"Python\u5143\u7EC4\u4E0E\u5B57\u5178\u5165\u95E8",user_id:1,gpid:null,visits:17,created_at:"2021-03-15T11:18:22.000+08:00",updated_at:"2021-03-16T20:38:08.000+08:00",status:0,language:"Python3.6",authentication:!1,identifier:"pmrfko5h",trainee:1,major_id:635,webssh:0,homepage_show:!1,hidden:!1,fork_from:3028,can_copy:!1,modify_time:"2017-10-11T09:45:02.000+08:00",reset_time:"2017-10-11T09:45:02.000+08:00",publish_time:"2019-08-02T11:30:27.000+08:00",closer_id:null,end_time:null,git_url:"eduforge/afvk9r35-1",myshixuns_count:1,challenges_count:4,use_scope:0,mirror_script_id:null,image_text:null,show_code_dir:!1,task_pass:!1,exec_time:145,test_set_permission:!0,sigle_training:!1,hide_code:!1,multi_webssh:!1,excute_time:null,repo_name:"innov/pmrfko5h20210315111822",averge_star:5,opening_time:null,users_count:1,forbid_copy:!1,pod_life:0,code_edit_permission:!1,laboratory_id:null,vip:!1,is_jupyter:!1,public:0,is_wechat_support:!0,to_be_built:!1,prebuild_click_count:0,display_git_address:!1,delete_user_id:null,sticky:0},myshixun:{id:576993,shixun_id:5207,is_public:!0,user_id:1,gpid:null,created_at:"2021-03-16T20:38:10.000+08:00",updated_at:"2021-03-16T21:28:39.000+08:00",status:0,identifier:"ln7i95zmef",commit_id:"c170e4ad0cb670cd610754f374af5f35974f4f8a",modify_time:"2017-10-11T09:45:02.000+08:00",reset_time:"2017-10-11T09:45:02.000+08:00",system_tip:!1,git_url:null,onclick_time:"2021-03-16T20:38:10.000+08:00",repo_name:"innov/ln7i95zmef20210316203810",hidden:!1,reset_repository_user_id:null},rank_name:null,windows_vnc:!0,user:{user_id:1,login:"innov",name:"99999",grade:368953,identity:1,image_url:"avatars/User/1?t=1593675434",school:"",user_url:"/users/innov"},tpm_modified:!1,tpm_cases_modified:!1,mirror_name:["Python3.6"],has_answer:!0,mirror_description:[`##### \u9002\u7528\u573A\u666F\r
\u7A0B\u5E8F\u8BBE\u8BA1\u3001\u7F51\u7EDC\u722C\u866B\u3001\u56FE\u50CF\u5904\u7406\u3001\u5927\u6570\u636E\u3001\u4EBA\u5DE5\u667A\u80FD\r
##### \u5305\u542B\u7684\u70ED\u95E8\u5E93\r
basemap;beautifulsoup4;Django;Flask;Keras;matplotlib;numpy;opencv;pip;PyMySQL;Scrapy;tensorflow;torch;pandas;tensorboard;requests;scikit-learn\r
##### \u5DF2\u5B89\u88C5\u5E93\u5217\u8868\uFF1A\r
absl-py;asn1crypto;astor;attrs;Automat;backcall;baidu-aip;basemap;beautifulsoup4;bleach;blinker;blis;bokeh;boto;boto3;botocore;cachetools;catalogue;certifi;cffi;chardet;click;constantly;crypto;cryptography;cssselect;cssutils;cycler;cymem;Cython;decorator;Django;dlib;dnspython;docutils;dominate;dpkt;dyNET;EasyProcess;et-xmlfile;ExifRead;face-recognition;face-recognition-models;ffmpeg;Flask;Flask-Bootstrap;Flask-Mail;Flask-SQLAlchemy;Flask-WTF;fonttools;gast;gensim;gpt-2-simple;graphviz;grpcio;h5py;html5lib;hyperlink;idna;importlib-metadata;incremental;IPy;ipython;ipython-genutils;itsdangerous;jdcal;jedi;jieba;Jinja2;jmespath;JPype1;Keras;Keras-Applications;Keras-Preprocessing;kiwisolver;lightgbm;llvmlite;lxml;Markdown;MarkupSafe;matplotlib;mpmath;murmurhash;mysql-connector;mysqlclient;Naked;networkx;nltk;numba;numpy;olefile;opencv-contrib-python;opencv-python;openpyxl;packaging;pandas;parsel;parso;patsy;pexpect;pickleshare;Pillow;pip;plac;popen;premailer;preshed;prettytable;prompt-toolkit;protobuf;psutil;ptyprocess;py4j;pyasn1;pyasn1-modules;PyAudio;pycparser;pycryptodome;pycurl;PyDispatcher;pydub;pyecharts;PyExecJS;Pygments;pygraphviz;pyhanlp;pymongo;PyMySQL;pyOpenSSL;pyparsing;PyPDF2;pyproj;pyquery;pyshp;pyspark;python-dateutil;python-docx;pyttsx3;pytz;PyVirtualDisplay;PyYAML;queuelib;regex;requests;rsa;s3transfer;scapy;scikit-learn;scipy;Scrapy;seaborn;selenium;service-identity;setuptools;shellescape;simplejson;six;smart-open;snapshot-phantomjs;snownlp;soupsieve;spacy;SQLAlchemy;srsly;statsmodels;sympy;tensorboard;tensorflow;tensorflow-tensorboard;termcolor;thinc;toposort;torch;torchvision;tornado;tqdm;traitlets;Twisted;urllib3;visitor;w3lib;wasabi;wcwidth;Werkzeug;wheel;wikipedia;wordcloud;WTForms;xgboost;xlrd;XlsxWriter;xlwt;z3-solver;zipp;zope.interface`],test_sets:[{is_public:!0,result:null,input:`pizza
ch icken
ca rrot
turkey
banana`,output:`('piz za', 'chicken', 'carrot', 'turkey', 'banana')
turkey
`,actual_output:null,compile_success:null,ts_time:null,ts_mem:null},{is_public:!0,result:null,input:`potato\r
agaric\r
beet\r
tomato`,output:`('potato', 'agaric', 'beet', 'tomato')
tomato
`,actual_output:null,compile_success:null,ts_time:null,ts_mem:null},{is_public:!1,result:null,input:`Spring Rolls\r
Lobster slices\r
Fried Wonton\r
Fried seaweed\r
Shrimp stoast\r
Wonton soup\r
shark fin soup`,output:`('Spring Rolls', 'Lobster slices', 'Fried Wonton', 'Fried seaweed', 'Shrimp stoast', 'Wonton soup', 'shark fin soup')
shark fin soup
`,actual_output:null,compile_success:null,ts_time:null,ts_mem:null},{is_public:!1,result:null,input:`turkey\r
duck\r
agaric\r
lamb`,output:`('turkey', 'duck', 'agaric', 'lamb')
turkey
`,actual_output:null,compile_success:null,ts_time:null,ts_mem:null},{is_public:!1,result:null,input:"Fried seaweed",output:`('Fried seaweed',)
Fried seaweed
`,actual_output:null,compile_success:null,ts_time:null,ts_mem:null}],allowed_unlock:!0,test_sets_count:null,sets_error_count:null}),T=Object(fe.a)(G,2),me=T[0],te=T[1],oe=L.match.params,g=L.location.query,Le;Object(K.useEffect)(function(){pe()},[]),Object(K.useEffect)(function(){M.host&&setTimeout(function(){y.a.publish("create-socket",1)},500)},[M]);var pe=function(){var $=Object(p.a)(ee().mark(function Z(){var b;return ee().wrap(function(N){for(;;)switch(N.prev=N.next){case 0:if(!(g.type==="terminal")){N.next=5;break}return N.next=3,Object(ve.a)("/api/myshixuns/".concat(g.taskId||"f3n9o5xvik","/open_webssh.json"),{method:"get"});case 3:b=N.sent,ue(Object(x.a)({},b));case 5:g.type==="windows";case 6:case"end":return N.stop()}},Z)}));return function(){return $.apply(this,arguments)}}();return C.a.createElement("section",{style:{position:"fixed",width:"100%",height:"100%",zIndex:22,top:0,right:0,bottom:0,left:0}},g.type==="terminal"&&C.a.createElement(_e.a,{sshConfigData:M,sid:1}),g.type!=="terminal"&&C.a.createElement(ie.a,{taskId:g.type==="windows"?"pcf9t4w6vrnz":"ijby95c82nsh",vnc_url:g.type==="vnc",window_vnc_url:g.type==="windows",taskData:me}))};_.default=Object(se.a)(function(W){var P=W.classroomList,X=W.loading,D=W.globalSetting;return{classroomList:P,globalSetting:D,loading:X.models.classroomList}})(ge)},qZJd:function(je,_,e){"use strict";var x=e("MXD1"),p=e("CFYs"),fe=e("miYZ"),k=e("tsqr"),K=e("2qtc"),C=e("kLXV"),se=e("9og8"),_e=e("rAM+"),ie=e("tJVT"),A=e("k1fw"),F=e("q1tI"),y=e.n(F),ve=e("IxHN"),ee=e("bdgK"),ge=e("M8RZ"),W=e("Ty5D"),P=e("1dTM"),X=e.n(P),D=e("dhSg"),de=e("+L6B"),H=e("2/Rp"),L=e("5NDa"),Y=e("5rEg"),J=e("AKST"),M=Y.a.TextArea,ue=function(m){var O=m.onCancel,o=m.onSave,l=m.content,Q=Object(F.useState)(l),q=Object(ie.a)(Q,2),ce=q[0],ye=q[1];function s(r){ye(r.target.value)}function t(){o(ce)}return Object(F.useEffect)(function(){ye(l)},[l]),y.a.createElement("div",{className:"clipboard-box"},y.a.createElement("h3",null,"\u5B9E\u9A8C\u73AF\u5883\u526A\u5207\u677F\uFF1A"),y.a.createElement(M,{value:ce,onChange:s,className:"clipboard"}),y.a.createElement("p",null," ",y.a.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 "),y.a.createElement("p",null," ",y.a.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 "),y.a.createElement("div",{className:"btn-action-container"},y.a.createElement(H.a,{type:"ghost",onClick:O,style:{marginRight:10}},"\u53D6\u6D88"),y.a.createElement(H.a,{type:"primary",onClick:t},"\u4FDD\u5B58")))},G=e("ErOA"),T=e("IZBM"),me=e("ye1Q"),te=e("wd/R"),oe=e.n(te);function g(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */g=function(){return O};var m,O={},o=Object.prototype,l=o.hasOwnProperty,Q=Object.defineProperty||function(u,n,a){u[n]=a.value},q=typeof Symbol=="function"?Symbol:{},ce=q.iterator||"@@iterator",ye=q.asyncIterator||"@@asyncIterator",s=q.toStringTag||"@@toStringTag";function t(u,n,a){return Object.defineProperty(u,n,{value:a,enumerable:!0,configurable:!0,writable:!0}),u[n]}try{t({},"")}catch(u){t=function(a,i,d){return a[i]=d}}function r(u,n,a,i){var d=n&&n.prototype instanceof ne?n:ne,f=Object.create(d.prototype),j=new Be(i||[]);return Q(f,"_invoke",{value:Ae(u,a,j)}),f}function c(u,n,a){try{return{type:"normal",arg:u.call(n,a)}}catch(i){return{type:"throw",arg:i}}}O.wrap=r;var v="suspendedStart",h="suspendedYield",R="executing",U="completed",w={};function ne(){}function ae(){}function S(){}var Ue={};t(Ue,ce,function(){return this});var Se=Object.getPrototypeOf,Re=Se&&Se(Se(ke([])));Re&&Re!==o&&l.call(Re,ce)&&(Ue=Re);var re=S.prototype=ne.prototype=Object.create(Ue);function Pe(u){["next","throw","return"].forEach(function(n){t(u,n,function(a){return this._invoke(n,a)})})}function be(u,n){function a(d,f,j,I){var E=c(u[d],u,f);if(E.type!=="throw"){var he=E.arg,z=he.value;return z&&typeof z=="object"&&l.call(z,"__await")?n.resolve(z.__await).then(function(B){a("next",B,j,I)},function(B){a("throw",B,j,I)}):n.resolve(z).then(function(B){he.value=B,j(he)},function(B){return a("throw",B,j,I)})}I(E.arg)}var i;Q(this,"_invoke",{value:function(f,j){function I(){return new n(function(E,he){a(f,j,E,he)})}return i=i?i.then(I,I):I()}})}function Ae(u,n,a){var i=v;return function(d,f){if(i===R)throw new Error("Generator is already running");if(i===U){if(d==="throw")throw f;return{value:m,done:!0}}for(a.method=d,a.arg=f;;){var j=a.delegate;if(j){var I=Me(j,a);if(I){if(I===w)continue;return I}}if(a.method==="next")a.sent=a._sent=a.arg;else if(a.method==="throw"){if(i===v)throw i=U,a.arg;a.dispatchException(a.arg)}else a.method==="return"&&a.abrupt("return",a.arg);i=R;var E=c(u,n,a);if(E.type==="normal"){if(i=a.done?U:h,E.arg===w)continue;return{value:E.arg,done:a.done}}E.type==="throw"&&(i=U,a.method="throw",a.arg=E.arg)}}}function Me(u,n){var a=n.method,i=u.iterator[a];if(i===m)return n.delegate=null,a==="throw"&&u.iterator.return&&(n.method="return",n.arg=m,Me(u,n),n.method==="throw")||a!=="return"&&(n.method="throw",n.arg=new TypeError("The iterator does not provide a '"+a+"' method")),w;var d=c(i,u.iterator,n.arg);if(d.type==="throw")return n.method="throw",n.arg=d.arg,n.delegate=null,w;var f=d.arg;return f?f.done?(n[u.resultName]=f.value,n.next=u.nextLoc,n.method!=="return"&&(n.method="next",n.arg=m),n.delegate=null,w):f:(n.method="throw",n.arg=new TypeError("iterator result is not an object"),n.delegate=null,w)}function Ie(u){var n={tryLoc:u[0]};1 in u&&(n.catchLoc=u[1]),2 in u&&(n.finallyLoc=u[2],n.afterLoc=u[3]),this.tryEntries.push(n)}function Ne(u){var n=u.completion||{};n.type="normal",delete n.arg,u.completion=n}function Be(u){this.tryEntries=[{tryLoc:"root"}],u.forEach(Ie,this),this.reset(!0)}function ke(u){if(u||u===""){var n=u[ce];if(n)return n.call(u);if(typeof u.next=="function")return u;if(!isNaN(u.length)){var a=-1,i=function d(){for(;++a<u.length;)if(l.call(u,a))return d.value=u[a],d.done=!1,d;return d.value=m,d.done=!0,d};return i.next=i}}throw new TypeError(typeof u+" is not iterable")}return ae.prototype=S,Q(re,"constructor",{value:S,configurable:!0}),Q(S,"constructor",{value:ae,configurable:!0}),ae.displayName=t(S,s,"GeneratorFunction"),O.isGeneratorFunction=function(u){var n=typeof u=="function"&&u.constructor;return!!n&&(n===ae||(n.displayName||n.name)==="GeneratorFunction")},O.mark=function(u){return Object.setPrototypeOf?Object.setPrototypeOf(u,S):(u.__proto__=S,t(u,s,"GeneratorFunction")),u.prototype=Object.create(re),u},O.awrap=function(u){return{__await:u}},Pe(be.prototype),t(be.prototype,ye,function(){return this}),O.AsyncIterator=be,O.async=function(u,n,a,i,d){d===void 0&&(d=Promise);var f=new be(r(u,n,a,i),d);return O.isGeneratorFunction(n)?f:f.next().then(function(j){return j.done?j.value:f.next()})},Pe(re),t(re,s,"Generator"),t(re,ce,function(){return this}),t(re,"toString",function(){return"[object Generator]"}),O.keys=function(u){var n=Object(u),a=[];for(var i in n)a.push(i);return a.reverse(),function d(){for(;a.length;){var f=a.pop();if(f in n)return d.value=f,d.done=!1,d}return d.done=!0,d}},O.values=ke,Be.prototype={constructor:Be,reset:function(n){if(this.prev=0,this.next=0,this.sent=this._sent=m,this.done=!1,this.delegate=null,this.method="next",this.arg=m,this.tryEntries.forEach(Ne),!n)for(var a in this)a.charAt(0)==="t"&&l.call(this,a)&&!isNaN(+a.slice(1))&&(this[a]=m)},stop:function(){this.done=!0;var n=this.tryEntries[0].completion;if(n.type==="throw")throw n.arg;return this.rval},dispatchException:function(n){if(this.done)throw n;var a=this;function i(he,z){return j.type="throw",j.arg=n,a.next=he,z&&(a.method="next",a.arg=m),!!z}for(var d=this.tryEntries.length-1;d>=0;--d){var f=this.tryEntries[d],j=f.completion;if(f.tryLoc==="root")return i("end");if(f.tryLoc<=this.prev){var I=l.call(f,"catchLoc"),E=l.call(f,"finallyLoc");if(I&&E){if(this.prev<f.catchLoc)return i(f.catchLoc,!0);if(this.prev<f.finallyLoc)return i(f.finallyLoc)}else if(I){if(this.prev<f.catchLoc)return i(f.catchLoc,!0)}else{if(!E)throw new Error("try statement without catch or finally");if(this.prev<f.finallyLoc)return i(f.finallyLoc)}}}},abrupt:function(n,a){for(var i=this.tryEntries.length-1;i>=0;--i){var d=this.tryEntries[i];if(d.tryLoc<=this.prev&&l.call(d,"finallyLoc")&&this.prev<d.finallyLoc){var f=d;break}}f&&(n==="break"||n==="continue")&&f.tryLoc<=a&&a<=f.finallyLoc&&(f=null);var j=f?f.completion:{};return j.type=n,j.arg=a,f?(this.method="next",this.next=f.finallyLoc,w):this.complete(j)},complete:function(n,a){if(n.type==="throw")throw n.arg;return n.type==="break"||n.type==="continue"?this.next=n.arg:n.type==="return"?(this.rval=this.arg=n.arg,this.method="return",this.next="end"):n.type==="normal"&&a&&(this.next=a),w},finish:function(n){for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a];if(i.finallyLoc===n)return this.complete(i.completion,i.afterLoc),Ne(i),w}},catch:function(n){for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a];if(i.tryLoc===n){var d=i.completion;if(d.type==="throw"){var f=d.arg;Ne(i)}return f}}throw new Error("illegal catch attempt")},delegateYield:function(n,a,i){return this.delegate={iterator:ke(n),resultName:a,nextLoc:i},this.method==="next"&&(this.arg=m),w}},O}var Le=y.a.createElement(me.a,{style:{fontSize:24},spin:!0});function pe(m){return m.replace(/\\u([\dA-Za-z]{4})/g,function(O,o){return String.fromCharCode(parseInt("0x"+o))})}function $(m){m||(m=window.location.search);var O=m.substr(1),o={};return O.split("&").forEach(function(l){var Q=l.split("=");o[Q[0]]=decodeURIComponent(Q[1])}),o}var Z={loading:!0,isLarge:!1,showClipBoardBox:!1,transferContent:"",mes:"\u5B9E\u9A8C\u73AF\u5883\u51C6\u5907\u4E2D"},b=function(m){return m[m.SET_LOADING=0]="SET_LOADING",m[m.SET_IS_LARGE=1]="SET_IS_LARGE",m[m.SET_MES=2]="SET_MES",m[m.SET_STATE=3]="SET_STATE",m[m.SHOW_CLIPBOARD_BOX=4]="SHOW_CLIPBOARD_BOX",m[m.SET_TRANSFER_CONTENT=5]="SET_TRANSFER_CONTENT",m}(b||{});function V(m,O){switch(O.type){case b.SET_LOADING:return Object(A.a)(Object(A.a)({},m),{},{loading:O.payload});case b.SET_IS_LARGE:return Object(A.a)(Object(A.a)({},m),{},{isLarge:O.payload});case b.SET_MES:return Object(A.a)(Object(A.a)({},m),{},{mes:O.payload});case b.SET_STATE:return Object(A.a)(Object(A.a)({},m),O.payload);case b.SET_TRANSFER_CONTENT:return Object(A.a)(Object(A.a)({},m),{},{transferContent:O.payload});case b.SHOW_CLIPBOARD_BOX:return Object(A.a)(Object(A.a)({},m),{},{showClipBoardBox:O.payload});default:throw new Error}}var N=_.a=function(m){var O=m.vnc_url,o=m.window_vnc_url,l=m.linux_vnc,Q=m.taskId,q=Object(F.useRef)(),ce=Object(F.useRef)(),ye=Object(F.useRef)(),s=Object(F.useReducer)(V,Z),t=Object(ie.a)(s,2),r=t[0],c=t[1],v=Object(F.useState)(0),h=Object(ie.a)(v,2),R=h[0],U=h[1],w=r.mes,ne=r.loading,ae=r.showClipBoardBox,S=r.isLarge,Ue=r.transferContent,Se=Object(F.useState)(0),Re=Object(ie.a)(Se,2),re=Re[0],Pe=Re[1],be=Object(F.useRef)(),Ae=Object(W.m)();Object(F.useEffect)(function(){return window.addEventListener("visibilitychange",Me),function(){window.removeEventListener("visibilitychange",Me)}},[]);var Me=function(d){if(document.visibilityState==="visible"){var f=sessionStorage.vncPageLeaveTime;oe()(new Date).diff(oe()(f),"minutes")>9&&U(new Date().getTime()),sessionStorage.removeItem("vncPageLeaveTime")}else sessionStorage.vncPageLeaveTime=new Date};function Ie(){c({type:b.SHOW_CLIPBOARD_BOX,payload:!1})}function Ne(){c({type:b.SET_IS_LARGE,payload:!S})}function Be(i){var d;return q.current&&(d=new ee.default(function(f){var j=Object(_e.a)(f),I;try{for(j.s();!(I=j.n()).done;){var E=I.value;(E.target.offsetHeight>0||E.target.offsetWidth>0)&&i._eventHandlers.windowResize()}}catch(he){j.e(he)}finally{j.f()}}),d.observe(q.current)),d}var ke=function(){var i=Object(se.a)(g().mark(function d(){var f,j,I,E;return g().wrap(function(z){for(;;)switch(z.prev=z.next){case 0:return I=((f=$())===null||f===void 0?void 0:f.homework_common_id)?{homework_common_id:(j=$())===null||j===void 0?void 0:j.homework_common_id}:{},z.next=3,Object(G.a)("/api/tasks/".concat(Ae.taskId||Q,"/get_vnc_link.json"),{method:"post",body:Object(A.a)(Object(A.a)({},Ae),I)});case 3:if(E=z.sent,!((E==null?void 0:E.status)===-3)){z.next=6;break}return z.abrupt("return",new Promise(function(){var B=Object(se.a)(g().mark(function le(Oe,Te){return g().wrap(function(xe){for(;;)switch(xe.prev=xe.next){case 0:C.a.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:function(){var Fe=Object(se.a)(g().mark(function Ce(){return g().wrap(function(De){for(;;)switch(De.prev=De.next){case 0:return clearTimeout(be.current),Pe(0),De.next=4,Object(T.e)(Ae.taskId,E==null?void 0:E.message);case 4:return U(R+1),De.abrupt("return");case 6:case"end":return De.stop()}},Ce)}));function We(){return Fe.apply(this,arguments)}return We}()});case 1:case"end":return xe.stop()}},le)}));return function(le,Oe){return B.apply(this,arguments)}}()));case 6:if(!((E==null?void 0:E.status)===-1)){z.next=8;break}throw new String(E==null?void 0:E.message);case 8:return D.a.publish("update-windows-time",E==null?void 0:E.data),z.abrupt("return",E);case 10:case"end":return z.stop()}},d)}));return function(){return i.apply(this,arguments)}}();Object(F.useEffect)(function(){var i,d;function f(B){o&&(k.b.warn("\u7531\u4E8E\u957F\u65F6\u95F4\u672A\u64CD\u4F5C\uFF0C\u8FDE\u63A5\u5931\u6548\uFF0C\u6B63\u5728\u91CD\u65B0\u8FDE\u63A5Windows VNC\u670D\u52A1"),c({type:b.SET_LOADING,payload:!0}),U(R+1))}D.a.subscribe("reset-linux-windows-loading",function(){c({type:b.SET_LOADING,payload:!0})}),D.a.subscribe("reset-linux-windos-vnc",function(){U(R+1)});function j(){clearTimeout(be.current),Pe(100),setTimeout(function(){c({type:b.SET_LOADING,payload:!1})},1300),D.a.subscribe("send-ctrl-alt-delete",function(){var B;(B=i)===null||B===void 0||B.sendCtrlAltDel()})}function I(B){var le=pe(B.detail.text);c({type:b.SET_TRANSFER_CONTENT,payload:le})}if((o||O||l)&&q.current){clearTimeout(be.current),new Promise(Object(se.a)(g().mark(function B(){var le,Oe,Te,Ee,xe,Fe,We,Ce,Ke,De,Ge;return g().wrap(function(we){for(;;)switch(we.prev=we.next){case 0:return le=$(),Oe="",we.next=4,ke();case 4:if(Ee=we.sent,!l){we.next=11;break}return ye.current.src=(Ee==null||((xe=Ee.data)===null||xe===void 0)?void 0:xe.vnc_url)+"&time="+Date.now(),c({type:b.SET_STATE,payload:{loading:!1,mes:"\u5B9E\u9A8C\u73AF\u5883\u91CD\u7F6E\u4E2D"}}),we.abrupt("return");case 11:o?(Te="Edu123",Oe=decodeURIComponent(Ee==null||((Fe=Ee.data)===null||Fe===void 0)?void 0:Fe.vnc_url)):(Ce=new URL(decodeURIComponent(Ee==null||((We=Ee.data)===null||We===void 0)?void 0:We.vnc_url)),Ke=Ce.protocol,De=Ce.searchParams,Ge=Ce.host,Te=De.get("password"),Oe="".concat(Ke==="https:"?"wss":"ws","://").concat(Ge,"/").concat(le.path||"websockify"));case 12:i=new X.a(q.current,Oe,{credentials:{password:Te},wsProtocols:["binary"]}),d=Be(i),i.viewOnly=le.view_only||!1,o?i.scaleViewport=!0:i.scaleViewport=le.scale||!1,i.scaleViewport=le.scale||!0,i.resizeSession=!0,ce.current=i,i.addEventListener("disconnect",f),i.addEventListener("connect",j),i.addEventListener("clipboard",I);case 22:case"end":return we.stop()}},B)})));var E=D.a.subscribe("vnc-reseting",function(){Pe(0),c({type:b.SET_STATE,payload:{loading:!0,mes:"\u5B9E\u9A8C\u73AF\u5883\u91CD\u7F6E\u4E2D"}})}),he=D.a.subscribe("vnc-enlarge",function(){c({type:b.SET_IS_LARGE,payload:!0})}),z=D.a.subscribe("show-clipboard-box",function(){c({type:b.SHOW_CLIPBOARD_BOX,payload:!0})});return Pe(0),function(){var B,le,Oe,Te;(B=i)===null||B===void 0||B.removeEventListener("disconnect",f),(le=i)===null||le===void 0||le.removeEventListener("connect",j),(Oe=i)===null||Oe===void 0||Oe.removeEventListener("clipboard",I),E(),he(),z(),(Te=d)===null||Te===void 0||Te.unobserve(q.current)}}},[O,o,l,R]);function u(i){var d;(d=ce.current)===null||d===void 0||d.clipboardPasteFrom(i),c({type:b.SET_TRANSFER_CONTENT,payload:i}),k.b.success("\u4FDD\u5B58\u6210\u529F\uFF01\u4F60\u53EF\u4EE5\u5728\u5B9E\u9A8C\u73AF\u5883\u4E2D\u7C98\u8D34\u8BE5\u5185\u5BB9"),Ie()}Object(F.useEffect)(function(){re==0&&(clearTimeout(be.current),n())},[re]);var n=function i(){re>99?re=99:(re=re+1,be.current=setTimeout(function(){i()},1500)),re<100&&Pe(re)},a=Object(F.useMemo)(function(){return ne?"none":l?"block":"none"},[l,ne]);return y.a.createElement(F.Fragment,null,S&&y.a.createElement("a",{className:"btn-vnc-resize",onClick:Ne},y.a.createElement("i",{className:"iconfont icon-tuichuquanping"})),y.a.createElement("iframe",{style:{display:a,position:S?"fixed":"absolute",left:0,top:S?54:40,zIndex:6,width:"100%",height:"calc(100% - ".concat(S?"100px":"45px",")")},frameBorder:"0",ref:ye}),y.a.createElement("div",{style:{position:S?"fixed":"absolute",left:0,top:S?54:40,zIndex:5,width:"100%",height:"calc(100% - ".concat(S?"100px":"45px",")")},className:"".concat(o?"vnc-panel-wrapper-windows":"vnc-panel-wrapper"," ").concat(S?"full-screen":"")},ne?y.a.createElement(ve.a,{message:w,style:{color:"#4CACFF"}},y.a.createElement("div",{className:"tc",style:{width:500,margin:"0 auto",color:"#FFF"}},y.a.createElement(p.a,{percent:re,format:function(d){return y.a.createElement("span",{className:"c-white"},d,"%")}}))):null,y.a.createElement("div",{ref:q,className:"vnc-panel ".concat(ne?"hide":"animated fadeIn")})),y.a.createElement(ge.a,null,y.a.createElement(C.a,{title:"\u590D\u5236\u7C98\u8D34",centered:!0,maskClosable:!1,visible:ae,onCancel:Ie,footer:null},y.a.createElement(ue,{onCancel:Ie,onSave:u,content:Ue}))))}}}]);