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