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

1 line
8.0 KiB

"use strict";(self.webpackChunk=self.webpackChunk||[]).push([[28859],{65379:function(e,n,t){var r=t(7557),l=t.n(r),o=t(41498),u=t.n(o),i=t(82242),a=t.n(i),s=t(79800),c=t.n(s),d=t(39647),p=t.n(d),f=t(59301),h=t(8591),m=t(53326),v=t(95237),x=t(84666),g=t(21884),b=t(11249),C=t(37712),j=["ButtonText","ButtonOptions","uploadProps"];n.Z=function(e){var n,t,r,o=e.ButtonText,i=e.ButtonOptions,s=e.uploadProps,d=p()(e,j),_=(0,f.useState)(null),k=c()(_,2),w=k[0],Z=k[1],y=a()(a()({maxCount:1,accept:"image/*",withCredentials:!0,beforeUpload:function(e){var n=e.size/1024/1024;return 0!=n||(h.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)&&Z(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")},s||{}),{},{onRemove:(t=u()(l()().mark((function e(n){return l()().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:E(),(null==s?void 0:s.onRemove)&&(null==s||s.onRemove(n));case 2:case"end":return e.stop()}}),e)}))),function(e){return t.apply(this,arguments)})}),E=function(){Z(null),null==d||d.onChange()};return(0,f.useEffect)((function(){(null==d?void 0:d.value)&&Z({response:{id:null==d?void 0:d.value}})}),[null==d?void 0:d.value]),(0,C.jsx)("div",{id:(null==d?void 0:d.scrollId)||"",children:null!=w&&null!==(n=w.response)&&void 0!==n&&n.id?(0,C.jsxs)(v.Z,{align:"middle",justify:"center",style:{position:"relative",width:400,backgroundColor:"#f4f3f4"},children:[(0,C.jsx)("img",{src:x.Z.API_SERVER+"/api/attachments/"+(null==w||null===(r=w.response)||void 0===r?void 0:r.id),alt:"avatar",style:{width:"100%"}}),(0,C.jsx)("div",{style:{position:"absolute",right:"-6px",top:"-6px",cursor:"pointer",width:16,height:16,borderRadius:"50%",backgroundColor:"#fff"},children:(0,C.jsx)(g.Z,{onClick:u()(l()().mark((function e(){return l()().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,C.jsx)(m.Z,a()(a()({},y),{},{children:(0,C.jsx)(b.op,a()(a()({style:a()({borderRadius:"2px"},null==i?void 0:i.style)},i),{},{children:o}))}))})}},59517:function(e,n,t){t.d(n,{Z:function(){return x}});var r=t(82242),l=t.n(r),o=t(7557),u=t.n(o),i=t(41498),a=t.n(i),s=t(79800),c=t.n(s),d=t(59301),p=t(84686),f=t(67444),h=t(33936),m=(t(95275),{editor_css:"editor_css___cm3Z8"}),v=t(37712),x=(0,h.connect)((function(e){return{user:e.user}}))((function(e){var n=e.defaultvalue,t=e.onChange,r=e.style,o=e.user,i=e.placeholder,s=2097152,h=(0,d.useRef)(null),x=(0,d.useState)(null),g=c()(x,2),b=g[0],C=g[1],j=(0,d.useState)(""),_=c()(j,2),k=_[0],w=_[1];(0,d.useEffect)((function(){w(n)}),[n]),(0,d.useEffect)((function(){t(k)}),[k]);var Z={placeholder:i||"请输入内容...",MENU_CONF:{}};Z.MENU_CONF.uploadImage={customUpload:function(e,n){return a()(u()().mark((function t(){var r,l;return u()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(r=new FormData).append("file",e),t.next=4,(0,f.ZP)("/api/attachments.json",{method:"post",body:r},!0);case 4:l=t.sent,n(null==l?void 0:l.url,"","");case 6:case"end":return t.stop()}}),t)})))()}},Z.MENU_CONF.uploadVideo={customUpload:function(e,n){return a()(u()().mark((function t(){var r,l,i,a,c,d,p,m,v,x,g,b,C,j;return u()().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.size,l=Math.ceil(r/s),t.prev=2,t.next=5,(0,f.ZP)("/api/attachments/multipart_upload_start",{method:"POST",body:{fileName:e.name,chunkCount:l,user_id:null==o||null===(i=o.userInfo)||void 0===i?void 0:i.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,h.current=new AbortController,p=[],0,m=u()().mark((function n(){var t,l,o,i;return u()().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:t=v*s,l=Math.min(t+s,r),o=e.slice(t,l),(i=new FormData).append("chunk",o),i.append("fileName",e.name),i.append("chunkIndex",(v+1).toString()),i.append("uploadId",d),p.push((function(){return(0,f.ZP)("/api/attachments/multipart_upload",{method:"POST",body:i,signal:h.current.signal},!0).then((function(e){}))}));case 9:case"end":return n.stop()}}),n)})),v=0;case 14:if(!(v<l)){t.next=19;break}return t.delegateYield(m(),"t0",16);case 16:v++,t.next=14;break;case 19:x=0,g=4,console.log(p,"promises");case 22:if(!(x<p.length)){t.next=31;break}if(!((C=null===(b=p.slice(x,x+g))||void 0===b?void 0:b.map((function(e){return e()}))).length>0)){t.next=29;break}return t.next=27,Promise.all(C);case 27:t.sent,x+=g;case 29:t.next=22;break;case 31:return t.next=33,(0,f.ZP)("/api/attachments/multipart_upload_end",{method:"POST",body:{fileName:e.name,chunkCount:l,uploadId:d,user_id:null==o||null===(a=o.userInfo)||void 0===a?void 0:a.user_id}});case 33:j=t.sent,n(null==j?void 0:j.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!=b&&(b.destroy(),C(null))}}),[b]),(0,v.jsx)(v.Fragment,{children:(0,v.jsxs)("div",{className:null==m?void 0:m.editor_css,style:{border:"1px solid #ccc",zIndex:100},children:[(0,v.jsx)(p.o,{editor:b,defaultConfig:{},mode:"default",style:{borderBottom:"1px solid #ccc"}}),(0,v.jsx)(p.M,{defaultConfig:Z,value:k,onCreated:C,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:l()({height:"500px",overflowY:"hidden"},r)})]})})}))},28859:function(e,n,t){t.d(n,{Z:function(){return C}});var r=t(82242),l=t.n(r),o=t(79800),u=t.n(o),i=t(39647),a=t.n(i),s=t(59301),c=t(43418),d=t(78241),p=t(24650),f=t(57809),h=t(65379),m="form___Ca7CG",v=t(33936),x=t(59517),g=t(37712),b=["handleFinish","form","content","dispatch","user","coreCurriculum"],C=(0,v.connect)((function(e){return{dispatch:e.dispatch,coreCurriculum:e.coreCurriculum,user:e.user}}))((function(e){var n,t,r=e.handleFinish,o=e.form,i=(e.content,e.dispatch),v=(e.user,e.coreCurriculum),C=a()(e,b),j=v.CoreSubjects,_=(0,s.useState)(""),k=u()(_,2),w=k[0],Z=k[1];return(0,s.useEffect)((function(){i({type:"coreCurriculum/getCoreSubjects",payload:{page:1,limit:12}})}),[]),(0,s.useEffect)((function(){var e,n;null!==(e=C.visible)&&void 0!==e&&e.id&&Z(null===(n=C.visible)||void 0===n?void 0:n.title)}),[C.visible]),(0,g.jsx)(c.Z,l()(l()({},C),{},{destroyOnClose:!0,centered:!0,width:1200,okText:"确认新增",afterClose:function(){return Z("")},children:(0,g.jsxs)(d.Z,{form:o,size:"large",initialValues:{},layout:"horizontal",labelCol:{span:2},className:m,onValuesChange:function(e){},onFinish:r,children:[(0,g.jsx)(d.Z.Item,{htmlFor:null,name:"title",label:"标题",rules:[{required:!0,message:"请输标题"}],children:(0,g.jsx)(p.Z,{placeholder:"请输入标题",maxLength:100,suffix:(0,g.jsxs)("span",{children:[null==w?void 0:w.length,"/100"]}),onChange:function(e){return Z(e.target.value)}})}),(0,g.jsx)(d.Z.Item,{htmlFor:null,name:"core_subject_id",label:"课程",rules:[{required:!0,message:"请选择课程"}],children:(0,g.jsx)(f.default,{placeholder:"请选择",getPopupContainer:function(e){return e.parentElement},children:null==j||null===(n=j.list)||void 0===n?void 0:n.map((function(e,n){return(0,g.jsx)(f.default.Option,{value:null==e?void 0:e.id,children:null==e?void 0:e.name},n)}))})}),(0,g.jsx)(d.Z.Item,{name:"cover_id",label:"列表封面图",rules:[{required:!0,message:"请上传列表封面图"}],children:(0,g.jsx)(h.Z,{ButtonText:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("i",{className:"iconfont icon-shangchuanfujian r5 font14"}),(0,g.jsx)("span",{className:"ml5",children:"上传图片"})]})})}),(0,g.jsx)(d.Z.Item,{label:"内容",name:"content",rules:[{required:!0,message:"请输入内容"}],labelCol:{span:2},children:(0,g.jsx)(x.Z,{defaultvalue:null==C||null===(t=C.visible)||void 0===t?void 0:t.content,style:{height:"300px"}})})]})}))}))}}]);