|
|
"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[20944],{34201:function(e,n,t){t.d(n,{Z:function(){return _}});var s=t(7557),a=t.n(s),l=t(41498),i=t.n(l),r=t(82242),o=t.n(r),u=t(79800),c=t.n(u),d=t(39647),p=t.n(d),h=t(59301),m=t(8591),f=t(59028),g=t(95237),x=t(94334),v=t(58670),j=t(66208),b="tip___bHEXo",Z=t(37712),y=["ButtonText","ButtonOptions","uploadProps","showTip"],_=function(e){var n,t,s,l=e.ButtonText,r=e.ButtonOptions,u=e.uploadProps,d=e.showTip,_=p()(e,y),w=(0,h.useState)(null),C=c()(w,2),k=C[0],P=C[1],I=o()(o()({maxCount:1,accept:"image/*",withCredentials:!0,beforeUpload:function(e){if(!("image/jpeg"===e.type||"image/png"===e.type||"image/jpg"===e.type))return m.ZP.error("您上传的不是JPEG/PNG/JPG类型文件"),f.Z.LIST_IGNORE;var n=e.size/1024/1024;return 0!=n||(m.ZP.error("".concat(e.name," 图片无法上传。").concat(0==n?"文件内容不能为空":"超过图片大小限制(2MB)")),f.Z.LIST_IGNORE)},onChange:function(e){var n;(["uploading","done","removed"].includes(e.file.status)&&P(e.file),"done"==e.file.status)&&(null==_||_.onChange(null===(n=e.file)||void 0===n||null===(n=n.response)||void 0===n?void 0:n.id))},action:"".concat(x.Z.API_SERVER,"/api/attachments.json")},u||{}),{},{onRemove:(t=i()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:E(),(null==u?void 0:u.onRemove)&&(null==u||u.onRemove(n));case 2:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}),E=function(){P(null),null==_||_.onChange()};return(0,h.useEffect)((function(){(null==_?void 0:_.value)&&P({response:{id:null==_?void 0:_.value}})}),[null==_?void 0:_.value]),(0,Z.jsx)("div",{id:(null==_?void 0:_.scrollId)||"",children:null!=k&&null!==(n=k.response)&&void 0!==n&&n.id?(0,Z.jsxs)(g.Z,{align:"middle",justify:"center",style:{position:"relative",width:400,backgroundColor:"#f4f3f4"},children:[(0,Z.jsx)("img",{src:x.Z.API_SERVER+"/api/attachments/"+(null==k||null===(s=k.response)||void 0===s?void 0:s.id),alt:"avatar",style:{width:"100%"}}),(0,Z.jsx)("div",{style:{position:"absolute",right:"-6px",top:"-6px",cursor:"pointer",width:16,height:16,borderRadius:"50%",backgroundColor:"#fff"},children:(0,Z.jsx)(v.Z,{onClick:i()(a()().mark((function e(){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:E();case 1:case"end":return e.stop()}}),e)}))),style:{fontSize:"16px",color:"red"}})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(f.Z,o()(o()({},I),{},{children:(0,Z.jsx)(j.op,o()(o()({style:o()({borderRadius:"2px"},null==r?void 0:r.style)},r),{},{children:l}))})),d&&(0,Z.jsx)("span",{className:b,children:"(建议上传尺寸为472*266的图片)"})]})})}},71716:function(e,n,t){t.d(n,{Z:function(){return x}});var s=t(82242),a=t.n(s),l=t(7557),i=t.n(l),r=t(41498),o=t.n(r),u=t(79800),c=t.n(u),d=t(59301),p=t(84686),h=t(92911),m=t(8785),f=(t(7923),{editor_css:"editor_css___cm3Z8"}),g=t(37712),x=(0,m.connect)((function(e){return{user:e.user}}))((function(e){var n=e.defaultvalue,t=e.onChange,s=e.style,l=e.user,r=e.placeholder,u=2097152,m=(0,d.useRef)(null),x=(0,d.useState)(null),v=c()(x,2),j=v[0],b=v[1],Z=(0,d.useState)(""),y=c()(Z,2),_=y[0],w=y[1];(0,d.useEffect)((function(){w(n)}),[n]),(0,d.useEffect)((function(){t(_)}),[_]);var C={placeholder:r||"请输入内容...",MENU_CONF:{}};C.MENU_CONF.uploadImage={customUpload:function(e,n){return o()(i()().mark((function t(){var s,a;return i()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(s=new FormData).append("file",e),t.next=4,(0,h.ZP)("/api/attachments.json",{method:"post",body:s},!0);case 4:a=t.sent,n(null==a?void 0:a.url,"","");case 6:case"end":return t.stop()}}),t)})))()}},C.MENU_CONF.uploadVideo={customUpload:function(e,n){return o()(i()().mark((function t(){var s,a,r,o,c,d,p,f,g,x,v,j,b,Z;return i()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return s=e.size,a=Math.ceil(s/u),t.prev=2,t.next=5,(0,h.ZP)("/api/attachments/multipart_upload_start",{method:"POST",body:{fileName:e.name,chunkCount:a,user_id:null==l||null===(r=l.userInfo)||void 0===r?void 0:r.user_id}});case 5:if(0===(null==(c=t.sent)?void 0:c.status)){t.next=8;break}throw new Error;case 8:d=c.upload_id,m.current=new AbortController,p=[],0,f=i()().mark((function n(){var t,a,l,r;return i()().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=g*u,a=Math.min(t+u,s),l=e.slice(t,a),(r=new FormData).append("chunk",l),r.append("fileName",e.name),r.append("chunkIndex",(g+1).toString()),r.append("uploadId",d),p.push((function(){return(0,h.ZP)("/api/attachments/multipart_upload",{method:"POST",body:r,signal:m.current.signal},!0).then((function(e){}))}));case 9:case"end":return n.stop()}}),n)})),g=0;case 14:if(!(g<a)){t.next=19;break}return t.delegateYield(f(),"t0",16);case 16:g++,t.next=14;break;case 19:x=0,v=4,console.log(p,"promises");case 22:if(!(x<p.length)){t.next=31;break}if(!((b=null===(j=p.slice(x,x+v))||void 0===j?void 0:j.map((function(e){return e()}))).length>0)){t.next=29;break}return t.next=27,Promise.all(b);case 27:t.sent,x+=v;case 29:t.next=22;break;case 31:return t.next=33,(0,h.ZP)("/api/attachments/multipart_upload_end",{method:"POST",body:{fileName:e.name,chunkCount:a,uploadId:d,user_id:null==l||null===(o=l.userInfo)||void 0===o?void 0:o.user_id}});case 33:Z=t.sent,n(null==Z?void 0:Z.object,""),t.next=39;break;case 37:t.prev=37,t.t1=t.catch(2);case 39:case"end":return t.stop()}}),t,null,[[2,37]])})))()}};return(0,d.useEffect)((function(){return function(){null!=j&&(j.destroy(),b(null))}}),[j]),(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)("div",{className:null==f?void 0:f.editor_css,style:{border:"1px solid #ccc",zIndex:100},children:[(0,g.jsx)(p.o,{editor:j,defaultConfig:{},mode:"default",style:{borderBottom:"1px solid #ccc"}}),(0,g.jsx)(p.M,{defaultConfig:C,value:_,onCreated:b,onChange:function(e){var n;!function(e){return""==e||new RegExp("^[ ]+$").test(e)}((n=e.getHtml(),n.replace(/<[^<p>]+>/g,"").replace(/<[</p>$]+>/g,"").replace(/ /gi,"").replace(/<[^<br/>]+>/g,"")))?w(e.getHtml()):w("")},mode:"default",style:a()({height:"500px",overflowY:"hidden"},s)})]})})}))},11436:function(e,n,t){t.r(n),t.d(n,{default:function(){return L}});var s=t(37205),a=t.n(s),l=t(7557),i=t.n(l),r=t(82242),o=t.n(r),u=t(41498),c=t.n(u),d=t(79800),p=t.n(d),h=t(59301),m=t(78241),f=t(8591),g=t(73782),x=t(95237),v=t(43604),j=t(57930),b=t(78673),Z=t(59028),y=t(3113),_=t(85574),w=t(8785),C="ContentWarp___dEP9T",k="footst___jjaL9",P="tags___GAiAz",I="hidden___gQNeb",E=t(71716),S=(t(39293),t(92911)),N=t(94334),F=t(34201),R=t(66208),T=t(37712),L=(0,w.connect)((function(e){var n=e.homePage,t=e.loading,s=e.globalSetting,a=e.user;return{homePage:n,globalSetting:s,loading:t.models.homePage,user:a}}))((function(e){e.homePage,e.globalSetting,e.user,e.loading;var n=e.dispatch,t=(0,h.useState)(),s=p()(t,2),l=(s[0],s[1],(0,h.useState)([{name:"全部"}])),r=p()(l,2),u=(r[0],r[1],m.Z.useForm()),d=p()(u,1)[0],L=(0,h.useState)([]),A=p()(L,2),B=A[0],O=A[1],z=(0,h.useState)({page:1,limit:10,setag:"全部"}),M=p()(z,2);M[0],M[1];(0,h.useEffect)((function(){return n({type:"globalSetting/headerFooterToggle",payload:!1}),function(){n({type:"globalSetting/headerFooterToggle",payload:!0})}}),[]);return(0,T.jsxs)("section",{style:{background:"#fff",paddingBottom:60},children:[(0,T.jsxs)("div",{style:{width:1200,margin:"0px auto"},children:[(0,T.jsxs)("div",{style:{paddingTop:40,display:"flex",alignItems:"center"},children:[(0,T.jsx)("div",{style:{background:"#666666",height:14,width:4,marginRight:8}}),(0,T.jsx)("span",{style:{color:"#232B40",fontWeight:500},children:"新闻动态"})]}),(0,T.jsx)("div",{className:C,children:(0,T.jsxs)(m.Z,{size:"large",colon:!1,form:d,onFinish:function(){var e=c()(i()().mark((function e(n){var t,s;return i()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,S.ZP)("/api/news_events.json",{method:"post",body:o()(o()({},n),{},{attachment_ids:null==n||null===(t=n.attachment_ids)||void 0===t?void 0:t.map((function(e){var n;return null==e||null===(n=e.response)||void 0===n?void 0:n.id})),news_event_tags:B})});case 2:0===(null==(s=e.sent)?void 0:s.status)&&(f.ZP.info("新增成功"),w.history.push("/news/".concat(null==s?void 0:s.id,"/detail")));case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),children:[(0,T.jsx)(m.Z.Item,{label:"标题",name:"title",labelCol:{span:2},rules:[{required:!0,message:"标题不能为空"}],children:(0,T.jsx)(g.Z,{maxLength:200,showCount:!0})}),(0,T.jsx)(m.Z.Item,{label:"标签",name:"tags",labelCol:{span:2},children:(0,T.jsx)(g.Z,{onPressEnter:function(e){5!==(null==B?void 0:B.length)?(B.push({id:null,name:e.target.value}),O(a()(B)),d.setFieldsValue({tags:""})):f.ZP.info("最多新增5个标签")},maxLength:10,addonAfter:"回车添加标签"})}),(0,T.jsxs)(x.Z,{children:[(0,T.jsx)(v.Z,{span:2}),null==B?void 0:B.map((function(e,n){return(0,T.jsxs)("div",{className:P,style:{position:"relative"},children:[(0,T.jsx)("span",{style:{display:"inline-flex",justifyContent:"center",padding:"0px 14px",background:"#F6F7F9",borderRadius:16,height:32,lineHeight:"32px",color:"#AC651A",marginRight:20,marginBottom:16},children:null==e?void 0:e.name}),(0,T.jsx)("span",{onClick:function(){B.splice(n,1),O(a()(B))},className:I,style:{position:"absolute",right:15,top:-5,width:14,height:14,background:"#E30000",color:"#FFFFFF",alignItems:"center",justifyContent:"center",borderRadius:"50%",fontSize:10,cursor:"pointer"},children:"x"})]})}))]}),(0,T.jsxs)(x.Z,{children:[(0,T.jsx)(v.Z,{span:12,children:(0,T.jsx)(m.Z.Item,{label:"来源",labelCol:{span:4},rules:[{required:!0,message:"来源不能为空"}],name:"publisher",children:(0,T.jsx)(g.Z,{maxLength:30,showCount:!0})})}),(0,T.jsx)(v.Z,{span:11,style:{marginLeft:46},children:(0,T.jsx)(m.Z.Item,{label:"发布时间",rules:[{required:!0,message:"发布时间不能为空"}],name:"publish_time",children:(0,T.jsx)(j.default,{style:{width:"100%"},showTime:!0})})})]}),(0,T.jsxs)(x.Z,{children:[(0,T.jsx)(v.Z,{span:12,children:(0,T.jsx)(m.Z.Item,{label:"编辑",labelCol:{span:4},name:"editor_name",children:(0,T.jsx)(g.Z,{maxLength:10,showCount:!0})})}),(0,T.jsx)(v.Z,{span:11,style:{marginLeft:46},children:(0,T.jsx)(m.Z.Item,{label:"审核",labelCol:{span:4},name:"reviewer_name",children:(0,T.jsx)(g.Z,{maxLength:10,showCount:!0})})})]}),(0,T.jsx)(m.Z.Item,{label:"链接",name:"url",labelCol:{span:2},children:(0,T.jsx)(g.Z,{})}),(0,T.jsx)(m.Z.Item,{label:"内容",name:"content",rules:[{required:!0,message:"请输入内容"}],labelCol:{span:2},children:(0,T.jsx)(E.Z,{})}),(0,T.jsx)(m.Z.Item,{label:"置顶",name:"is_top",labelCol:{span:2},children:(0,T.jsx)(b.Z,{})}),(0,T.jsxs)(x.Z,{wrap:!1,gutter:20,children:[(0,T.jsx)(v.Z,{flex:1,children:(0,T.jsx)(m.Z.Item,{name:"attachment_ids",label:(0,T.jsx)("div",{style:{textAlign:"right",width:82},children:"附件"}),valuePropName:"fileList",getValueFromEvent:function(e){return console.log("Upload event:",e),Array.isArray(e)?e:null==e?void 0:e.fileList},children:(0,T.jsx)(Z.Z,{action:"".concat(N.Z.API_SERVER,"/api/attachments.json"),withCredentials:!0,listType:"picture",children:(0,T.jsx)(R.op,{style:{borderRadius:"2px"},icon:(0,T.jsx)(_.Z,{}),children:"上传文件"})})})}),(0,T.jsx)(v.Z,{flex:1,children:(0,T.jsx)(m.Z.Item,{name:"cover_id",label:"封面图",children:(0,T.jsx)(F.Z,{uploadProps:{accept:".jpg, .png",beforeUpload:function(e){return!(e.size/1024/1024>10)||(f.ZP.error("封面图仅支持上传文件大小10MB以下的文件。"),Z.Z.LIST_IGNORE)},data:{is_upload_cover:!0}},ButtonText:"上传图片",ButtonOptions:{icon:(0,T.jsx)(_.Z,{})}})})})]})]})})]}),(0,T.jsx)("div",{className:k,children:(0,T.jsxs)("div",{style:{width:1200,margin:"0px auto",display:"flex",alignItems:"center",justifyContent:"space-between",height:"100%"},children:[(0,T.jsx)(y.ZP,{onClick:function(){w.history.back()},size:"large",className:"canclebtn",children:"返回"}),(0,T.jsx)(y.ZP,{onClick:function(){d.submit()},style:{marginLeft:10},className:"confirmbtn",type:"primary",size:"large",children:"确认新建"})]})})]})}))}}]); |