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.
NewEduCoderBuild/p__News__Add__index.async.js

1 line
12 KiB

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[20944],{89678:function(e,n,t){var i=t(7557),s=t.n(i),l=t(41498),a=t.n(l),o=t(82242),r=t.n(o),u=t(79800),c=t.n(u),d=t(39647),p=t.n(d),h=t(59301),f=t(8591),m=t(46651),g=t(95237),x=t(68339),v=t(97650),j=t(27030),b=t(37712),y=["ButtonText","ButtonOptions","uploadProps"];n.Z=function(e){var n,t,i,l=e.ButtonText,o=e.ButtonOptions,u=e.uploadProps,d=p()(e,y),Z=(0,h.useState)(null),_=c()(Z,2),w=_[0],C=_[1],k=r()(r()({maxCount:1,accept:"image/*",withCredentials:!0,beforeUpload:function(e){var n=e.size/1024/1024;return 0!=n||(f.ZP.error("".concat(e.name," 图片无法上传。").concat(0==n?"文件内容不能为空":"超过图片大小限制(2MB)")),m.Z.LIST_IGNORE)},onChange:function(e){var n;(["uploading","done","removed"].includes(e.file.status)&&C(e.file),"done"==e.file.status)&&(null==d||d.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=a()(s()().mark((function e(n){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:P(),(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)})}),P=function(){C(null),null==d||d.onChange()};return(0,h.useEffect)((function(){(null==d?void 0:d.value)&&C({response:{id:null==d?void 0:d.value}})}),[null==d?void 0:d.value]),(0,b.jsx)("div",{id:(null==d?void 0:d.scrollId)||"",children:null!=w&&null!==(n=w.response)&&void 0!==n&&n.id?(0,b.jsxs)(g.Z,{align:"middle",justify:"center",style:{position:"relative",width:400,backgroundColor:"#f4f3f4"},children:[(0,b.jsx)("img",{src:x.Z.API_SERVER+"/api/attachments/"+(null==w||null===(i=w.response)||void 0===i?void 0:i.id),alt:"avatar",style:{width:"100%"}}),(0,b.jsx)("div",{style:{position:"absolute",right:"-6px",top:"-6px",cursor:"pointer",width:16,height:16,borderRadius:"50%",backgroundColor:"#fff"},children:(0,b.jsx)(v.Z,{onClick:a()(s()().mark((function e(){return s()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:P();case 1:case"end":return e.stop()}}),e)}))),style:{fontSize:"16px",color:"red"}})})]}):(0,b.jsx)(m.Z,r()(r()({},k),{},{children:(0,b.jsx)(j.op,r()(r()({style:r()({borderRadius:"2px"},null==o?void 0:o.style)},o),{},{children:l}))}))})}},22845:function(e,n,t){var i=t(82242),s=t.n(i),l=(t(59301),t(19779)),a=t(3113),o=t(37712);n.Z=function(e){var n=e.img,t=e.buttonProps,i=void 0===t?{}:t,r=e.styles,u=void 0===r?{}:r,c=e.customText,d=e.ButtonText,p=e.ButtonClick,h=e.Buttonclass,f=e.ButtonTwo,m=e.imgStyles,g=e.loading,x=void 0!==g&&g;return(0,o.jsxs)("section",{className:"tc animated fadeIn",style:s()(s()({},{color:"#999",margin:"100px auto",visibility:x?"hidden":"visible"}),u),children:[(0,o.jsx)("img",{src:n||l,style:s()({width:288,height:200},m)}),(0,o.jsx)("p",{className:"mt20 font14",children:c||"暂时还没有相关数据哦!"}),d&&(0,o.jsx)(a.ZP,s()(s()({className:h,onClick:p},i),{},{children:d})),f&&f]})}},36586:function(e,n,t){t.d(n,{Z:function(){return x}});var i=t(82242),s=t.n(i),l=t(7557),a=t.n(l),o=t(41498),r=t.n(o),u=t(79800),c=t.n(u),d=t(59301),p=t(84686),h=t(51836),f=t(96707),m=(t(96080),{editor_css:"editor_css___cm3Z8"}),g=t(37712),x=(0,f.connect)((function(e){return{user:e.user}}))((function(e){var n=e.defaultvalue,t=e.onChange,i=e.style,l=e.user,o=e.placeholder,u=2097152,f=(0,d.useRef)(null),x=(0,d.useState)(null),v=c()(x,2),j=v[0],b=v[1],y=(0,d.useState)(""),Z=c()(y,2),_=Z[0],w=Z[1];(0,d.useEffect)((function(){w(n)}),[n]),(0,d.useEffect)((function(){t(_)}),[_]);var C={placeholder:o||"请输入内容...",MENU_CONF:{}};C.MENU_CONF.uploadImage={customUpload:function(e,n){return r()(a()().mark((function t(){var i,s;return a()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(i=new FormData).append("file",e),t.next=4,(0,h.ZP)("/api/attachments.json",{method:"post",body:i},!0);case 4:s=t.sent,n(null==s?void 0:s.url,"","");case 6:case"end":return t.stop()}}),t)})))()}},C.MENU_CONF.uploadVideo={customUpload:function(e,n){return r()(a()().mark((function t(){var i,s,o,r,c,d,p,m,g,x,v,j,b,y;return a()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=e.size,s=Math.ceil(i/u),t.prev=2,t.next=5,(0,h.ZP)("/api/attachments/multipart_upload_start",{method:"POST",body:{fileName:e.name,chunkCount:s,user_id:null==l||null===(o=l.userInfo)||void 0===o?void 0:o.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,f.current=new AbortController,p=[],0,m=a()().mark((function n(){var t,s,l,o;return a()().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=g*u,s=Math.min(t+u,i),l=e.slice(t,s),(o=new FormData).append("chunk",l),o.append("fileName",e.name),o.append("chunkIndex",(g+1).toString()),o.append("uploadId",d),p.push((function(){return(0,h.ZP)("/api/attachments/multipart_upload",{method:"POST",body:o,signal:f.current.signal},!0).then((function(e){}))}));case 9:case"end":return n.stop()}}),n)})),g=0;case 14:if(!(g<s)){t.next=19;break}return t.delegateYield(m(),"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:s,uploadId:d,user_id:null==l||null===(r=l.userInfo)||void 0===r?void 0:r.user_id}});case 33:y=t.sent,n(null==y?void 0:y.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==m?void 0:m.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(/&nbsp;/gi,"").replace(/<[^<br/>]+>/g,"")))?w(e.getHtml()):w("")},mode:"default",style:s()({height:"500px",overflowY:"hidden"},i)})]})})}))},95288:function(e,n,t){t.r(n),t.d(n,{default:function(){return B}});var i=t(37205),s=t.n(i),l=t(7557),a=t.n(l),o=t(82242),r=t.n(o),u=t(41498),c=t.n(u),d=t(79800),p=t.n(d),h=t(59301),f=t(78241),m=t(8591),g=t(98135),x=t(95237),v=t(43604),j=t(84291),b=t(78673),y=t(46651),Z=t(3113),_=t(81407),w=t(96707),C="ContentWarp___dEP9T",k="footst___jjaL9",P="tags___GAiAz",I="hidden___gQNeb",S=t(36586),E=(t(21444),t(51836)),F=t(68339),N=t(89678),R=t(27030),T=t(37712),B=(0,w.connect)((function(e){var n=e.homePage,t=e.loading,i=e.globalSetting,s=e.user;return{homePage:n,globalSetting:i,loading:t.models.homePage,user:s}}))((function(e){e.homePage,e.globalSetting,e.user,e.loading;var n=e.dispatch,t=(0,h.useState)(),i=p()(t,2),l=(i[0],i[1],(0,h.useState)([{name:"全部"}])),o=p()(l,2),u=(o[0],o[1],f.Z.useForm()),d=p()(u,1)[0],B=(0,h.useState)([]),A=p()(B,2),O=A[0],z=A[1],L=(0,h.useState)({page:1,limit:10,setag:"全部"}),M=p()(L,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)(f.Z,{size:"large",colon:!1,form:d,onFinish:function(){var e=c()(a()().mark((function e(n){var t,i;return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,E.ZP)("/api/news_events.json",{method:"post",body:r()(r()({},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:O})});case 2:0===(null==(i=e.sent)?void 0:i.status)&&(m.ZP.info("新增成功"),w.history.push("/news/".concat(null==i?void 0:i.id,"/detail")));case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),children:[(0,T.jsx)(f.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)(f.Z.Item,{label:"标签",name:"tags",labelCol:{span:2},children:(0,T.jsx)(g.Z,{onPressEnter:function(e){5!==(null==O?void 0:O.length)?(O.push({id:null,name:e.target.value}),z(s()(O)),d.setFieldsValue({tags:""})):m.ZP.info("最多新增5个标签")},maxLength:10,addonAfter:"回车添加标签"})}),(0,T.jsxs)(x.Z,{children:[(0,T.jsx)(v.Z,{span:2}),null==O?void 0:O.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(){O.splice(n,1),z(s()(O))},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)(f.Z.Item,{label:"发布人",labelCol:{span:4},rules:[{required:!0,message:"发布人不能为空"}],name:"publisher",children:(0,T.jsx)(g.Z,{maxLength:10})})}),(0,T.jsx)(v.Z,{span:11,style:{marginLeft:46},children:(0,T.jsx)(f.Z.Item,{label:"发布时间",rules:[{required:!0,message:"发布时间不能为空"}],name:"publish_time",children:(0,T.jsx)(j.default,{style:{width:"100%"},showTime:!0})})})]}),(0,T.jsx)(f.Z.Item,{label:"链接",name:"url",labelCol:{span:2},children:(0,T.jsx)(g.Z,{})}),(0,T.jsx)(f.Z.Item,{label:"内容",name:"content",rules:[{required:!0,message:"请输入内容"}],labelCol:{span:2},children:(0,T.jsx)(S.Z,{})}),(0,T.jsx)(f.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)(f.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)(y.Z,{action:"".concat(F.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)(f.Z.Item,{name:"cover_id",label:"封面图",children:(0,T.jsx)(N.Z,{uploadProps:{accept:".jpg, .png",beforeUpload:function(e){return!(e.size/1024/1024>10)||(m.ZP.error("封面图仅支持上传文件大小10MB以下的文件。"),y.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)(Z.ZP,{onClick:function(){w.history.back()},size:"large",children:"返回"}),(0,T.jsx)(Z.ZP,{onClick:function(){d.submit()},style:{marginLeft:10},type:"primary",size:"large",children:"确认新建"})]})})]})}))}}]);