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__.89aa18e1.asyn...

162 lines
47 KiB

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