build/static/js/75.aae1d288.chunk.js

1 line
17 KiB
JavaScript
Raw Normal View History

2022-12-08 16:50:44 +08:00
(this.webpackJsonp=this.webpackJsonp||[]).push([[75],{"++Tf":function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=f(n("kLXV")),r=f(n("14Xm")),l=f(n("tsqr")),o=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],a=!0,r=!1,l=void 0;try{for(var o,u=e[Symbol.iterator]();!(a=(o=u.next()).done)&&(n.push(o.value),!t||n.length!==t);a=!0);}catch(e){r=!0,l=e}finally{try{!a&&u.return&&u.return()}finally{if(r)throw l}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")};n("k3Gp"),n("8/o9");var u=n("q1tI"),i=f(u);n("68xt");var s=f(n("13Nf"));n("YQfW");var c=f(n("vDqi"));function f(e){return e&&e.__esModule?e:{default:e}}t.default=function(e){var t=this,n=e.onCancel,f=e.avatarImg,d=e.login,m=(0,u.useState)(f),p=o(m,2),v=p[0],h=p[1];(0,u.useEffect)((function(){f&&h(f)}),[f]);var g,E,y=(0,u.useRef)(),_=(g=r.default.mark((function e(){var a,o;return r.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:(a=y.current.cropper.getCroppedCanvas().toDataURL("image/png"))||l.default.info("请先上传图片"),o="/users/"+d+"/update_image.json",c.default.put(o,{image:a}).then((function(e){e&&(l.default.success("头像修改成功!"),n(!0))})).catch((function(e){}));case 4:case"end":return e.stop()}}),e,t)})),E=function(){var e=g.apply(this,arguments);return new Promise((function(t,n){return function a(r,l){try{var o=e[r](l),u=o.value}catch(e){return void n(e)}if(!o.done)return Promise.resolve(u).then((function(e){a("next",e)}),(function(e){a("throw",e)}));t(u)}("next")}))},function(){return E.apply(this,arguments)});return i.default.createElement(a.default,{visible:!0,width:"638px",footer:null,centered:!0,title:"修改头像",onCancel:function(){return n(!1)},className:"avatarBox"},i.default.createElement("div",{className:"avatarDiv"},i.default.createElement("div",null,i.default.createElement(s.default,{style:{height:320,width:320},src:v,guides:!1,preview:"#updateAvatarImg",ref:y,aspectRatio:1})),i.default.createElement("div",{className:"previewBox"},i.default.createElement("div",{className:"previewImg",id:"updateAvatarImg"}),i.default.createElement("div",{className:"uploadBtn"},i.default.createElement("label",{className:"uploadButton",id:"uploadBtn",htmlFor:"inputImage"},i.default.createElement("input",{type:"file",className:"sr-only",id:"inputImage",name:"file",accept:"image/*",style:{display:"none"},onChange:function(e){var t=void 0;if(e.dataTransfer?t=e.dataTransfer.files:e.target&&(t=e.target.files),t&&(!t||0!==t.length)){var n=t[0];if(/^image\/\w+/.test(n.type))if(n.size>2097152)l.default.info("仅支持文件大小小于2M的文件");else{var a=new FileReader;a.onload=function(){a.result&&h(a.result)},a.readAsDataURL(t[0])}else l.default.info("请选择一个图片格式的文件")}}}),"点击上传"),i.default.createElement("a",{onClick:_},"保存头像")))))}},"68xt":function(e,t,n){},"6V0J":function(e,t,n){},KJct:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=i(n("2/Rp")),r=function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],a=!0,r=!1,l=void 0;try{for(var o,u=e[Symbol.iterator]();!(a=(o=u.next()).done)&&(n.push(o.value),!t||n.length!==t);a=!0);}catch(e){r=!0,l=e}finally{try{!a&&u.return&&u.return()}finally{if(r)throw l}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")};n("L/Qf");var l=n("q1tI"),o=i(l),u=i(n("vDqi"));function i(e){return e&&e.__esModule?e:{default:e}}n("6V0J"),t.default=function(e){var t=e.is_watch,n=e.fontClass,i=e.starText,s=e.is_block,c=e.id,f=e.successFunc,d=e.notReset,m=(0,l.useState)(!1),p=r(m,2),v=p[0],h=p[1],g=(0,l.useState)(t),E=r(g,2),y=E[0],_=E[1];return o.default.createElement(a.default,{type:y?"default":"primary",ghost:!y,block:s,loading:v,onClick:function(){return e=y,h(!0),void(0,u.default)({method:e?"delete":"post",url:"/watchers/"+(e?"unfollow":"follow")+".json",params:{target_type:"user",id:c}}).then((function(e){e&&0===e.data.status&&(f&&f(