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.
2 lines
11 KiB
2 lines
11 KiB
(window.webpackJsonp=window.webpackJsonp||[]).push([[140],{X0ci:function(Z,F,c){},rmrE:function(Z,F,c){},ymAh:function(Z,F,c){"use strict";c.r(F),c.d(F,"Types",function(){return N});var mt=c("T2oS"),rt=c("W9HT"),dt=c("P2fV"),nt=c("NJEC"),ht=c("+L6B"),q=c("2/Rp"),J=c("9og8"),at=c("tJVT"),B=c("k1fw"),H=c("q1tI"),i=c.n(H),tt=c("Ty5D"),V=c("55Ip"),Y=c("ErOA"),ot=c("m3rI"),it=c("9Bee"),ct=c("X0ci"),ft=c.n(ct),lt=c("rmrE"),pt=c.n(lt);function M(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */M=function(){return s};var u,s={},C=Object.prototype,v=C.hasOwnProperty,O=Object.defineProperty||function(r,t,e){r[t]=e.value},A=typeof Symbol=="function"?Symbol:{},b=A.iterator||"@@iterator",W=A.asyncIterator||"@@asyncIterator",T=A.toStringTag||"@@toStringTag";function y(r,t,e){return Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}),r[t]}try{y({},"")}catch(r){y=function(e,n,o){return e[n]=o}}function K(r,t,e,n){var o=t&&t.prototype instanceof $?t:$,a=Object.create(o.prototype),_=new X(n||[]);return O(a,"_invoke",{value:et(r,e,_)}),a}function G(r,t,e){try{return{type:"normal",arg:r.call(t,e)}}catch(n){return{type:"throw",arg:n}}}s.wrap=K;var S="suspendedStart",l="suspendedYield",k="executing",P="completed",E={};function $(){}function U(){}function g(){}var I={};y(I,b,function(){return this});var m=Object.getPrototypeOf,f=m&&m(m(Q([])));f&&f!==C&&v.call(f,b)&&(I=f);var d=g.prototype=$.prototype=Object.create(I);function R(r){["next","throw","return"].forEach(function(t){y(r,t,function(e){return this._invoke(t,e)})})}function D(r,t){function e(o,a,_,h){var p=G(r[o],r,a);if(p.type!=="throw"){var j=p.arg,w=j.value;return w&&typeof w=="object"&&v.call(w,"__await")?t.resolve(w.__await).then(function(x){e("next",x,_,h)},function(x){e("throw",x,_,h)}):t.resolve(w).then(function(x){j.value=x,_(j)},function(x){return e("throw",x,_,h)})}h(p.arg)}var n;O(this,"_invoke",{value:function(a,_){function h(){return new t(function(p,j){e(a,_,p,j)})}return n=n?n.then(h,h):h()}})}function et(r,t,e){var n=S;return function(o,a){if(n===k)throw new Error("Generator is already running");if(n===P){if(o==="throw")throw a;return{value:u,done:!0}}for(e.method=o,e.arg=a;;){var _=e.delegate;if(_){var h=L(_,e);if(h){if(h===E)continue;return h}}if(e.method==="next")e.sent=e._sent=e.arg;else if(e.method==="throw"){if(n===S)throw n=P,e.arg;e.dispatchException(e.arg)}else e.method==="return"&&e.abrupt("return",e.arg);n=k;var p=G(r,t,e);if(p.type==="normal"){if(n=e.done?P:l,p.arg===E)continue;return{value:p.arg,done:e.done}}p.type==="throw"&&(n=P,e.method="throw",e.arg=p.arg)}}}function L(r,t){var e=t.method,n=r.iterator[e];if(n===u)return t.delegate=null,e==="throw"&&r.iterator.return&&(t.method="return",t.arg=u,L(r,t),t.method==="throw")||e!=="return"&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+e+"' method")),E;var o=G(n,r.iterator,t.arg);if(o.type==="throw")return t.method="throw",t.arg=o.arg,t.delegate=null,E;var a=o.arg;return a?a.done?(t[r.resultName]=a.value,t.next=r.nextLoc,t.method!=="return"&&(t.method="next",t.arg=u),t.delegate=null,E):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,E)}function st(r){var t={tryLoc:r[0]};1 in r&&(t.catchLoc=r[1]),2 in r&&(t.finallyLoc=r[2],t.afterLoc=r[3]),this.tryEntries.push(t)}function z(r){var t=r.completion||{};t.type="normal",delete t.arg,r.completion=t}function X(r){this.tryEntries=[{tryLoc:"root"}],r.forEach(st,this),this.reset(!0)}function Q(r){if(r||r===""){var t=r[b];if(t)return t.call(r);if(typeof r.next=="function")return r;if(!isNaN(r.length)){var e=-1,n=function o(){for(;++e<r.length;)if(v.call(r,e))return o.value=r[e],o.done=!1,o;return o.value=u,o.done=!0,o};return n.next=n}}throw new TypeError(typeof r+" is not iterable")}return U.prototype=g,O(d,"constructor",{value:g,configurable:!0}),O(g,"constructor",{value:U,configurable:!0}),U.displayName=y(g,T,"GeneratorFunction"),s.isGeneratorFunction=function(r){var t=typeof r=="function"&&r.constructor;return!!t&&(t===U||(t.displayName||t.name)==="GeneratorFunction")},s.mark=function(r){return Object.setPrototypeOf?Object.setPrototypeOf(r,g):(r.__proto__=g,y(r,T,"GeneratorFunction")),r.prototype=Object.create(d),r},s.awrap=function(r){return{__await:r}},R(D.prototype),y(D.prototype,W,function(){return this}),s.AsyncIterator=D,s.async=function(r,t,e,n,o){o===void 0&&(o=Promise);var a=new D(K(r,t,e,n),o);return s.isGeneratorFunction(t)?a:a.next().then(function(_){return _.done?_.value:a.next()})},R(d),y(d,T,"Generator"),y(d,b,function(){return this}),y(d,"toString",function(){return"[object Generator]"}),s.keys=function(r){var t=Object(r),e=[];for(var n in t)e.push(n);return e.reverse(),function o(){for(;e.length;){var a=e.pop();if(a in t)return o.value=a,o.done=!1,o}return o.done=!0,o}},s.values=Q,X.prototype={constructor:X,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=u,this.done=!1,this.delegate=null,this.method="next",this.arg=u,this.tryEntries.forEach(z),!t)for(var e in this)e.charAt(0)==="t"&&v.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=u)},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 e=this;function n(j,w){return _.type="throw",_.arg=t,e.next=j,w&&(e.method="next",e.arg=u),!!w}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],_=a.completion;if(a.tryLoc==="root")return n("end");if(a.tryLoc<=this.prev){var h=v.call(a,"catchLoc"),p=v.call(a,"finallyLoc");if(h&&p){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(h){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!p)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&v.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&(t==="break"||t==="continue")&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var _=a?a.completion:{};return _.type=t,_.arg=e,a?(this.method="next",this.next=a.finallyLoc,E):this.complete(_)},complete:function(t,e){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"&&e&&(this.next=e),E},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),z(n),E}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var o=n.completion;if(o.type==="throw"){var a=o.arg;z(n)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:Q(t),resultName:e,nextLoc:n},this.method==="next"&&(this.arg=u),E}},s}var ut={data:void 0},N=function(u){return u.GET_DATA="get-data",u.PRAISE="on-praise",u}({});function _t(u,s){switch(s.type){case N.GET_DATA:return Object(B.a)(Object(B.a)({},u),{},{data:s.payload});case N.PRAISE:return Object(B.a)(Object(B.a)({},u),{},{data:s.payload});default:throw new Error}}F.default=function(){var u,s,C,v,O,A,b,W,T,y=Object(H.useReducer)(_t,ut),K=Object(at.a)(y,2),G=K[0],S=K[1],l=G.data,k=Object(tt.m)(),P=k.caseId,E=Object(tt.k)();Object(H.useEffect)(function(){var m=!1;function f(){return d.apply(this,arguments)}function d(){return d=Object(J.a)(M().mark(function R(){var D;return M().wrap(function(L){for(;;)switch(L.prev=L.next){case 0:return L.next=2,Object(Y.c)("libraries/".concat(P,".json"));case 2:D=L.sent,m||(D.status===404?E.push("/moop_cases"):S({type:N.GET_DATA,payload:D}));case 4:case"end":return L.stop()}},R)})),d.apply(this,arguments)}return m||f(),function(){m=!0}},[P]);function $(){return U.apply(this,arguments)}function U(){return U=Object(J.a)(M().mark(function m(){var f;return M().wrap(function(R){for(;;)switch(R.prev=R.next){case 0:return R.next=2,Object(Y.f)("praise_tread/like.json",{object_id:P,object_type:"library"});case 2:f=Object(B.a)({},l),f.operation.user_praised=!0,f.praise_count+=1,S({type:N.PRAISE,payload:f});case 6:case"end":return R.stop()}},m)})),U.apply(this,arguments)}function g(){return I.apply(this,arguments)}function I(){return I=Object(J.a)(M().mark(function m(){return M().wrap(function(d){for(;;)switch(d.prev=d.next){case 0:return d.next=2,Object(Y.b)("/libraries/".concat(P,".json"));case 2:E.push("/moop_cases");case 3:case"end":return d.stop()}},m)})),I.apply(this,arguments)}return i.a.createElement(rt.a,{spinning:!l,delay:500},l?i.a.createElement("section",{className:"moop-info"},i.a.createElement("div",{className:"crumb"},i.a.createElement(V.Link,{to:"/moop_cases"},"\u6559\u5B66\u6848\u4F8B > "),i.a.createElement("span",null,l.title)),i.a.createElement("div",{className:"title"},i.a.createElement("h2",null,l.title,(u=l.tags)===null||u===void 0?void 0:u.map(function(m,f){return i.a.createElement("span",{className:"label-"+f,key:m.id},m.name)})),i.a.createElement(V.Link,{to:"/moop_cases"},"\u8FD4\u56DE")),i.a.createElement("div",{className:"moop-info-body"},i.a.createElement("div",{className:"moop-sub-title"},i.a.createElement("img",{src:"".concat(ot.a.IMG_SERVER,"/images/").concat((s=l.creator)===null||s===void 0?void 0:s.image_url),alt:"cover",width:50}),i.a.createElement("div",{className:"desc"},i.a.createElement("div",{className:"flex-container"},i.a.createElement("span",null,(C=l.creator)===null||C===void 0?void 0:C.name),((v=l.operation)===null||v===void 0?void 0:v.can_editable)?i.a.createElement(V.Link,{to:"/moop_cases/".concat(l.id,"/edit"),style:{marginRight:10}},i.a.createElement(q.a,{type:"ghost"},"\u7F16\u8F91")):null,((O=l.operation)===null||O===void 0?void 0:O.can_deletable)?i.a.createElement(nt.a,{placement:"bottomRight",title:"\u662F\u5426\u786E\u8BA4\u5220\u9664\uFF1F",onConfirm:g},i.a.createElement(q.a,{type:"dashed"},"\u5220\u9664")):null),i.a.createElement("div",{className:"sum"},i.a.createElement("span",null,(A=l.creator)===null||A===void 0?void 0:A.school_name),i.a.createElement("span",null,"\u7F16\u7801\uFF1A",l.uuid),i.a.createElement("span",null,"\u53D1\u5E03\u65F6\u95F4\uFF1A",l.published_at)))),i.a.createElement("p",null,"\u4F5C\u8005\uFF1A","".concat(l.author_name," / ").concat(l.author_school_name)),i.a.createElement(it.a,{value:l.content}),i.a.createElement("ul",{className:"attachment"},(b=l.attachments)===null||b===void 0?void 0:b.map(function(m){return i.a.createElement("li",{key:m.id},i.a.createElement("a",{href:m.url},i.a.createElement("i",{className:"iconfont icon-fujian"}),i.a.createElement("span",null,m.title),i.a.createElement("span",null,m.filesize)))})),i.a.createElement("button",{className:"praise",disabled:(W=l.operation)===null||W===void 0?void 0:W.user_praised,onClick:$},((T=l.operation)===null||T===void 0?void 0:T.user_praised)?i.a.createElement("span",null,"\u5DF2\u8D5E"):i.a.createElement("span",null,i.a.createElement("i",{className:"iconfont icon-dianzan"})),i.a.createElement("span",null,l.praise_count)))):null)}}}]);
|