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

1 line
44 KiB

(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[189],{"07cG":function(t,e,n){t.exports={ldsRing:"ldsRing___2F8W7",idsRingWrapper:"idsRingWrapper___fC2cF",ldsring:"ldsring___3A88y"}},AKST:function(t,e,n){},Dqnf:function(t,e,n){"use strict";var r=n("k1fw"),o=n("tJVT"),a=n("rAM+"),i=n("q1tI"),c=n.n(i),s=n("J66h"),u=n("/POA"),l=(n("q7KB"),n("dhSg")),f=n("bdgK");function p(t,e,n){var r=n._core._renderService.dimensions.actualCellWidth||9.5,o=n._core._renderService.dimensions.actualCellHeight||18,a=Math.floor(e/o),i=Math.floor(t/r);return[i,a]}function d(t,e){var n=new f["default"]((function(e){var n,r=Object(a["a"])(e);try{for(r.s();!(n=r.n()).done;){var i=n.value;if(i.target.offsetHeight>0||i.target.offsetWidth>0){var c=p(i.target.offsetWidth,i.target.offsetHeight,t),s=Object(o["a"])(c,2),u=s[0],f=s[1];console.log("cols, rows",u,f),t.resize(u,f),l["a"].publish("ssh-xterm-resize",{columns:u,rows:f,width:i.target.offsetWidth,height:i.target.offsetHeight})}}}catch(d){r.e(d)}finally{r.f()}}));return n.observe(e),n}var h=3e4;e["a"]=function(t){var e=t.sshConfigData,n=t.sid,a=Object(i["useState"])(null),f=Object(o["a"])(a,2),p=f[0],m=f[1],y=e.ws_url,v=e.password,_=e.port,b=Object(i["useRef"])(),g=Object(i["useRef"])(),w=Object(i["useRef"])(!1);return Object(i["useEffect"])((function(){if(b.current&&y){var t=new u["Terminal"]({fontSize:16,rendererType:"dom"});t.open(b.current),t.onData((function(t){g.current&&1===g.current.readyState&&(g.current.send(JSON.stringify({tp:"client",data:t})),l["a"].publish("on-operating-ssh"))})),t.write("Connecting..."),m(t);var e=d(t,b.current);return function(){t.dispose(),e.unobserve(b.current)}}}),[y,b.current]),Object(i["useEffect"])((function(){if(p&&y){var t=function(){var t=new WebSocket(y);g.current=t,t.onopen=function(){var n=p.element.parentElement;if(n){var o=n.offsetWidth,a=n.offsetHeight;console.log("init",{tp:"init",data:Object(r["a"])(Object(r["a"])({},e),{},{secret:v,width:o,height:a,rows:p.rows,columns:p.cols})}),t.send(JSON.stringify({tp:"init",data:Object(r["a"])(Object(r["a"])({},e),{},{secret:v,width:o,height:a,rows:p.rows,columns:p.cols})}))}p.focus()},t.onerror=function(e){console.log("------in socket error----",e,t,y)},t.onmessage=function(t){w.current||(p.write("\r"),setTimeout((function(){}),1e3)),w.current=!0,console.log("event:",t);var e=s["Base64"].decode(t.data.toString()),n=p._core._renderService.dimensions.actualCellWidth||9.5;console.log("data:",e,n,p),p.write(e)},t.onclose=function(t){o&&clearInterval(o),p.write("\r\nconnection closed")}},o=setInterval((function(){g.current&&g.current.send(JSON.stringify({tp:"h"}))}),h),a=l["a"].subscribe("create-socket",(function(e){n===e&&(g.current&&1===g.current.readyState?p.focus():t(),p.focus())})),i=l["a"].subscribe("close-socket",(function(t){n===t&&(g.current&&(g.current.close(),w.current=!1,p.clear()),g.current=null)})),c=l["a"].subscribe("ssh-xterm-resize",(function(t){g.current&&1===g.current.readyState&&g.current.send(JSON.stringify({tp:"resize",data:Object(r["a"])({},t)}))})),u=l["a"].subscribe("ssh-add-connect-time",(function(){g.current&&1===g.current.readyState&&g.current.send(JSON.stringify({tp:"overtime"}))}));return function(){i(),a(),c(),u(),g.current&&(g.current.close(),w.current=!1)}}}),[p,y,_]),c.a.createElement("div",{ref:b,className:"xterm-panel"},y?null:c.a.createElement("p",{style:{color:"#fff"}},"\u6b63\u5728\u8fde\u63a5\u547d\u4ee4\u884c\u670d\u52a1..."))}},IZBM:function(t,e,n){"use strict";n.d(e,"j",(function(){return o})),n.d(e,"k",(function(){return a})),n.d(e,"y",(function(){return i})),n.d(e,"g",(function(){return c})),n.d(e,"B",(function(){return s})),n.d(e,"x",(function(){return u})),n.d(e,"t",(function(){return l})),n.d(e,"u",(function(){return f})),n.d(e,"e",(function(){return p})),n.d(e,"o",(function(){return d})),n.d(e,"f",(function(){return h})),n.d(e,"h",(function(){return m})),n.d(e,"s",(function(){return y})),n.d(e,"i",(function(){return v})),n.d(e,"r",(function(){return _})),n.d(e,"c",(function(){return b})),n.d(e,"v",(function(){return g})),n.d(e,"w",(function(){return w})),n.d(e,"A",(function(){return j})),n.d(e,"l",(function(){return O})),n.d(e,"m",(function(){return E})),n.d(e,"n",(function(){return k})),n.d(e,"q",(function(){return x})),n.d(e,"z",(function(){return S})),n.d(e,"a",(function(){return L})),n.d(e,"b",(function(){return T})),n.d(e,"p",(function(){return N})),n.d(e,"d",(function(){return A}));var r=n("ErOA");function o(t,e){return Object(r["c"])("tasks/".concat(t,".json"),e||{})}function a(t){return Object(r["c"])("myshixuns/".concat(t,"/challenges.json"))}function i(t,e,n){return Object(r["c"])("tasks/".concat(t,"/star.json?shixun_id=").concat(e,"&star=").concat(n))}function c(t,e){return Object(r["c"])("tasks/".concat(t,"/rep_content.json"),e)}function s(t,e){return Object(r["f"])("myshixuns/".concat(t,"/update_file.json"),e)}function u(t,e){return Object(r["c"])("tasks/".concat(t,"/reset_original_code.json"),e)}function l(t,e){return Object(r["f"])("myshixuns/".concat(t,"/reset_repository.json"),e)}function f(t,e){return Object(r["c"])("tasks/".concat(t,"/reset_passed_code.json"),e)}function p(t,e){return Object(r["f"])("tasks/".concat(t,"/game_build.json"),e)}function d(t,e){return Object(r["c"])("tasks/".concat(t,"/game_status.json"),e)}function h(t,e){return Object(r["f"])("tasks/".concat(t,"/choose_build.json"),e)}function m(t){return Object(r["c"])("tasks/".concat(t,"/picture_display.json"))}function y(t){return Object(r["f"])("tasks/".concat(t,"/plus_or_cancel_praise.json"))}function v(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return Object(r["f"])("myshixuns/".concat(t,"/repository.json"),e)}function _(t){return Object(r["c"])("myshixuns/".concat(t,"/open_webssh.json"))}function b(t){return Object(r["c"])("tasks/".concat(t,"/close_webssh.json"))}function g(t){return Object(r["c"])("tasks/".concat(t,"/reset_vnc_link.json"))}function w(t){return Object(r["f"])("tasks/".concat(t,"/reset_windows_vnc_link.json"))}function j(t){return Object(r["c"])("tasks/".concat(t,"/check_test_sets.json"))}function O(t){return Object(r["c"])("tasks/".concat(t,"/get_answer_info.json"))}function E(t){return Object(r["c"])("tasks/".concat(t,"/get_choose_answer.json"))}function k(t){return Object(r["c"])("tasks/".concat(t,"/unlock_choose_answer.json"))}function x(t,e){return Object(r["c"])("tasks/".concat(t,"/unlock_answer.json?answer_id=").concat(e))}function S(t,e,n){return Object(r["f"])("tasks/".concat(t,"/set_games_status.json"),{result:e,data:n})}function L(t){return Object(r["f"])("tasks/".concat(t,"/extend_vnc.json"))}function T(t){return Object(r["f"])("tasks/".concat(t,"/extend_windows_vnc.json"))}function N(t,e){return Object(r["c"])("tasks/".concat(t,"/rank_list.json"),e)}function A(t,e){return Object(r["f"])("tasks/".concat(t,"/close_windows_vnc.json"),{tpi_id:e})}},IxHN:function(t,e,n){"use strict";var r=n("q1tI"),o=n.n(r),a=n("07cG"),i=n.n(a);e["a"]=function(t){var e=t.message,n=t.className,r=t.children,a=t.style,c=void 0===a?{}:a;return o.a.createElement("div",{className:"".concat(i.a.idsRingWrapper," ").concat(n)},o.a.createElement("div",{className:i.a.ldsRing},o.a.createElement("div",null),o.a.createElement("div",null),o.a.createElement("div",null),o.a.createElement("div",null)),e?o.a.createElement("p",{style:c},e):null,r)}},Lmeb:function(t,e,n){},M8RZ:function(t,e,n){"use strict";n.d(e,"a",(function(){return l}));var r=n("fWQN"),o=n("mtLc"),a=n("yKVA"),i=n("879j"),c=n("q1tI"),s=n.n(c),u=n("i8i4"),l=function(t){Object(a["a"])(n,t);var e=Object(i["a"])(n);function n(t){var o;Object(r["a"])(this,n),o=e.call(this,t);var a=window.document;return o.node=a.createElement("div"),a.body.appendChild(o.node),o}return Object(o["a"])(n,[{key:"render",value:function(){var t=this.props.children;return Object(u["createPortal"])(t,this.node)}},{key:"componentWillUnmount",value:function(){window.document.body.removeChild(this.node)}}]),n}(s.a.Component)},PYMJ:function(t,e,n){"use strict";n.r(e);var r=n("k1fw"),o=n("9og8"),a=n("tJVT"),i=n("PpiC"),c=n("q1tI"),s=n.n(c),u=n("9kvl"),l=n("Dqnf"),f=n("qZJd"),p=(n("Lmeb"),n("dhSg")),d=n("ErOA");function h(){h=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(T){s=function(t,e,n){return t[e]=n}}function u(t,e,n,o){var a=e&&e.prototype instanceof p?e:p,i=Object.create(a.prototype),c=new x(o||[]);return r(i,"_invoke",{value:j(t,n,c)}),i}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(T){return{type:"throw",arg:T}}}t.wrap=u;var f={};function p(){}function d(){}function m(){}var y={};s(y,a,(function(){return this}));var v=Object.getPrototypeOf,_=v&&v(v(S([])));_&&_!==e&&n.call(_,a)&&(y=_);var b=m.prototype=p.prototype=Object.create(y);function g(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function o(r,a,i,c){var s=l(t[r],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,i,c)}),(function(t){o("throw",t,i,c)})):e.resolve(f).then((function(t){u.value=t,i(u)}),(function(t){return o("throw",t,i,c)}))}c(s.arg)}var a;r(this,"_invoke",{value:function(t,n){function r(){return new e((function(e,r){o(t,n,e,r)}))}return a=a?a.then(r,r):r()}})}function j(t,e,n){var r="suspendedStart";return function(o,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw a;return L()}for(n.method=o,n.arg=a;;){var i=n.delegate;if(i){var c=O(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=l(t,e,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}function O(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var a=o.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return d.prototype=m,r(b,"constructor",{value:m,configurable:!0}),r(m,"constructor",{value:d,configurable:!0}),d.displayName=s(m,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,s(t,c,"GeneratorFunction")),t.prototype=Object.create(b),t},t.awrap=function(t){return{__await:t}},g(w.prototype),s(w.prototype,i,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,r,o,a){void 0===a&&(a=Promise);var i=new w(u(e,n,r,o),a);return t.isGeneratorFunction(n)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(b),s(b,c,"Generator"),s(b,a,(function(){return this})),s(b,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=S,x.prototype={constructor:x,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(k),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return i.type="throw",i.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),k(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;k(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}var m=function(t){t.classroomList,t.globalSetting,t.loading,t.dispatch;var e=Object(i["a"])(t,["classroomList","globalSetting","loading","dispatch"]),n=Object(c["useState"])({}),u=Object(a["a"])(n,2),m=u[0],y=u[1],v=Object(c["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]\n\n---\n####\u4efb\u52a1\u63cf\u8ff0\n\n\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\n\n\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\n\n\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\n\n####\u76f8\u5173\u77e5\u8bc6\n\n#####\u5143\u7ec4\u4e0e\u5217\u8868\n\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\n\n#####\u521b\u5efa\u5143\u7ec4\n\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\n\n`menu1 = ('meat','fish','chicken')`\n`menu2 = ('meat',)`\n**![,](/api/attachments/386428)**\n#####\u8bbf\u95ee\u5143\u7ec4\n\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:\n\n```python\nmenu = ('meat','fish','chicken','carrot')\nprint(menu[0])\nprint(menu[1:3])\n```\n\n\u8f93\u51fa\u7ed3\u679c\uff1a\n\n`meat`\n`('fish', 'chicken')`\n\n#####\u4fee\u6539\u5143\u7ec4\n\n\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\n\n```python\nmenu = ('meat','fish','chicken','carrot')\nmenu[0] = 'pizza'\nprint(menu[0])\n```\n\n\u8f93\u51fa\u7ed3\u679c\uff1a\n\n`TypeError: 'tuple' object does not support item assignment`\n\n\u7cfb\u7edf\u4f1a\u81ea\u52a8\u62a5\u9519\uff0c\u5143\u7ec4\u4e2d\u7684\u5143\u7d20\u503c\u4e0d\u652f\u6301\u4fee\u6539\u3002\n\n#####\u5143\u7ec4\u5185\u7f6e\u51fd\u6570\n\n\u5143\u7ec4\u548c\u5217\u8868\u4e00\u6837\uff0c\u90fd\u6709\u4e00\u4e9b\u5185\u7f6e\u51fd\u6570\u65b9\u4fbf\u7f16\u7a0b\u3002\u4f8b\u5982\uff1a\n\n`len(tuple)`\uff1a\u8ba1\u7b97\u5143\u7ec4\u4e2d\u5143\u7d20\u4e2a\u6570\u3002\n\n`max(tuple)`\uff1a\u8fd4\u56de\u5143\u7ec4\u4e2d\u5143\u7d20\u7684\u6700\u5927\u503c\u3002\n\n`min(tuple)`\uff1a\u8fd4\u56de\u5143\u7ec4\u4e2d\u5143\u7d20\u7684\u6700\u5c0f\u503c\u3002\n\n`tuple(seq)`\uff1a\u5c06\u5217\u8868\u8f6c\u6362\u4e3a\u5143\u7ec4\u3002\n\n\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\n\n####\u7f16\u7a0b\u8981\u6c42\n\n\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\n\n- \u5c06\u8f93\u5165\u7684\u83dc\u5355menu_list\u8f6c\u6362\u4e3a\u5143\u7ec4\u7c7b\u578b\n- \u6253\u5370\u8f93\u51fa\u751f\u6210\u7684\u5143\u7ec4\n- \u6253\u5370\u8f93\u51fa\u5143\u7ec4\u4e2d\u9996\u5b57\u6bcd\u6700\u5927\u7684\u5143\u7d20\n\n\u672c\u5173\u6d89\u53ca\u7684\u4ee3\u7801\u6587\u4ef6`src/Step1/menu_test.py`\u7684\u4ee3\u7801\u6846\u67b6\u5982\u4e0b\uff1a\n\n```python\n# coding=utf-8\n\n# \u521b\u5efa\u5e76\u521d\u59cb\u5316munu_list\u5217\u8868\nmenu_list = []\nwhile True:\n\ttry:\n\t\tfood = input()\n\t\tmenu_list.append(food)\n\texcept:\n\t\tbreak\n\n# \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\n###### Begin ######\n\n\n\n\n####### End #######\n```\n\n####\u6d4b\u8bd5\u8bf4\u660e\n\n\u672c\u5173\u7684\u6d4b\u8bd5\u6587\u4ef6\u662f`src/Step1/menu_test.py`\uff0c\u6d4b\u8bd5\u8fc7\u7a0b\u5982\u4e0b\uff1a\n\n1. \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\n3. \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\n\n\u4ee5\u4e0b\u662f\u5e73\u53f0\u5bf9`src/Step1/menu_test.py`\u7684\u6837\u4f8b\u6d4b\u8bd5\u96c6\uff1a\n\n\u6d4b\u8bd5\u8f93\u5165\uff1a\n`beef`\n`veal`\n`lamb`\n`pork`\n\u9884\u671f\u8f93\u51fa\uff1a\n`('beef', 'veal', 'lamb', 'pork')`\n`veal`\n\n\u6d4b\u8bd5\u8f93\u5165\uff1a\n`duck`\n`broth`\n`fish`\n`macaroni`\n\u9884\u671f\u8f93\u51fa\uff1a\n`('duck', 'broth', 'fish', 'macaroni')`\n`macaroni`\n\n\u5f00\u59cb\u4f60\u7684\u4efb\u52a1\u5427\uff0c\u795d\u4f60\u6210\u529f\uff01\n\n\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\n\n![](/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\n\u7a0b\u5e8f\u8bbe\u8ba1\u3001\u7f51\u7edc\u722c\u866b\u3001\u56fe\u50cf\u5904\u7406\u3001\u5927\u6570\u636e\u3001\u4eba\u5de5\u667a\u80fd\r\n##### \u5305\u542b\u7684\u70ed\u95e8\u5e93\r\nbasemap;beautifulsoup4;Django;Flask;Keras;matplotlib;numpy;opencv;pip;PyMySQL;Scrapy;tensorflow;torch;pandas;tensorboard;requests;scikit-learn\r\n##### \u5df2\u5b89\u88c5\u5e93\u5217\u8868\uff1a\r\nabsl-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\nch icken\nca rrot\nturkey\nbanana",output:"('piz za', 'chicken', 'carrot', 'turkey', 'banana')\nturkey\n",actual_output:null,compile_success:null,ts_time:null,ts_mem:null},{is_public:!0,result:null,input:"potato\r\nagaric\r\nbeet\r\ntomato",output:"('potato', 'agaric', 'beet', 'tomato')\ntomato\n",actual_output:null,compile_success:null,ts_time:null,ts_mem:null},{is_public:!1,result:null,input:"Spring Rolls\r\nLobster slices\r\nFried Wonton\r\nFried seaweed\r\nShrimp stoast\r\nWonton soup\r\nshark fin soup",output:"('Spring Rolls', 'Lobster slices', 'Fried Wonton', 'Fried seaweed', 'Shrimp stoast', 'Wonton soup', 'shark fin soup')\nshark fin soup\n",actual_output:null,compile_success:null,ts_time:null,ts_mem:null},{is_public:!1,result:null,input:"turkey\r\nduck\r\nagaric\r\nlamb",output:"('turkey', 'duck', 'agaric', 'lamb')\nturkey\n",actual_output:null,compile_success:null,ts_time:null,ts_mem:null},{is_public:!1,result:null,input:"Fried seaweed",output:"('Fried seaweed',)\nFried seaweed\n",actual_output:null,compile_success:null,ts_time:null,ts_mem:null}],allowed_unlock:!0,test_sets_count:null,sets_error_count:null}),_=Object(a["a"])(v,2),b=_[0],g=(_[1],e.match.params),w=e.location.query;Object(c["useEffect"])((function(){j()}),[]),Object(c["useEffect"])((function(){m.host&&setTimeout((function(){p["a"].publish("create-socket",1)}),500)}),[m]);var j=function(){var t=Object(o["a"])(h().mark((function t(){var n;return h().wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(console.log("par\xe5ms:",g,e),"terminal"!==w.type){t.next=6;break}return t.next=4,Object(d["a"])("/api/myshixuns/".concat(w.taskId||"f3n9o5xvik","/open_webssh.json"),{method:"get"});case 4:n=t.sent,y(Object(r["a"])({},n));case 6:w.type;case 7:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return s.a.createElement("section",{style:{position:"fixed",width:"100%",height:"100%",zIndex:22,top:0,right:0,bottom:0,left:0}},"terminal"===w.type&&s.a.createElement(l["a"],{sshConfigData:m,sid:1}),"terminal"!==w.type&&s.a.createElement(f["a"],{taskId:"windows"===w.type?"pcf9t4w6vrnz":"ijby95c82nsh",vnc_url:"vnc"===w.type,window_vnc_url:"windows"===w.type,taskData:b}))};e["default"]=Object(u["a"])((function(t){var e=t.classroomList,n=t.loading,r=t.globalSetting;return{classroomList:e,globalSetting:r,loading:n.models.classroomList}}))(m)},dhSg:function(t,e,n){"use strict";function r(t){var e={},n={subscribe:function(t,n){return e[t]||(e[t]=[]),e[t].push(n),this.unsubscribe.bind(null,t,n)},unsubscribe:function(t,n){var r=e[t],o=-1;if(r){for(var a=0;a<r.length;a++)if(r[a].name===n.name){o=a;break}if(o>=0)return e[t].splice(o,1),!0}return!1},publish:function(t){if(!e[t])return!1;var n=Array.prototype.slice.call(arguments,1);return e[t].forEach((function(t){t.apply(null,n)})),this}};return t?Object.assign(t,n):n}var o=new r;e["a"]=o},qZJd:function(t,e,n){"use strict";n("MXD1");var r=n("CFYs"),o=(n("miYZ"),n("tsqr")),a=(n("2qtc"),n("kLXV")),i=n("9og8"),c=n("rAM+"),s=n("tJVT"),u=n("k1fw"),l=n("q1tI"),f=n.n(l),p=n("IxHN"),d=n("bdgK"),h=n("M8RZ"),m=n("Ty5D"),y=n("1dTM"),v=n.n(y),_=n("dhSg"),b=(n("+L6B"),n("2/Rp")),g=(n("5NDa"),n("5rEg")),w=(n("AKST"),g["a"].TextArea),j=function(t){var e=t.onCancel,n=t.onSave,r=t.content,o=Object(l["useState"])(r),a=Object(s["a"])(o,2),i=a[0],c=a[1];function u(t){c(t.target.value)}function p(){n(i)}return Object(l["useEffect"])((function(){c(r)}),[r]),f.a.createElement("div",{className:"clipboard-box"},f.a.createElement("h3",null,"\u5b9e\u9a8c\u73af\u5883\u526a\u5207\u677f\uff1a"),f.a.createElement(w,{value:i,onChange:u,className:"clipboard"}),f.a.createElement("p",null," ",f.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 "),f.a.createElement("p",null," ",f.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 "),f.a.createElement("div",{className:"btn-action-container"},f.a.createElement(b["a"],{type:"ghost",onClick:e,style:{marginRight:10}},"\u53d6\u6d88"),f.a.createElement(b["a"],{type:"primary",onClick:p},"\u4fdd\u5b58")))},O=n("ErOA"),E=n("IZBM"),k=n("ye1Q");function x(){x=function(){return t};var t={},e=Object.prototype,n=e.hasOwnProperty,r=Object.defineProperty||function(t,e,n){t[e]=n.value},o="function"==typeof Symbol?Symbol:{},a=o.iterator||"@@iterator",i=o.asyncIterator||"@@asyncIterator",c=o.toStringTag||"@@toStringTag";function s(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{s({},"")}catch(T){s=function(t,e,n){return t[e]=n}}function u(t,e,n,o){var a=e&&e.prototype instanceof p?e:p,i=Object.create(a.prototype),c=new k(o||[]);return r(i,"_invoke",{value:w(t,n,c)}),i}function l(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(T){return{type:"throw",arg:T}}}t.wrap=u;var f={};function p(){}function d(){}function h(){}var m={};s(m,a,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==e&&n.call(v,a)&&(m=v);var _=h.prototype=p.prototype=Object.create(m);function b(t){["next","throw","return"].forEach((function(e){s(t,e,(function(t){return this._invoke(e,t)}))}))}function g(t,e){function o(r,a,i,c){var s=l(t[r],t,a);if("throw"!==s.type){var u=s.arg,f=u.value;return f&&"object"==typeof f&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,i,c)}),(function(t){o("throw",t,i,c)})):e.resolve(f).then((function(t){u.value=t,i(u)}),(function(t){return o("throw",t,i,c)}))}c(s.arg)}var a;r(this,"_invoke",{value:function(t,n){function r(){return new e((function(e,r){o(t,n,e,r)}))}return a=a?a.then(r,r):r()}})}function w(t,e,n){var r="suspendedStart";return function(o,a){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw a;return L()}for(n.method=o,n.arg=a;;){var i=n.delegate;if(i){var c=j(i,n);if(c){if(c===f)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=l(t,e,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}function j(t,e){var n=e.method,r=t.iterator[n];if(void 0===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=void 0,j(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),f;var o=l(r,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var a=o.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function E(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function k(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function S(t){if(t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var r=-1,o=function e(){for(;++r<t.length;)if(n.call(t,r))return e.value=t[r],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:L}}function L(){return{value:void 0,done:!0}}return d.prototype=h,r(_,"constructor",{value:h,configurable:!0}),r(h,"constructor",{value:d,configurable:!0}),d.displayName=s(h,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,s(t,c,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},b(g.prototype),s(g.prototype,i,(function(){return this})),t.AsyncIterator=g,t.async=function(e,n,r,o,a){void 0===a&&(a=Promise);var i=new g(u(e,n,r,o),a);return t.isGeneratorFunction(n)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},b(_),s(_,c,"Generator"),s(_,a,(function(){return this})),s(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),n=[];for(var r in e)n.push(r);return n.reverse(),function t(){for(;n.length;){var r=n.pop();if(r in e)return t.value=r,t.done=!1,t}return t.done=!0,t}},t.values=S,k.prototype={constructor:k,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(E),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function r(n,r){return i.type="throw",i.arg=t,e.next=n,r&&(e.method="next",e.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),s=n.call(a,"finallyLoc");if(c&&s){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),E(n),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var r=n.completion;if("throw"===r.type){var o=r.arg;E(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:S(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),f}},t}k["a"];function S(t){return t.replace(/\\u([\dA-Za-z]{4})/g,(function(t,e){return String.fromCharCode(parseInt("0x"+e))}))}function L(t){t||(t=window.location.search);var e=t.substr(1),n={};return e.split("&").forEach((function(t){var e=t.split("=");n[e[0]]=decodeURIComponent(e[1])})),n}var T,N={loading:!0,isLarge:!1,showClipBoardBox:!1,transferContent:"",mes:"\u5b9e\u9a8c\u73af\u5883\u51c6\u5907\u4e2d"};function A(t,e){switch(e.type){case T.SET_LOADING:return Object(u["a"])(Object(u["a"])({},t),{},{loading:e.payload});case T.SET_IS_LARGE:return Object(u["a"])(Object(u["a"])({},t),{},{isLarge:e.payload});case T.SET_MES:return Object(u["a"])(Object(u["a"])({},t),{},{mes:e.payload});case T.SET_STATE:return Object(u["a"])(Object(u["a"])({},t),e.payload);case T.SET_TRANSFER_CONTENT:return Object(u["a"])(Object(u["a"])({},t),{},{transferContent:e.payload});case T.SHOW_CLIPBOARD_BOX:return Object(u["a"])(Object(u["a"])({},t),{},{showClipBoardBox:e.payload});default:throw new Error}}(function(t){t[t["SET_LOADING"]=0]="SET_LOADING",t[t["SET_IS_LARGE"]=1]="SET_IS_LARGE",t[t["SET_MES"]=2]="SET_MES",t[t["SET_STATE"]=3]="SET_STATE",t[t["SHOW_CLIPBOARD_BOX"]=4]="SHOW_CLIPBOARD_BOX",t[t["SET_TRANSFER_CONTENT"]=5]="SET_TRANSFER_CONTENT"})(T||(T={}));e["a"]=function(t){var e,n=t.vnc_url,y=t.window_vnc_url,b=t.taskId,g=Object(l["useRef"])(),w=Object(l["useRef"])(),k=Object(l["useReducer"])(A,N),C=Object(s["a"])(k,2),P=C[0],I=C[1],R=Object(l["useState"])(0),F=Object(s["a"])(R,2),z=F[0],G=F[1],W=P.mes,D=P.loading,q=P.showClipBoardBox,B=P.isLarge,M=P.transferContent,J=Object(l["useState"])(0),H=Object(s["a"])(J,2),K=H[0],V=H[1],X=Object(m["m"])();function Y(){I({type:T.SHOW_CLIPBOARD_BOX,payload:!1})}function Z(){I({type:T.SET_IS_LARGE,payload:!B})}function Q(t){var e;return g.current&&(e=new d["default"]((function(e){var n,r=Object(c["a"])(e);try{for(r.s();!(n=r.n()).done;){var o=n.value;(o.target.offsetHeight>0||o.target.offsetWidth>0)&&t._eventHandlers.windowResize()}}catch(a){r.e(a)}finally{r.f()}})),e.observe(g.current)),e}var U=function(){var t=Object(i["a"])(x().mark((function t(){var n;return x().wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,Object(O["a"])("/api/tasks/".concat(X.taskId||b,"/get_vnc_link.json"),{method:"post",params:Object(u["a"])({},X)});case 2:if(n=t.sent,-3!==(null===n||void 0===n?void 0:n.status)){t.next=5;break}return t.abrupt("return",new Promise(function(){var t=Object(i["a"])(x().mark((function t(r,o){return x().wrap((function(t){while(1)switch(t.prev=t.next){case 0:a["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 t=Object(i["a"])(x().mark((function t(){return x().wrap((function(t){while(1)switch(t.prev=t.next){case 0:return clearTimeout(e),V(0),t.next=4,Object(E["d"])(X.taskId,null===n||void 0===n?void 0:n.message);case 4:return U(),t.abrupt("return");case 6:case"end":return t.stop()}}),t)})));function r(){return t.apply(this,arguments)}return r}()});case 1:case"end":return t.stop()}}),t)})));return function(e,n){return t.apply(this,arguments)}}()));case 5:if(-1!==(null===n||void 0===n?void 0:n.status)){t.next=7;break}throw new String(null===n||void 0===n?void 0:n.message);case 7:return _["a"].publish("update-windows-time",null===n||void 0===n?void 0:n.data),t.abrupt("return",n);case 9:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();function $(t){var e;null===(e=w.current)||void 0===e||e.clipboardPasteFrom(t),I({type:T.SET_TRANSFER_CONTENT,payload:t}),o["b"].success("\u4fdd\u5b58\u6210\u529f\uff01\u4f60\u53ef\u4ee5\u5728\u5b9e\u9a8c\u73af\u5883\u4e2d\u7c98\u8d34\u8be5\u5185\u5bb9"),Y()}Object(l["useEffect"])((function(){var t,r;function a(t){y&&(o["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"),I({type:T.SET_LOADING,payload:!0}),G(z+1))}function c(){clearTimeout(e),V(100),setTimeout((function(){I({type:T.SET_LOADING,payload:!1})}),1300),_["a"].subscribe("send-ctrl-alt-delete",(function(){var e;null===(e=t)||void 0===e||e.sendCtrlAltDel()}))}function s(t){var e=S(t.detail.text);I({type:T.SET_TRANSFER_CONTENT,payload:e})}if((y||n)&&g.current){new Promise(Object(i["a"])(x().mark((function e(){var n,o,i,u,l,f,p,d,h,m;return x().wrap((function(e){while(1)switch(e.prev=e.next){case 0:return n=L(),o="",e.next=4,U();case 4:u=e.sent,y?(i="Edu123",o=decodeURIComponent(null===u||void 0===u||null===(l=u.data)||void 0===l?void 0:l.vnc_url)):(p=new URL(null===u||void 0===u||null===(f=u.data)||void 0===f?void 0:f.vnc_url),d=p.protocol,h=p.searchParams,m=p.host,i=h.get("password"),o="".concat("https:"===d?"wss":"ws","://").concat(m,"/").concat(n.path||"websockify")),t=new v.a(g.current,o,{credentials:{password:i},wsProtocols:["binary"]}),r=Q(t),t.viewOnly=n.view_only||!1,t.scaleViewport=!!y||(n.scale||!1),t.scaleViewport=n.scale||!0,t.resizeSession=!0,w.current=t,t.addEventListener("disconnect",a),t.addEventListener("connect",c),t.addEventListener("clipboard",s);case 16:case"end":return e.stop()}}),e)}))));var u=_["a"].subscribe("vnc-reseting",(function(){I({type:T.SET_STATE,payload:{loading:!0,mes:"\u5b9e\u9a8c\u73af\u5883\u91cd\u7f6e\u4e2d"}})})),l=_["a"].subscribe("vnc-enlarge",(function(){I({type:T.SET_IS_LARGE,payload:!0})})),f=_["a"].subscribe("show-clipboard-box",(function(){I({type:T.SHOW_CLIPBOARD_BOX,payload:!0})}));return V(0),function(){var e,n,o,i;null===(e=t)||void 0===e||e.removeEventListener("disconnect",a),null===(n=t)||void 0===n||n.removeEventListener("connect",c),null===(o=t)||void 0===o||o.removeEventListener("clipboard",s),u(),l(),f(),null===(i=r)||void 0===i||i.unobserve(g.current)}}}),[n,y,z]),Object(l["useEffect"])((function(){0==K&&tt()}),[K]);var tt=function t(){K>99?K=99:(K+=1,e=setTimeout((function(){t()}),1500)),K<100&&V(K)};return f.a.createElement(l["Fragment"],null,f.a.createElement("div",{className:"".concat(y?"vnc-panel-wrapper-windows":"vnc-panel-wrapper"," ").concat(B?"full-screen":"")},B&&f.a.createElement("a",{className:"btn-vnc-resize",onClick:Z},f.a.createElement("i",{className:"iconfont icon-tuichuquanping"})),D?f.a.createElement(p["a"],{message:W,style:{color:"#4CACFF"}},f.a.createElement("div",{className:"tc",style:{width:500,margin:"0 auto",color:"#FFF"}},f.a.createElement(r["a"],{percent:K,format:function(t){return f.a.createElement("span",{className:"c-white"},t,"%")}}))):null,f.a.createElement("div",{ref:g,className:"vnc-panel ".concat(D?"hide":"animated fadeIn")})),f.a.createElement(h["a"],null,f.a.createElement(a["a"],{title:"\u590d\u5236\u7c98\u8d34",centered:!0,maskClosable:!1,visible:q,onCancel:Y,footer:null},f.a.createElement(j,{onCancel:Y,onSave:$,content:M}))))}}}]);