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__.af2d6307.asyn...

162 lines
42 KiB

(window.webpackJsonp=window.webpackJsonp||[]).push([[125],{"07cG":function(se,l,t){se.exports={ldsRing:"ldsRing___2F8W7",idsRingWrapper:"idsRingWrapper___fC2cF",ldsring:"ldsring___3A88y"}},AKST:function(se,l,t){},Dqnf:function(se,l,t){"use strict";var Z=t("k1fw"),C=t("tJVT"),Y=t("rAM+"),f=t("q1tI"),s=t.n(f),P=t("J66h"),ne=t.n(P),Q=t("/POA"),T=t.n(Q),ie=t("q7KB"),de=t.n(ie),b=t("ER/M"),O=t.n(b),d=t("dhSg"),me=t("bdgK");function A(B,F,$){var S=$._core._renderService.dimensions.actualCellWidth||9.5,j=$._core._renderService.dimensions.actualCellHeight||18,_=Math.floor(F/j),N=Math.floor(B/S);return[N,_]}function G(B,F){var $=new me.default(function(S){var j=Object(Y.a)(S),_;try{for(j.s();!(_=j.n()).done;){var N=_.value;if(N.target.offsetHeight>0||N.target.offsetWidth>0){var y=A(N.target.offsetWidth,N.target.offsetHeight,B),q=Object(C.a)(y,2),k=q[0],D=q[1];console.log("cols, rows",k,D),d.a.publish("ssh-xterm-resize",{columns:k,rows:D,width:N.target.offsetWidth,height:N.target.offsetHeight}),B.resize(k,D);var h=P.Base64.decode("IA=="),V=P.Base64.decode("CBtbSw==");B.write(h),B.write(V)}}}catch(E){j.e(E)}finally{j.f()}});return $.observe(F),$}var z=3e4;l.a=function(B){var F=B.sshConfigData,$=B.sid,S=Object(f.useState)(null),j=Object(C.a)(S,2),_=j[0],N=j[1],y=F.ws_url,q=F.password,k=F.port,D=Object(f.useRef)(),h=Object(f.useRef)(),V=Object(f.useRef)(!1);return Object(f.useEffect)(function(){if(D.current&&y){var E=new Q.Terminal({fontSize:16,rendererType:"dom"});E.open(D.current),E.onData(function(oe){h.current&&(h.current.readyState===1&&(h.current.send(JSON.stringify({tp:"client",data:oe})),d.a.publish("on-operating-ssh")))}),E.write("Connecting..."),N(E);var W=G(E,D.current);return function(){E.dispose(),W.unobserve(D.current)}}},[y,D.current]),Object(f.useEffect)(function(){if(_&&y){var E=function(){var U=new WebSocket(y);h.current=U,U.onopen=function(){var m=_.element.parentElement;if(m){var re=m.offsetWidth,o=m.offsetHeight;console.log("init",{tp:"init",data:Object(Z.a)(Object(Z.a)({},F),{},{secret:q,width:re,height:o,rows:_.rows,columns:_.cols})}),U.send(JSON.stringify({tp:"init",data:Object(Z.a)(Object(Z.a)({},F),{},{secret:q,width:re,height:o,rows:_.rows,columns:_.cols})}))}_.focus()},U.onerror=function(m){console.log("------in socket error----",m,U,y)},U.onmessage=function(m){V.current||(_.write("\r"),setTimeout(function(){},1e3)),V.current=!0,console.log("event:",m);var re=P.Base64.decode(m.data.toString()),o=_._core._renderService.dimensions.actualCellWidth||9.5;console.log("data:",re,o,_),_.write(re)},U.onclose=function(m){W&&clearInterval(W),_.write(`\r
connection closed`)}},W=setInterval(function(){h.current&&h.current.send(JSON.stringify({tp:"h"}))},z),oe=d.a.subscribe("create-socket",function(K){$==K&&(h.current&&h.current.readyState===1?_.focus():E(),_.focus())}),ee=d.a.subscribe("close-socket",function(K){$===K&&(h.current&&(h.current.close(),V.current=!1,_.clear()),h.current=null)}),fe=d.a.subscribe("ssh-xterm-resize",function(K){h.current&&h.current.readyState===1&&h.current.send(JSON.stringify({tp:"resize",data:Object(Z.a)({},K)}))}),pe=d.a.subscribe("ssh-add-connect-time",function(){h.current&&h.current.readyState===1&&h.current.send(JSON.stringify({tp:"overtime"}))});return function(){ee(),oe(),fe(),pe(),h.current&&(h.current.close(),V.current=!1)}}},[_,y,k]),s.a.createElement("div",{ref:D,className:O.a["xterm-panel"]},y?null:s.a.createElement("p",{style:{color:"#fff"}},"\u6B63\u5728\u8FDE\u63A5\u547D\u4EE4\u884C\u670D\u52A1..."))}},"ER/M":function(se,l,t){se.exports={"xterm-panel":"xterm-panel___2r2xx"}},IZBM:function(se,l,t){"use strict";t.d(l,"l",function(){return ie}),t.d(l,"m",function(){return de}),t.d(l,"i",function(){return b}),t.d(l,"E",function(){return O}),t.d(l,"h",function(){return d}),t.d(l,"I",function(){return me}),t.d(l,"D",function(){return A}),t.d(l,"y",function(){return G}),t.d(l,"A",function(){return z}),t.d(l,"f",function(){return B}),t.d(l,"q",function(){return F}),t.d(l,"g",function(){return $}),t.d(l,"j",function(){return S}),t.d(l,"w",function(){return N}),t.d(l,"k",function(){return y}),t.d(l,"u",function(){return q}),t.d(l,"v",function(){return k}),t.d(l,"d",function(){return D}),t.d(l,"B",function(){return h}),t.d(l,"C",function(){return V}),t.d(l,"z",function(){return E}),t.d(l,"H",function(){return W}),t.d(l,"n",function(){return oe}),t.d(l,"o",function(){return ee}),t.d(l,"p",function(){return fe}),t.d(l,"s",function(){return pe}),t.d(l,"F",function(){return K}),t.d(l,"b",function(){return U}),t.d(l,"c",function(){return m}),t.d(l,"a",function(){return re}),t.d(l,"r",function(){return o}),t.d(l,"e",function(){return e}),t.d(l,"x",function(){return r}),t.d(l,"t",function(){return a}),t.d(l,"G",function(){return u});var Z=t("WmNS"),C=t.n(Z),Y=t("9og8"),f=t("k1fw"),s=t("ErOA"),P=t("1vsH"),ne,Q,T=((ne=Object(P.r)())===null||ne===void 0?void 0:ne.homework_common_id)?{homework_common_id:(Q=Object(P.r)())===null||Q===void 0?void 0:Q.homework_common_id}:{};function ie(n){return Object(s.c)("tasks/".concat(n,".json"),T)}function de(n){return Object(s.c)("myshixuns/".concat(n,"/challenges.json"))}function b(n,i){return Object(s.c)("myshixuns/".concat(n,"/subject_challenges.json"),i)}function O(n,i,J){return Object(s.c)("tasks/".concat(n,"/star.json?shixun_id=").concat(i,"&star=").concat(J))}function d(n,i){return Object(s.c)("tasks/".concat(n,"/rep_content.json"),Object(f.a)(Object(f.a)({},i),T))}function me(n,i){return Object(s.f)("myshixuns/".concat(n,"/update_file.json"),i)}function A(n,i){return Object(s.c)("tasks/".concat(n,"/reset_original_code.json"),Object(f.a)(Object(f.a)({},i),T))}function G(n,i){return Object(s.f)("myshixuns/".concat(n,"/reset_repository.json"),i)}function z(n,i){return Object(s.c)("tasks/".concat(n,"/reset_passed_code.json"),Object(f.a)(Object(f.a)({},i),T))}function B(n,i){return Object(s.f)("tasks/".concat(n,"/game_build.json"),Object(f.a)(Object(f.a)({},i),T))}function F(n,i){return Object(s.c)("tasks/".concat(n,"/game_status.json"),Object(f.a)(Object(f.a)({},i),T))}function $(n,i){return Object(s.f)("tasks/".concat(n,"/choose_build.json"),Object(f.a)(Object(f.a)({},i),T))}function S(n){return Object(s.c)("tasks/".concat(n,"/picture_display.json"),T)}function j(n,i){return Object(s.c)("tasks/".concat(n,"/cost_time.json"),Object(f.a)(Object(f.a)({},i),T))}function _(n,i){return Object(s.c)("courses/".concat(n,"/inform_detail.json"),i)}function N(n){return Object(s.f)("tasks/".concat(n,"/plus_or_cancel_praise.json"))}function y(n){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Object(s.f)("myshixuns/".concat(n,"/repository.json"),i)}function q(n){return Object(s.c)("myshixuns/".concat(n,"/open_webssh.json"))}function k(n,i){return Object(s.c)("myshixuns/".concat(n,"/open_vm_webssh.json"),i)}function D(n){return Object(s.c)("tasks/".concat(n,"/close_webssh.json"))}function h(n){return Object(s.c)("tasks/".concat(n,"/reset_vnc_link.json"),T)}function V(n){return Object(s.f)("tasks/".concat(n,"/reset_environment"))}function E(n,i){return Object(s.f)("tasks/".concat(n,"/reset_linux_vnc_link.json"),i||{})}function W(n){return Object(s.c)("tasks/".concat(n,"/check_test_sets.json"))}function oe(n){return Object(s.c)("tasks/".concat(n,"/get_answer_info.json"))}function ee(n){return Object(s.c)("tasks/".concat(n,"/get_choose_answer.json"))}function fe(n){return Object(s.c)("tasks/".concat(n,"/unlock_choose_answer.json"))}function pe(n,i){return Object(s.c)("tasks/".concat(n,"/unlock_answer.json?answer_id=").concat(i))}function K(n,i,J){return Object(s.f)("tasks/".concat(n,"/set_games_status.json"),{result:i,data:J})}function U(n){return Object(s.f)("tasks/".concat(n,"/extend_vnc.json"))}function m(n){return Object(s.f)("tasks/".concat(n,"/active.json"))}function re(n){return Object(s.f)("tasks/".concat(n,"/extend_linux_vnc.json"),T)}function o(n,i){return Object(s.c)("tasks/".concat(n,"/rank_list.json"),i)}function e(n,i){return Object(s.f)("tasks/".concat(n,"/close_windows_vnc.json"),{tpi_id:i})}function r(n){return Object(s.c)("tasks/".concat(n,"/pull_files.json"))}function a(n,i){return Object(s.f)("tasks/".concat(n,"/log_output"),i)}function u(n){return Object(s.c)("tasks/".concat(n,"/stop_log_output.json"))}function c(n){return v.apply(this,arguments)}function v(){return v=Object(Y.a)(C.a.mark(function n(i){return C.a.wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.abrupt("return",Object(s.a)("/api/myshixuns/".concat(i.id,"/add_file.json"),{method:"post",body:i}));case 1:case"end":return R.stop()}},n)})),v.apply(this,arguments)}function I(n){return w.apply(this,arguments)}function w(){return w=Object(Y.a)(C.a.mark(function n(i){return C.a.wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.abrupt("return",Object(s.a)("/api/myshixuns/".concat(i.id,"/delete_git_file.json"),{method:"Delete",body:i}));case 1:case"end":return R.stop()}},n)})),w.apply(this,arguments)}function p(n){return M.apply(this,arguments)}function M(){return M=Object(Y.a)(C.a.mark(function n(i){return C.a.wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.abrupt("return",Object(s.a)("/api/myshixuns/".concat(i.id,"/mv_file.json"),{method:"post",body:i}));case 1:case"end":return R.stop()}},n)})),M.apply(this,arguments)}function X(n){return ae.apply(this,arguments)}function ae(){return ae=Object(Y.a)(C.a.mark(function n(i){return C.a.wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.abrupt("return",Object(s.a)("/api/tasks/".concat(i.id,"/rep_content.json"),{method:"get",params:i}));case 1:case"end":return R.stop()}},n)})),ae.apply(this,arguments)}},IxHN:function(se,l,t){"use strict";var Z=t("q1tI"),C=t.n(Z),Y=t("07cG"),f=t.n(Y);l.a=function(s){var P=s.message,ne=s.className,Q=s.children,T=s.style,ie=T===void 0?{}:T;return C.a.createElement("div",{className:"".concat(f.a.idsRingWrapper," ").concat(ne)},C.a.createElement("div",{className:f.a.ldsRing},C.a.createElement("div",null),C.a.createElement("div",null),C.a.createElement("div",null),C.a.createElement("div",null)),P?C.a.createElement("p",{style:ie},P):null,Q)}},Lmeb:function(se,l,t){},M8RZ:function(se,l,t){"use strict";t.d(l,"a",function(){return T});var Z=t("fWQN"),C=t("mtLc"),Y=t("yKVA"),f=t("879j"),s=t("q1tI"),P=t.n(s),ne=t("i8i4"),Q=t.n(ne),T=function(ie){Object(Y.a)(b,ie);var de=Object(f.a)(b);function b(O){var d;Object(Z.a)(this,b),d=de.call(this,O);var me=window.document;return d.node=me.createElement("div"),me.body.appendChild(d.node),d}return Object(C.a)(b,[{key:"render",value:function(){var d=this.props.children;return Object(ne.createPortal)(d,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),b}(P.a.Component)},PYMJ:function(se,l,t){"use strict";t.r(l);var Z=t("k1fw"),C=t("9og8"),Y=t("tJVT"),f=t("PpiC"),s=t("q1tI"),P=t.n(s),ne=t("9kvl"),Q=t("Dqnf"),T=t("qZJd"),ie=t("Lmeb"),de=t.n(ie),b=t("dhSg"),O=t("ErOA");function d(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */d=function(){return A};var A={},G=Object.prototype,z=G.hasOwnProperty,B=typeof Symbol=="function"?Symbol:{},F=B.iterator||"@@iterator",$=B.asyncIterator||"@@asyncIterator",S=B.toStringTag||"@@toStringTag";function j(o,e,r){return Object.defineProperty(o,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),o[e]}try{j({},"")}catch(o){j=function(r,a,u){return r[a]=u}}function _(o,e,r,a){var u=e&&e.prototype instanceof q?e:q,c=Object.create(u.prototype),v=new U(a||[]);return c._invoke=function(I,w,p){var M="suspendedStart";return function(X,ae){if(M==="executing")throw new Error("Generator is already running");if(M==="completed"){if(X==="throw")throw ae;return re()}for(p.method=X,p.arg=ae;;){var n=p.delegate;if(n){var i=fe(n,p);if(i){if(i===y)continue;return i}}if(p.method==="next")p.sent=p._sent=p.arg;else if(p.method==="throw"){if(M==="suspendedStart")throw M="completed",p.arg;p.dispatchException(p.arg)}else p.method==="return"&&p.abrupt("return",p.arg);M="executing";var J=N(I,w,p);if(J.type==="normal"){if(M=p.done?"completed":"suspendedYield",J.arg===y)continue;return{value:J.arg,done:p.done}}J.type==="throw"&&(M="completed",p.method="throw",p.arg=J.arg)}}}(o,r,v),c}function N(o,e,r){try{return{type:"normal",arg:o.call(e,r)}}catch(a){return{type:"throw",arg:a}}}A.wrap=_;var y={};function q(){}function k(){}function D(){}var h={};j(h,F,function(){return this});var V=Object.getPrototypeOf,E=V&&V(V(m([])));E&&E!==G&&z.call(E,F)&&(h=E);var W=D.prototype=q.prototype=Object.create(h);function oe(o){["next","throw","return"].forEach(function(e){j(o,e,function(r){return this._invoke(e,r)})})}function ee(o,e){function r(u,c,v,I){var w=N(o[u],o,c);if(w.type!=="throw"){var p=w.arg,M=p.value;return M&&typeof M=="object"&&z.call(M,"__await")?e.resolve(M.__await).then(function(X){r("next",X,v,I)},function(X){r("throw",X,v,I)}):e.resolve(M).then(function(X){p.value=X,v(p)},function(X){return r("throw",X,v,I)})}I(w.arg)}var a;this._invoke=function(u,c){function v(){return new e(function(I,w){r(u,c,I,w)})}return a=a?a.then(v,v):v()}}function fe(o,e){var r=o.iterator[e.method];if(r===void 0){if(e.delegate=null,e.method==="throw"){if(o.iterator.return&&(e.method="return",e.arg=void 0,fe(o,e),e.method==="throw"))return y;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var a=N(r,o.iterator,e.arg);if(a.type==="throw")return e.method="throw",e.arg=a.arg,e.delegate=null,y;var u=a.arg;return u?u.done?(e[o.resultName]=u.value,e.next=o.nextLoc,e.method!=="return"&&(e.method="next",e.arg=void 0),e.delegate=null,y):u:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,y)}function pe(o){var e={tryLoc:o[0]};1 in o&&(e.catchLoc=o[1]),2 in o&&(e.finallyLoc=o[2],e.afterLoc=o[3]),this.tryEntries.push(e)}function K(o){var e=o.completion||{};e.type="normal",delete e.arg,o.completion=e}function U(o){this.tryEntries=[{tryLoc:"root"}],o.forEach(pe,this),this.reset(!0)}function m(o){if(o){var e=o[F];if(e)return e.call(o);if(typeof o.next=="function")return o;if(!isNaN(o.length)){var r=-1,a=function u(){for(;++r<o.length;)if(z.call(o,r))return u.value=o[r],u.done=!1,u;return u.value=void 0,u.done=!0,u};return a.next=a}}return{next:re}}function re(){return{value:void 0,done:!0}}return k.prototype=D,j(W,"constructor",D),j(D,"constructor",k),k.displayName=j(D,S,"GeneratorFunction"),A.isGeneratorFunction=function(o){var e=typeof o=="function"&&o.constructor;return!!e&&(e===k||(e.displayName||e.name)==="GeneratorFunction")},A.mark=function(o){return Object.setPrototypeOf?Object.setPrototypeOf(o,D):(o.__proto__=D,j(o,S,"GeneratorFunction")),o.prototype=Object.create(W),o},A.awrap=function(o){return{__await:o}},oe(ee.prototype),j(ee.prototype,$,function(){return this}),A.AsyncIterator=ee,A.async=function(o,e,r,a,u){u===void 0&&(u=Promise);var c=new ee(_(o,e,r,a),u);return A.isGeneratorFunction(e)?c:c.next().then(function(v){return v.done?v.value:c.next()})},oe(W),j(W,S,"Generator"),j(W,F,function(){return this}),j(W,"toString",function(){return"[object Generator]"}),A.keys=function(o){var e=[];for(var r in o)e.push(r);return e.reverse(),function a(){for(;e.length;){var u=e.pop();if(u in o)return a.value=u,a.done=!1,a}return a.done=!0,a}},A.values=m,U.prototype={constructor:U,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(K),!e)for(var r in this)r.charAt(0)==="t"&&z.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if(e.type==="throw")throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function a(p,M){return v.type="throw",v.arg=e,r.next=p,M&&(r.method="next",r.arg=void 0),!!M}for(var u=this.tryEntries.length-1;u>=0;--u){var c=this.tryEntries[u],v=c.completion;if(c.tryLoc==="root")return a("end");if(c.tryLoc<=this.prev){var I=z.call(c,"catchLoc"),w=z.call(c,"finallyLoc");if(I&&w){if(this.prev<c.catchLoc)return a(c.catchLoc,!0);if(this.prev<c.finallyLoc)return a(c.finallyLoc)}else if(I){if(this.prev<c.catchLoc)return a(c.catchLoc,!0)}else{if(!w)throw new Error("try statement without catch or finally");if(this.prev<c.finallyLoc)return a(c.finallyLoc)}}}},abrupt:function(e,r){for(var a=this.tryEntries.length-1;a>=0;--a){var u=this.tryEntries[a];if(u.tryLoc<=this.prev&&z.call(u,"finallyLoc")&&this.prev<u.finallyLoc){var c=u;break}}c&&(e==="break"||e==="continue")&&c.tryLoc<=r&&r<=c.finallyLoc&&(c=null);var v=c?c.completion:{};return v.type=e,v.arg=r,c?(this.method="next",this.next=c.finallyLoc,y):this.complete(v)},complete:function(e,r){if(e.type==="throw")throw e.arg;return e.type==="break"||e.type==="continue"?this.next=e.arg:e.type==="return"?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):e.type==="normal"&&r&&(this.next=r),y},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.finallyLoc===e)return this.complete(a.completion,a.afterLoc),K(a),y}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc===e){var u=a.completion;if(u.type==="throw"){var c=u.arg;K(a)}return c}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,a){return this.delegate={iterator:m(e),resultName:r,nextLoc:a},this.method==="next"&&(this.arg=void 0),y}},A}var me=function(G){var z=G.classroomList,B=G.globalSetting,F=G.loading,$=G.dispatch,S=Object(f.a)(G,["classroomList","globalSetting","loading","dispatch"]),j=Object(s.useState)({}),_=Object(Y.a)(j,2),N=_[0],y=_[1],q=Object(s.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}),k=Object(Y.a)(q,2),D=k[0],h=k[1],V=S.match.params,E=S.location.query,W;Object(s.useEffect)(function(){oe()},[]),Object(s.useEffect)(function(){N.host&&setTimeout(function(){b.a.publish("create-socket",1)},500)},[N]);var oe=function(){var ee=Object(C.a)(d().mark(function fe(){var pe;return d().wrap(function(U){for(;;)switch(U.prev=U.next){case 0:if(console.log("par\xE5ms:",V,S),!(E.type==="terminal")){U.next=6;break}return U.next=4,Object(O.a)("/api/myshixuns/".concat(E.taskId||"f3n9o5xvik","/open_webssh.json"),{method:"get"});case 4:pe=U.sent,y(Object(Z.a)({},pe));case 6:E.type==="windows";case 7:case"end":return U.stop()}},fe)}));return function(){return ee.apply(this,arguments)}}();return P.a.createElement("section",{style:{position:"fixed",width:"100%",height:"100%",zIndex:22,top:0,right:0,bottom:0,left:0}},E.type==="terminal"&&P.a.createElement(Q.a,{sshConfigData:N,sid:1}),E.type!=="terminal"&&P.a.createElement(T.a,{taskId:E.type==="windows"?"pcf9t4w6vrnz":"ijby95c82nsh",vnc_url:E.type==="vnc",window_vnc_url:E.type==="windows",taskData:D}))};l.default=Object(ne.a)(function(A){var G=A.classroomList,z=A.loading,B=A.globalSetting;return{classroomList:G,globalSetting:B,loading:z.models.classroomList}})(me)},qZJd:function(se,l,t){"use strict";var Z=t("MXD1"),C=t("CFYs"),Y=t("miYZ"),f=t("tsqr"),s=t("WmNS"),P=t.n(s),ne=t("2qtc"),Q=t("kLXV"),T=t("9og8"),ie=t("rAM+"),de=t("tJVT"),b=t("k1fw"),O=t("q1tI"),d=t.n(O),me=t("IxHN"),A=t("bdgK"),G=t("M8RZ"),z=t("Ty5D"),B=t("1vsH"),F=t("1dTM"),$=t.n(F),S=t("dhSg"),j=t("+L6B"),_=t("2/Rp"),N=t("5NDa"),y=t("5rEg"),q=t("AKST"),k=y.a.TextArea,D=function(e){var r=e.onCancel,a=e.onSave,u=e.content,c=Object(O.useState)(u),v=Object(de.a)(c,2),I=v[0],w=v[1];function p(X){w(X.target.value)}function M(){a(I)}return Object(O.useEffect)(function(){w(u)},[u]),d.a.createElement("div",{className:"clipboard-box"},d.a.createElement("h3",null,"\u5B9E\u9A8C\u73AF\u5883\u526A\u5207\u677F\uFF1A"),d.a.createElement(k,{value:I,onChange:p,className:"clipboard"}),d.a.createElement("p",null," ",d.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 "),d.a.createElement("p",null," ",d.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 "),d.a.createElement("div",{className:"btn-action-container"},d.a.createElement(_.a,{type:"ghost",onClick:r,style:{marginRight:10}},"\u53D6\u6D88"),d.a.createElement(_.a,{type:"primary",onClick:M},"\u4FDD\u5B58")))},h=t("ErOA"),V=t("IZBM"),E=t("ye1Q"),W=t("bntm"),oe=t("wd/R"),ee=t.n(oe),fe=d.a.createElement(E.a,{style:{fontSize:24},spin:!0});function pe(e){return e.replace(/\\u([\dA-Za-z]{4})/g,function(r,a){return String.fromCharCode(parseInt("0x"+a))})}function K(e){e||(e=window.location.search);var r=e.substr(1),a={};return r.split("&").forEach(function(u){var c=u.split("=");a[c[0]]=decodeURIComponent(c[1])}),a}var U={loading:!0,isLarge:!1,showClipBoardBox:!1,transferContent:"",mes:"\u5B9E\u9A8C\u73AF\u5883\u51C6\u5907\u4E2D"},m;(function(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"})(m||(m={}));function re(e,r){switch(r.type){case m.SET_LOADING:return Object(b.a)(Object(b.a)({},e),{},{loading:r.payload});case m.SET_IS_LARGE:return Object(b.a)({},Object(b.a)(Object(b.a)({},e),{},{isLarge:r.payload}));case m.SET_MES:return Object(b.a)(Object(b.a)({},e),{},{mes:r.payload});case m.SET_STATE:return Object(b.a)(Object(b.a)({},e),r.payload);case m.SET_TRANSFER_CONTENT:return Object(b.a)(Object(b.a)({},e),{},{transferContent:r.payload});case m.SHOW_CLIPBOARD_BOX:return Object(b.a)(Object(b.a)({},e),{},{showClipBoardBox:r.payload});case m.UPDATE_ALL:return Object(b.a)({loading:e.loading},r.payload);default:throw new Error}}var o=l.a=function(e){var r=e.vnc_url,a=e.window_vnc_url,u=e.linux_vnc,c=e.virtual_machine,v=e.taskId,I=Object(O.useRef)(),w=Object(O.useRef)(),p=Object(O.useRef)(),M=Object(O.useReducer)(re,U),X=Object(de.a)(M,2),ae=X[0],n=X[1],i=Object(O.useState)(0),J=Object(de.a)(i,2),R=J[0],De=J[1],Fe=ae.mes,Me=ae.loading,We=ae.showClipBoardBox,he=ae.isLarge,ke=ae.transferContent,Ke=Object(O.useState)(0),Ie=Object(de.a)(Ke,2),ve=Ie[0],Pe=Ie[1],Le=Object(O.useRef)(),xe=Object(z.m)();Object(O.useEffect)(function(){return window.addEventListener("visibilitychange",Re),function(){window.removeEventListener("visibilitychange",Re)}},[]);var Be=function(){Object(W.a)()?w.current.resizeSession=!0:setTimeout(function(){w.current.resizeSession=!1},900)};Object(O.useEffect)(function(){return window.addEventListener("visibilitychange",Re),document.addEventListener(Object(W.c)(),Be),function(){document.removeEventListener(Object(W.c)(),Be),window.removeEventListener("visibilitychange",Re)}},[]);var Re=function(H){if(document.visibilityState==="visible"){var _e=sessionStorage.vncPageLeaveTime;ee()(new Date).diff(ee()(_e),"minutes")>2&&De(new Date().getTime()),sessionStorage.removeItem("vncPageLeaveTime")}else sessionStorage.vncPageLeaveTime=new Date};function Ae(){n({type:m.SHOW_CLIPBOARD_BOX,payload:!1})}function Ge(){n({type:m.SET_IS_LARGE,payload:!he})}function ze(g){var H;return I.current&&(H=new A.default(function(_e){var ue=Object(ie.a)(_e),Ee;try{for(ue.s();!(Ee=ue.n()).done;){var L=Ee.value;(L.target.offsetHeight>0||L.target.offsetWidth>0)&&g._eventHandlers.windowResize()}}catch(ye){ue.e(ye)}finally{ue.f()}}),H.observe(I.current)),H}var Ve=function(){var g=Object(T.a)(P.a.mark(function H(){var _e,ue,Ee,L,ye;return P.a.wrap(function(x){for(;;)switch(x.prev=x.next){case 0:return Ee=((_e=K())===null||_e===void 0?void 0:_e.homework_common_id)?{homework_common_id:(ue=K())===null||ue===void 0?void 0:ue.homework_common_id}:{},x.next=3,Object(h.a)("/api/tasks/".concat(xe.taskId||v,"/get_vnc_link.json"),{method:"post",body:Object(b.a)(Object(b.a)({},xe),Ee)});case 3:if(L=x.sent,!((L==null?void 0:L.status)===-3)){x.next=6;break}return x.abrupt("return",new Promise(function(){var te=Object(T.a)(P.a.mark(function le(be,ce){return P.a.wrap(function(Oe){for(;;)switch(Oe.prev=Oe.next){case 0:Q.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 Te=Object(T.a)(P.a.mark(function we(){return P.a.wrap(function(ge){for(;;)switch(ge.prev=ge.next){case 0:return clearTimeout(Le.current),Pe(0),ge.next=4,Object(V.e)(xe.taskId,L==null?void 0:L.message);case 4:return De(R+1),ge.abrupt("return");case 6:case"end":return ge.stop()}},we)}));function Ce(){return Te.apply(this,arguments)}return Ce}()});case 1:case"end":return Oe.stop()}},le)}));return function(le,be){return te.apply(this,arguments)}}()));case 6:if(!((L==null?void 0:L.status)===-1)){x.next=8;break}throw new String(L==null?void 0:L.message);case 8:return c&&(Object(B.F)("PVEAuthCookie",L==null||((ye=L.data)===null||ye===void 0)?void 0:ye.cookies_value,1),Object(B.F)("PVELangCookie","zh_CN",1)),S.a.publish("update-windows-time",L==null?void 0:L.data),x.abrupt("return",L);case 11:case"end":return x.stop()}},H)}));return function(){return g.apply(this,arguments)}}();Object(O.useEffect)(function(){var g,H;function _e(x){a&&(f.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"),n({type:m.SET_LOADING,payload:!0}),De(R+1))}S.a.subscribe("reset-linux-windows-loading",function(){n({type:m.SET_LOADING,payload:!0})}),S.a.subscribe("reset-linux-windos-vnc",function(){De(R+1)});function ue(){Pe(100),clearTimeout(Le.current),setTimeout(function(){w.current.resizeSession=!1,n({type:m.SET_LOADING,payload:!1})},1300),S.a.subscribe("send-ctrl-alt-delete",function(){var x;(x=g)===null||x===void 0||x.sendCtrlAltDel()})}function Ee(x){var te=pe(x.detail.text);n({type:m.SET_TRANSFER_CONTENT,payload:te})}if((a||r||u||c)&&I.current){clearTimeout(Le.current),new Promise(Object(T.a)(P.a.mark(function x(){var te,le,be,ce,Se,Oe,Te,Ce,we,Ue,ge;return P.a.wrap(function(je){for(;;)switch(je.prev=je.next){case 0:return te=K(),le="",je.next=4,Ve();case 4:if(ce=je.sent,!(u||c)){je.next=11;break}return p.current.src=(ce==null||((Se=ce.data)===null||Se===void 0)?void 0:Se.vnc_url)+"&time="+Date.now(),n({type:m.SET_STATE,payload:{loading:!1,mes:"\u5B9E\u9A8C\u73AF\u5883\u91CD\u7F6E\u4E2D"}}),je.abrupt("return");case 11:a?(be="Edu123",le=decodeURIComponent(ce==null||((Oe=ce.data)===null||Oe===void 0)?void 0:Oe.vnc_url)):(Ce=new URL(decodeURIComponent(ce==null||((Te=ce.data)===null||Te===void 0)?void 0:Te.vnc_url)),we=Ce.protocol,Ue=Ce.searchParams,ge=Ce.host,be=Ue.get("password"),le="".concat(we==="https:"?"wss":"ws","://").concat(ge,"/").concat(te.path||"websockify"));case 12:g=new $.a(I.current,le,{credentials:{password:be},wsProtocols:["binary"],resize:"scale",show_dot:!0}),H=ze(g),g.viewOnly=te.view_only||!1,a?g.scaleViewport=!0:g.scaleViewport=te.scale||!1,g.scaleViewport=te.scale||!0,g.showDotCursor=!0,g.resizeSession=!0,w.current=g,g.addEventListener("disconnect",_e),g.addEventListener("connect",ue),g.addEventListener("clipboard",Ee);case 23:case"end":return je.stop()}},x)})));var L=S.a.subscribe("vnc-reseting",function(){Pe(0),n({type:m.SET_STATE,payload:{loading:!0,mes:"\u5B9E\u9A8C\u73AF\u5883\u91CD\u7F6E\u4E2D"}})}),ye=S.a.subscribe("vnc-enlarge",function(x){}),Ne=S.a.subscribe("show-clipboard-box",function(){n({type:m.SHOW_CLIPBOARD_BOX,payload:!0})});return Pe(0),function(){var x,te,le,be;(x=g)===null||x===void 0||x.removeEventListener("disconnect",_e),(te=g)===null||te===void 0||te.removeEventListener("connect",ue),(le=g)===null||le===void 0||le.removeEventListener("clipboard",Ee),L(),ye(),Ne(),(be=H)===null||be===void 0||be.unobserve(I.current)}}},[r,a,u,R]);function Xe(g){var H;(H=w.current)===null||H===void 0||H.clipboardPasteFrom(g),n({type:m.SET_TRANSFER_CONTENT,payload:g}),f.b.success("\u4FDD\u5B58\u6210\u529F\uFF01\u4F60\u53EF\u4EE5\u5728\u5B9E\u9A8C\u73AF\u5883\u4E2D\u7C98\u8D34\u8BE5\u5185\u5BB9"),Ae()}Object(O.useEffect)(function(){ve==0&&(clearTimeout(Le.current),Je())},[ve]);var Je=function g(){ve>99?ve=99:(ve=ve+1,Le.current=setTimeout(function(){g()},1500)),ve<100&&Pe(ve)},He=Object(O.useMemo)(function(){return Me?"none":u||c?"block":"none"},[u,Me,c]);return d.a.createElement(O.Fragment,null,he&&d.a.createElement("a",{className:"btn-vnc-resize",onClick:Ge},d.a.createElement("i",{className:"iconfont icon-tuichuquanping"})),d.a.createElement("iframe",{style:{display:He,position:he?"fixed":"absolute",left:0,top:he?54:40,zIndex:6,width:"100%",height:"calc(100% - ".concat(he?"100px":"45px",")")},frameBorder:"0",ref:p,allowFullScreen:!0}),d.a.createElement("div",{style:{position:he?"fixed":"absolute",left:0,top:he?54:40,zIndex:5,width:"100%",height:"calc(100% - ".concat(he?"100px":"45px",")")},className:"".concat(a?"vnc-panel-wrapper-windows":"vnc-panel-wrapper"," ").concat(he?"full-screen":"")},Me?d.a.createElement(me.a,{message:Fe,style:{color:"#0152d9"}},d.a.createElement("div",{className:"tc",style:{width:500,margin:"0 auto",color:"#FFF"}},d.a.createElement(C.a,{percent:ve,format:function(H){return d.a.createElement("span",{className:"c-white"},H,"%")}}))):null,d.a.createElement("div",{ref:I,className:"vnc-panel ".concat(Me?"hidden zIndexf1":"animated fadeIn")})),d.a.createElement(G.a,null,d.a.createElement(Q.a,{title:"\u590D\u5236\u7C98\u8D34",centered:!0,maskClosable:!1,visible:We,onCancel:Ae,footer:null},d.a.createElement(D,{onCancel:Ae,onSave:Xe,content:ke}))))}}}]);