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__.25f97228.asyn...

162 lines
44 KiB

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