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
13 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[20944],{52491:function(e,n,t){t.d(n,{Z:function(){return _}});var s=t(7557),a=t.n(s),i=t(41498),l=t.n(i),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(54580),g=t(95237),x=t(91689),v=t(19248),j=t(940),b="tip___bHEXo",Z=t(37712),y=["ButtonText","ButtonOptions","uploadProps","showTip","showText","showListening","imgWidth"],_=function(e){var n,t,s,i=e.ButtonText,r=e.ButtonOptions,u=e.uploadProps,d=e.showTip,_=e.showText,w=e.showListening,C=e.imgWidth,k=p()(e,y),I=(0,h.useState)(null),P=c()(I,2),N=P[0],S=P[1],E=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):!(n>2)||(m.ZP.error("".concat(e.name," 图片无法上传。超过图片大小限制(2MB)")),f.Z.LIST_IGNORE)},onChange:function(e){var n;(["uploading","done","removed"].includes(e.file.status)&&S(e.file),"done"==e.file.status)&&(null==k||k.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=l()(a()().mark((function e(n){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:F(),(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)})}),F=function(){S(null),null==k||k.onChange()};return(0,h.useEffect)((function(){(null==k?void 0:k.value)&&S({response:{id:null==k?void 0:k.value}})}),[null==k?void 0:k.value]),(0,Z.jsx)("div",{id:(null==k?void 0:k.scrollId)||"",children:null!=N&&null!==(n=N.response)&&void 0!==n&&n.id?(0,Z.jsxs)(g.Z,{align:"middle",justify:"center",style:{position:"relative",width:C||400,backgroundColor:"#f4f3f4"},children:[(0,Z.jsx)("img",{src:x.Z.API_SERVER+"/api/attachments/"+(null==N||null===(s=N.response)||void 0===s?void 0:s.id),alt:"avatar",style:{width:"100%",height:C?"177px":"auto"}}),(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:l()(a()().mark((function e(){return a()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:F();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()({},E),{},{children:(0,Z.jsx)(j.op,o()(o()({style:o()({borderRadius:"2px"},null==r?void 0:r.style)},r),{},{children:i}))})),d&&(0,Z.jsx)("span",{className:b,children:"建议上传尺寸为472*266的图片"}),_&&(0,Z.jsx)("span",{className:b,style:{width:"4rem"},children:"需上传尺寸为200*268的图片大小不超过2MB"}),w&&(0,Z.jsx)("span",{className:b,style:{width:"4rem"},children:"限制上传2MB内的图片建议上传尺寸为283*177的图片"})]})})}},20416:function(e,n,t){t.d(n,{Z:function(){return x}});var s=t(82242),a=t.n(s),i=t(7557),l=t.n(i),r=t(41498),o=t.n(r),u=t(79800),c=t.n(u),d=t(59301),p=t(84686),h=t(94171),m=t(49389),f=(t(20632),{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,i=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()(l()().mark((function t(){var s,a;return l()().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()(l()().mark((function t(){var s,a,r,o,c,d,p,f,g,x,v,j,b,Z;return l()().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==i||null===(r=i.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=l()().mark((function n(){var t,a,i,r;return l()().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=g*u,a=Math.min(t+u,s),i=e.slice(t,a),(r=new FormData).append("chunk",i),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==i||null===(o=i.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(/&nbsp;/gi,"").replace(/<[^<br/>]+>/g,"")))?w(e.getHtml()):w("")},mode:"default",style:a()({height:"500px",overflowY:"hidden"},s)})]})})}))},91012:function(e,n,t){t.r(n),t.d(n,{default:function(){return L}});var s=t(37205),a=t.n(s),i=t(7557),l=t.n(i),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(10249),x=t(95237),v=t(43604),j=t(5083),b=t(78673),Z=t(54580),y=t(3113),_=t(32050),w=t(49389),C="ContentWarp___dEP9T",k="footst___jjaL9",I="tags___GAiAz",P="hidden___gQNeb",N=t(20416),S=(t(50946),t(94171)),E=t(91689),F=t(52491),R=t(940),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),i=(s[0],s[1],(0,h.useState)([{name:"全部"}])),r=p()(i,2),u=(r[0],r[1],m.Z.useForm()),d=p()(u,1)[0],L=(0,h.useState)([]),B=p()(L,2),O=B[0],A=B[1],M=(0,h.useState)(!0),z=p()(M,2),G=z[0],U=z[1],V=(0,h.useState)(!1),q=p()(V,2),H=q[0],W=q[1],D=(0,h.useState)({page:1,limit:10,setag:"全部"}),J=p()(D,2);J[0],J[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()(l()().mark((function e(n){var t,s;return l()().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:O,is_jump:H})});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==O?void 0:O.length)?(O.push({id:null,name:e.target.value}),A(a()(O)),d.setFieldsValue({tags:""})):f.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:I,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),A(a()(O))},className:P,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:60,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:60,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:60,showCount:!0})})})]}),(0,T.jsx)(m.Z.Item,{label:"链接",name:"url",labelCol:{span:2},children:(0,T.jsx)(g.Z,{onChange:function(e){e.target.value.trim()?U(!1):(W(!1),U(!0))}})}),(0,T.jsxs)("div",{style:{paddingLeft:"93px",marginBottom:20},children:[(0,T.jsx)(b.Z,{disabled:G,checked:H,onChange:function(e){return W(e)}}),(0,T.jsx)("span",{className:"ml10",style:{position:"relative",top:3},children:"进入新闻动态优先跳转链接"})]}),(0,T.jsx)(m.Z.Item,{label:"内容",name:"content",rules:[{required:!0,message:"请输入内容"}],labelCol:{span:2},children:(0,T.jsx)(N.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(E.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:"确认新建"})]})})]})}))}}]);