1 line
17 KiB
JavaScript
1 line
17 KiB
JavaScript
(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(),d&&_(!y)),h(!1)})).catch((function(e){h(!1)}));var e}},y?o.default.createElement("span",{className:""},o.default.createElement("i",{className:"iconfont icon-shixing font-15 text-yellow mr-4"}),o.default.createElement("span",{className:n||"font-12"},"已关注")):o.default.createElement("span",{className:""},o.default.createElement("i",{className:"iconfont icon-kongxing font-15"}),o.default.createElement("span",{className:n},i||"关注")))}},PA6o:function(e,t,n){},RrAk:function(e,t,n){},xjFL:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var a=h(n("W9HT")),r=h(n("BvKs")),l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(e[a]=n[a])}return e},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,a.key,a)}}return function(t,n,a){return n&&e(t.prototype,n),a&&e(t,a),t}}();n("04bd"),n("2WkQ");var u=n("q1tI"),i=h(u),s=n("eO8H"),c=h(n("KJct")),f=h(n("vDqi")),d=n("sYIF"),m=h(n("++Tf"));n("RrAk"),n("7dqz"),n("PA6o");var p=h(n("CnBM")),v=h(n("HUFq"));function h(e){return e&&e.__esModule?e:{default:e}}var g=(0,p.default)({loader:function(){return Promise.all([n.e(0),n.e(1),n.e(5),n.e(81)]).then(n.t.bind(null,"aah+",7))},loading:v.default}),E=(0,p.default)({loader:function(){return n.e(158).then(n.t.bind(null,"A5Ec",7))},loading:v.default}),y=(0,p.default)({loader:function(){return Promise.all([n.e(5),n.e(16),n.e(21),n.e(159),n.e(82)]).then(n.t.bind(null,"oe+v",7))},loading:v.default}),_=(0,p.default)({loader:function(){return Promise.all([n.e(0),n.e(1),n.e(5),n.e(16),n.e(27)]).then(n.t.bind(null,"Dmw4",7))},loading:v.default}),w=(0,p.default)({loader:function(){return Promise.all([n.e(0),n.e(1),n.e(5),n.e(71)]).then(n.t.bind(null,"EEGS",7))},loading:v.default}),b=(0,p.default)({loader:function(){return Promise.all([n.e(0),n.e(1),n.e(131)]).then(n.t.bind(null,"vTxG",7))},loading:v.default}),N=(0,p.default)({loader:function(){return Promise.all([n.e(0),n.e(1),n.e(146)]).then(n.t.bind(null,"0WPJ",7))},loading:v.default}),k=(0,p.default)({loader:function(){return Promise.all([n.e(0),n.e(1),n.e(145)]).then(n.t.bind(null,"bkQV",7))},loading:v.default}),x=(0,p.default)({loader:function(){return n.e(137).then(n.t.bind(null,"oeDK",7))},loading:v.default}),S=((0,p.default)({loader:function(){return n.e(90).then(n.t.bind(null,"ZX6M",7))},loading:v.default}),function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.renderPath=function(e,t){var a=n.props.match.params.username;e==="/"+a?(n.setState({route_type:void 0}),t&&n.setState({menuKey:t.show_super_description?"6":"0"})):e==="/"+a+"/statistics"?n.setState({menuKey:"1",route_type:void 0}):e.indexOf("/"+a+"/projects")>-1?n.setState({menuKey:"2",route_type:void 0}):e.indexOf("/"+a+"/notice")>-1?n.setState({menuKey:"3",route_type:void 0}):e.indexOf("/"+a+"/devops")>-1?n.setState({menuKey:"4",route_type:void 0}):e==="/"+a+"/organizes"?n.setState({menuKey:"5",route_type:void 0}):e==="/"+a+"/following"?n.setState({menuKey:void 0,route_type:"following"}):e==="/"+a+"/followers"?n.setState({menuKey:void 0,route_type:"followers"}):n.setState({menuKey:"6",route_type:void 0})},n.componentDidMount=function(){n.fetchUser()},n.componentDidUpdate=function(e){var t=n.props.match.params.username,a=e.match.params.username;a&&t&&a!==t&&n.fetchUser();var r=n.props.location.pathname,l=e.location.pathname;l&&r&&l!==r&&n.renderPath(r),n.props.history.listen((function(){(document.body.scrollTop||document.documentElement.scrollTop>0)&&window.scrollTo(0,0)}))},n.fetchUser=function(){n.setState({isSpin:!0});var e=n.props.current_user,t=n.props.match.params.username,a=(n.props.location.pathname,n.state.notice,"/users/"+(t||e&&e.login)+".json");f.default.get(a).then((function(e){var t=e.data&&e.data.undo_events;n.setState({user:e.data,isSpin:!1,undo_events:t});var a=n.props.location.pathname;n.renderPath(a,e.data)}))},n.change_devops_type=function(e){var t=n.state.user;n.setState({project_type:e,route_type:void 0}),n.props.history.push("/"+(t&&t.login)+"/devops/"+e)},n.undo_link=function(){var e=n.state.user;n.setState({route_type:void 0,project_type:"notice"},(function(){n.props.history.push("/"+(e&&e.login)+"/notice"),n.fetchUser()}))},n.route_link=function(e){n.setState({route_type:e})},n.organize_link=function(){var e=n.state.user;n.setState({route_type:void 0,project_type:"organizes"}),n.props.history.push("/"+(e&&e.login)+"/organizes")},n.resetUser=function(){var e=n.props.resetUserInfo;n.fetchUser(),e&&e()},n.deleteUndoEvent=function(e){var t=n.state.undo_events-e;n.setState({undo_events:t})},n.onCancelAvatar=function(e){if(n.setState({avatarVisible:!1}),e){var t=n.state.menuKey;if("2"===t||"3"===t)window.location.reload();else{n.fetchUser();var a=n.props.resetUserInfo;a&&a()}}},n.chooseTab=function(e){n.setState({menuKey:e})},n.aboutDescFunc=function(e){var t=n.state.user,a="/users/"+(t&&t.login)+".json",r={user:{user_extension_attributes:{show_super_description:e}}};f.default.put(a,r).then((function(e){e&&e.data&&n.fetchUser()}))},n.state={isSpin:!1,user:void 0,project_type:void 0,route_type:void 0,undo_events:0,menuKey:"6",avatarVisible:!1},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),o(t,[{key:"render",value:function(){var e=this,t=this.props.current_user,n=this.props.match.params.username,o=this.state,u=o.user,f=o.isSpin,p=o.route_type,v=o.undo_events,h=o.menuKey,S=o.avatarVisible;return i.default.createElement("div",{className:"newMain clearfix"},S&&i.default.createElement(m.default,{onCancel:this.onCancelAvatar,avatarImg:(0,d.getImageUrl)("/"+(u&&u.image_url)),login:t&&t.login}),i.default.createElement(a.default,{spinning:f},i.default.createElement("div",{className:"new-content-flex"},i.default.createElement("div",{className:"list-left",style:{border:"none"}},i.default.createElement("div",{className:"bgcF"},i.default.createElement("div",{className:"list-l-Menu text-center",style:{padding:"20px 25px"}},i.default.createElement("div",{className:"headimg-div"},i.default.createElement("span",{className:"headimg"},i.default.createElement("img",{src:(0,d.getImageUrl)("/"+(u&&u.image_url)),alt:""}),i.default.createElement("span",null,u&&1===u.gender?i.default.createElement("i",{className:"iconfont icon-nan1"}):i.default.createElement("i",{className:"iconfont icon-nv1"}))),t&&t.login&&t.login===n?i.default.createElement("span",{className:"updateAvatar",onClick:function(){e.setState({avatarVisible:!0})}},"修改头像"):""),i.default.createElement("div",{className:"text-center mt15 font-24 task-hide",title:u&&u.username},u&&u.username),i.default.createElement("div",{className:"userDescription"},u&&u.description),t&&u&&u.login!==t.login&&i.default.createElement("div",{className:"user-info-star-button "},i.default.createElement(c.default,{is_block:!0,is_watch:u.is_watch,id:u.login,fontClass:"font-14 ml5",starText:"关注TA",notReset:!0})),t&&u&&u.login===t.login&&i.default.createElement("div",{className:"usersDesc"},i.default.createElement("p",null,"想全方位展示自己?试试点击下方按钮定制化您的专属个人简介吧!"),u.show_super_description?i.default.createElement("a",{className:"emptyBtn",onClick:function(){return e.aboutDescFunc(!1)}},"隐藏个人简介"):i.default.createElement("a",{className:"fullBtn",onClick:function(){return e.aboutDescFunc(!0)}},"展示个人简介")),i.default.createElement("div",{className:"focusBox"},i.default.createElement(s.Link,{to:"/"+(u&&u.login)+"/following",className:"with50 text-center pull-left "+("following"===p?"text-primary":""),onClick:function(){return e.route_link("following")}},i.default.createElement("div",null,t&&u&&u.login===t.login?"我关注的":"TA关注的"),i.default.createElement("span",null,u&&u.watching_count)),i.default.createElement(s.Link,{to:"/"+(u&&u.login)+"/followers",onClick:function(){return e.route_link("followers")},className:"with50 text-center pull-left "+("followers"===p?"text-primary":"")},i.default.createElement("div",null,t&&u&&u.login===t.login?"关注我的":"关注TA的"),i.default.createElement("span",null,u&&u.watched_count))),u&&(u.province||u.custom_department||u.email)?i.default.createElement("div",{className:"infoBox"},u.province&&i.default.createElement("div",null,i.default.createElement("i",{className:"iconfont icon-weizhi"}),i.default.createElement("span",null,u.province),i.default.createElement("span",{title:u.city},u.city)),u.custom_department&&i.default.createElement("div",null,i.default.createElement("i",{className:"iconfont icon-danwei"}),i.default.createElement("span",{title:u.custom_department},u.custom_department)),u.email&&i.default.createElement("div",null,i.default.createElement("i",{className:"iconfont icon-youxiangrenzheng"}),i.default.createElement("span",{title:u.email},u.email))):""))),i.default.createElement("div",{className:"list-right"},!p&&h&&i.default.createElement(r.default,{selectedKeys:[h],mode:"horizontal",className:"infosRightMenu"},u&&u.show_super_description&&i.default.createElement(r.default.Item,{key:"6"},i.default.createElement(s.Link,{to:"/"+(u&&u.login),onClick:function(){return e.chooseTab("6")}},i.default.createElement("i",{className:"iconfont icon-personal-center font-20"}),"个人简介")),i.default.createElement(r.default.Item,{key:"0"},i.default.createElement(s.Link,{to:"/"+(u&&u.login),onClick:function(){return e.chooseTab("0")}},i.default.createElement("i",{className:"iconfont icon-gailan"}),"活动概览")),i.default.createElement(r.default.Item,{key:"1"},i.default.createElement(s.Link,{to:"/"+(u&&u.login)+"/statistics"},i.default.createElement("i",{className:"iconfont icon-shujutongji"}),"数据统计")),i.default.createElement(r.default.Item,{key:"2"},i.default.createElement(s.Link,{to:"/"+(u&&u.login)+"/projects"},i.default.createElement("i",{className:"iconfont icon-xiangmu"}),"参与项目")),t&&u&&u.login===t.login?i.default.createElement(r.default.Item,{key:"3"},i.default.createElement(s.Link,{to:"/"+(u&&u.login)+"/notice"},i.default.createElement("i",{className:"iconfont icon-daibanshixiang"}),"待办事项",v&&v>0?i.default.createElement("span",{className:"menuNum"},"(",v,")"):"")):"",t&&t.login&&t.login===n?i.default.createElement(r.default.Item,{key:"4"},i.default.createElement(s.Link,{to:"/"+(u&&u.login)+"/devops/CIService"},i.default.createElement("i",{className:"iconfont icon-gongzuoliu1"}),"DevOps引擎")):"",i.default.createElement(r.default.Item,{key:"5"},i.default.createElement(s.Link,{to:"/"+(u&&u.login)+"/organizes"},i.default.createElement("i",{className:"iconfont icon-zuzhi"}),"参与组织",u&&u.user_org_count&&u.user_org_count>0?i.default.createElement("span",{className:"menuNum"},"(",u.user_org_count,")"):""))),u&&i.default.createElement(s.Switch,this.props,i.default.createElement(s.Route,{path:"/:username/following",render:function(){return i.default.createElement(N,l({},e.props,e.state,{userType:"watchers",fetchUser:e.fetchUser}))}}),i.default.createElement(s.Route,{path:"/:username/notice",render:function(){return i.default.createElement(x,l({},e.props,e.state,{deleteUndoEvent:e.deleteUndoEvent}))}}),i.default.createElement(s.Route,{path:"/:username/followers",render:function(){return i.default.createElement(k,l({},e.props,e.state,{userType:"fan_users",fetchUser:e.fetchUser}))}}),i.default.createElement(s.Route,{path:"/:username/devops/CDService",render:function(){return i.default.createElement(E,l({},e.props,e.state))}}),i.default.createElement(s.Route,{path:"/:username/devops/CIService",render:function(){return i.default.createElement(g,l({},e.props,e.state))}}),i.default.createElement(s.Route,{path:"/:username/projects",render:function(){return i.default.createElement(w,l({},e.props,e.state))}}),i.default.createElement(s.Route,{path:"/:username/organizes",render:function(){return i.default.createElement(b,l({},e.props,e.state))}}),i.default.createElement(s.Route,{path:"/:username/statistics",render:function(t){return i.default.createElement(y,l({},e.props,e.state))}}),i.default.createElement(s.Route,{path:"/:username",render:function(t){return i.default.createElement(_,l({},e.props,e.state,{menuKey:h,show_super_description:u&&u.show_super_description}))}}),i.default.createElement(s.Route,{path:"/",render:function(t){return i.default.createElement(_,l({},e.props,e.state,{menuKey:h}))}}))))))}}]),t}(u.Component));t.default=S}}]); |