1 |
- import{d as K,r as C,b as q,e as R,A as le,q as W,b7 as b,f as e,k as y,O as z,b8 as H,E as oe,j as w,x as j,S as J,U as X,N as se,w as Q,aD as ne,g as $,h as ue,F as ie,l as re,m as ce,D as de,b9 as pe,P as Y}from"./index-efb66432-1734950731618.js";import{u as me}from"./catchData-e017bf09-1734950731618.js";import{x as fe,z as ge,A as Z,B as ye,D as ve,E as be,F as Ae}from"./api-5c1c8c26-1734950731618.js";import{C as he,g as P,a as ee,o as Fe}from"./index-ff431115-1734950731618.js";import{i as Ce}from"./index-85d522f9-1734950731618.js";import{N as Be}from"./Scrollbar-10f58cff-1734950731618.js";import{N as Ie}from"./Cascader-500c8137-1734950731618.js";const Se="_uploadModal_eir1m_1",_e="_formModal_eir1m_4",we="_formSpace_eir1m_8",Ee="_previewModal_eir1m_11",Ue="_image_eir1m_23",ke="_titleType_eir1m_32",De="_iconUploadDelete_eir1m_40",Ne="_commonType_eir1m_55",Me="_changeCover_eir1m_74",Ge="_formItem_eir1m_91",Te="_btnGroup_eir1m_116",xe="_uploadFile_eir1m_123",Oe="_uploadBtn_eir1m_130",Re="_iconUploadAdd_eir1m_147",je="_uploadCover_eir1m_152",F={uploadModal:Se,formModal:_e,formSpace:we,previewModal:Ee,image:Ue,titleType:ke,iconUploadDelete:De,commonType:Ne,changeCover:Me,formItem:Ge,btnGroup:Te,uploadFile:xe,uploadBtn:Oe,iconUploadAdd:Re,uploadCover:je},Ve="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAAAXNSR0IArs4c6QAAA3xJREFUaEPdmk1oE1EQgL/8qQVRVATxoCIqRURBBIsHKQZqTqJgIR4EPUgbf+6Fpoq2hd79IUWwggcDFRRPsRApHkRBBEVEVEQ9iCAqilBt/syE3bJds9l922xa38Ke9r2Z+d6bmZ15uyE0u0It4BEdUUNPEagEqbPZQG3AemAtsNy4F9kApoEfxv0J+ABMNQuyGUBLgY3ABmCNT8M+A++Bd8AvnzJq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qe="_headerItem_t4tbc_42",$e="_uploadContainer_t4tbc_59",Ye="_imgCropperSection_t4tbc_85",Ze="_uploadBtnGroup_t4tbc_92",_={uploadFile:Pe,uploadBtn:Le,iconUploadAdd:Ke,uploadHeader:qe,headerItem:Qe,uploadContainer:$e,imgCropperSection:Ye,uploadBtnGroup:Ze},We=K({name:"upload-file",props:{img:{type:String,default:""},accept:{type:String,default:".jpg,.png,.jpeg,.gif"},bucketName:{type:String,default:"gyt"},path:{type:String,default:""},fileName:{type:String,default:""},options:{type:Object,default:()=>({viewMode:0,autoCrop:!0,enlarge:1,autoCropWidth:640,autoCropHeight:360,fixedBox:!1,previewsCircle:!0,title:"上传图片"})}},emits:["close","confirm"],setup(a,{emit:A}){const I=C(),E="https://".concat(a.bucketName,".ks3-cn-beijing.ksyuncs.com/"),k=q(),s=C(!1),f=C(!1),M=C(),h=C({img:"",autoCrop:!0,autoCropWidth:180,autoCropHeight:180,fixedBox:!0,full:!1,enlarge:1,previewsCircle:!0,centerBox:!0,outputType:"png",title:"修改头像",name:null}),v=R({myCropper:null,cropperReady:!1}),S=async m=>{const d=m.file;let g=!0;if((d.type.includes("image")?b.IMG:d.type.includes("audio")?b.SONG:b.VIDEO)!==b.IMG)return k.error("上传文件格式错误"),!1;const N=10;return g=d.file.size/1024/1024<N,g?(G(d.file,T=>{p(T,d.file.name)}),!1):(k.error("图片大小不能超过".concat(N,"M")),!1)},G=async(m,d)=>{const g=new FileReader;g.addEventListener("load",()=>d(g.result)),g.readAsDataURL(m)},p=(m,d)=>{const g=Object.assign({},a.options,{img:m,name:d});s.value=!0,h.value=Object.assign({},h.value,g),J(()=>{l()})},l=()=>{try{v.cropperReady=!0,v.myCropper=new he(I.value,{viewMode:1,dragMode:"move",aspectRatio:h.value.autoCropWidth/h.value.autoCropHeight,initialAspectRatio:1,autoCropArea:1,cropBoxMovable:!0,cropBoxResizable:!0,background:!0,movable:!1,modal:!0,preview:".before",ready:()=>{v.cropperReady=!1}})}catch(m){}},o=()=>{v.myCropper.getCroppedCanvas({imageSmoothingQuality:"high"}).toBlob(m=>{f.value=!0,r(m)})},r=async m=>{try{const d="".concat(a.path).concat(a.fileName||new Date().getTime()+".png"),g={filename:d,bucketName:a.bucketName,postData:{filename:d,acl:"public-read",key:d}},{data:D}=await P(g),N={policy:D.policy,signature:D.signature,acl:"public-read",key:d,KSSAccessKeyId:D.kssAccessKeyId,name:d,file:m},T=await ee(E,N);A("confirm",T),A("close")}catch(d){}f.value=!1};return le(()=>a.img,()=>{a.img&&L(a.img)===b.IMG&&p(a.img)}),W(()=>{a.img&&L(a.img)===b.IMG&&p(a.img)}),()=>e("div",{class:_.uploadFile},[e("div",{class:_.uploadHeader},[e("div",{class:_.headerItem},[y("上传封面")])]),s.value?e("div",{class:_.uploadContainer},[e(oe,{show:v.cropperReady},{default:()=>{var m,d,g;return[e("div",{class:_.imgCropperSection},[((m=h.value)==null?void 0:m.img)&&e("img",{ref:I,src:(d=h.value)==null?void 0:d.img,style:{opacity:(g=v.myCropper)!=null&&g.ready?"1":"0"},alt:""},null)])]}})]):e("div",{class:_.uploadContainer},[e(z,{ref:M,accept:a.accept,multiple:!1,max:1,showFileList:!1,showPreviewButton:!0,onBeforeUpload:m=>S(m)},{default:()=>[e(H,null,{default:()=>[e("div",{class:_.uploadBtn},[e("img",{src:Ce,class:_.iconUploadAdd},null),e("p",null,[y("点击或将图片拖至此区域")]),e("span",null,[y("(建议比例16:9)")])])]})]})]),e("div",{class:_.uploadBtnGroup},[s.value?e(w,{type:"default",onClick:()=>{h.value.img="",s.value=!1}},{default:()=>[y("重新选择")]}):e("span",null,null),e(j,null,{default:()=>[e(w,{type:"default",onClick:()=>A("close")},{default:()=>[y("取消")]}),e(w,{type:"primary",onClick:()=>o(),disabled:!s.value,loading:f.value},{default:()=>[y("保存封面")]})]})])])}});function ze(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!de(a)}const L=a=>a?(a==null?void 0:a.indexOf(".mp3"))>-1?b.SONG:(a==null?void 0:a.indexOf(".mp4"))>-1?b.VIDEO:(a==null?void 0:a.indexOf(".ppt"))>-1?b.PPT:b.IMG:"",it=K({name:"upload-modal",props:{list:{type:Array,default:()=>[]},showDelete:{type:Boolean,default:!1},editStatus:{type:Boolean,default:!0}},emits:["close","confirm","editAll"],setup(a,{emit:A}){const I=me(),E=C(),k=q(),s=R({list:[],uploading:!1,uploadUrl:"",name:"",instrumentIds:[]}),f=R({uploadCoverStatus:!1,uploadType:"",uploadImg:null,uploadIndex:0}),M=p=>{let l=Z;switch(p){case"IMG":l=Z;break;case"VIDEO":l=Ae;break;case"SONG":l=be;break;case"MUSIC":l=ve;break;case"PPT":l=ye;break}return l},h=async()=>{var p;(p=E.value)==null||p.validate(async l=>{if(l){J(pe);return}s.uploading=!0;try{const o=[];if(s.list.forEach(r=>{o.push({instrumentIds:r.instrumentIds.join(","),openFlag:r.openFlag,coverImg:r.coverImg,name:r.name,type:r.type,enableFlag:1,content:r.content,id:r.id||null})}),S.value){if(a.editStatus)A("editAll",o);else{const{data:r}=await fe(o);k.success("保存成功"),s.list=[],A("close",!0),A("confirm",r)}s.list=[]}else await ge(o),k.success("保存成功"),s.list=[],A("close",!0),A("confirm")}catch(o){}s.uploading=!1})},v=p=>{s.list.splice(p,1)},S=X(()=>a.list.length>0);W(async()=>{const p=a.list||[],l=[];p.forEach(o=>{l.push({instrumentIds:o.instrumentIds?o.instrumentIds.split(",").map(r=>r):[],openFlag:o.openFlag,coverImg:o.coverImg,name:o.title,type:o.type,sourceFrom:o.sourceFrom,enableFlag:o.enableFlag,content:o.content,id:o.id})}),s.list=l||[],await I.getSubjects()});const G=(p,l)=>{const o=[];l.map(r=>{Array.isArray(r.instruments)&&r.instruments.forEach(m=>{o.push(m.value)})}),p.instrumentIds=o};return()=>{let p;return e("div",{class:F.uploadModal},[e(Be,{style:{"max-height":"55vh"}},{default:()=>[e(se,{ref:E,labelPlacement:"left",labelWidth:120,model:s,class:F.formModal},{default:()=>[e(j,{class:F.formSpace},ze(p=s.list.map((l,o)=>e("div",{class:F.formItem,key:o},[e("div",{class:F.previewModal},[e(Q,{class:[F.titleType],src:M(l.type),previewDisabled:!0,objectFit:"cover"},null),(!S.value||a.showDelete)&&e("img",{class:[F.iconUploadDelete],src:Ve,onClick:()=>v(o)},null),e(Q,{class:[F.cover,F.image],lazy:!0,previewDisabled:!0,src:l.coverImg,objectFit:"cover"},null),e("div",{class:F.commonType},[l.type!=="IMG"?e(w,{class:F.changeCover,type:"default",bordered:!1,onClick:()=>{f.uploadIndex=o,f.uploadImg=l.coverImg,f.uploadType=l.type,f.uploadCoverStatus=!0}},{default:()=>[y("更换封面")]}):e("span",null,null),e("div",null,[y("是否公开"),e(ne,{size:"small",value:l.openFlag,"onUpdate:value":r=>l.openFlag=r,disabled:l.sourceFrom==="TEACHER"&&l.type==="MUSIC"},null)])])]),e($,{showFeedback:!1,path:"list.".concat(o,".name"),rule:[{required:!0,message:"请输入资源名称",trigger:["input","blur"]}]},{default:()=>[e(ue,{value:l.name,"onUpdate:value":r=>l.name=r,placeholder:"请输入资源名称",maxlength:25,clearable:!0},null)]}),e($,{path:"list[".concat(o,"].instrumentIds"),showFeedback:!1,rule:[{required:!0,message:"请选择素材可用乐器",trigger:"change",type:"array"}]},{default:()=>[e(Ie,{value:l.instrumentIds,"onUpdate:value":r=>l.instrumentIds=r,placeholder:"请选择素材可用乐器(可多选)",options:I.getEnableSubjects,checkStrategy:"child",showPath:!1,childrenField:"instruments",expandTrigger:"hover",labelField:"name",valueField:"id",clearable:!0,filterable:!0,multiple:!0,maxTagCount:"responsive"},{action:()=>e(ie,null,[e(w,{text:!0,style:" --n-width: 100% ",onClick:()=>G(l,I.getEnableSubjects)},{default:()=>[y("全选")]})])})]})])))?p:{default:()=>[p]})]})]}),e(j,{class:F.btnGroup,justify:"center"},{default:()=>[e(w,{round:!0,onClick:()=>A("close")},{default:()=>[a.editStatus?"取消":"上一步"]}),e(w,{round:!0,type:"primary",loading:s.uploading,disabled:s.list.length===0,onClick:h},{default:()=>[y("确定")]})]}),e(re,{maskClosable:ce,show:f.uploadCoverStatus,"onUpdate:show":l=>f.uploadCoverStatus=l,preset:"card",showIcon:!1,class:["modalTitle ",F.uploadCover],blockScroll:!1},{default:()=>[e(We,{img:f.uploadImg,onClose:()=>f.uploadCoverStatus=!1,onConfirm:l=>{f.uploadType==="IMG"&&(s.list[f.uploadIndex].content=l),s.list[f.uploadIndex].coverImg=l}},null)]})])}}}),He="_saveModal_ulplg_1",Je="_uploadBtn_ulplg_25",Xe="_iconUploadAdd_ulplg_47",et="_btnGroup_ulplg_57",O={saveModal:He,uploadBtn:Je,iconUploadAdd:Xe,btnGroup:et},rt=K({name:"save-modal",props:{fileList:{type:String,default:""},imageList:{type:Array,default:()=>[]},accept:{type:String,default:".jpg,.png,.jpeg,.gif"},showType:{type:String,default:"default"},showFileList:{type:Boolean,default:!0},max:{type:Number,default:1},multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},bucketName:{type:String,default:"gyt"},directoryDnd:{type:Boolean,default:!1},path:{type:String,default:""},fileName:{type:String,default:""}},emits:["close","confrim"],setup(a,{emit:A}){const I="https://".concat(a.bucketName,".ks3-cn-beijing.ksyuncs.com/"),E=q(),k=C(!1),s=C(!1),f=C(),M=C(),h=R([]),v=C([]),S=C([]);function G(t){return t.slice((t.lastIndexOf(".")-1>>>0)+2)}function p(t,n){const i=G(t).toLowerCase();return n.includes(i)}const l=async t=>{const n=t.file;let i=!0;const u=["jpg","jpeg","png","mp4","mp3"];if(!p(n.file.name,u))return E.error("文件格式不支持"),!1;const c=n.type.includes("image")?b.IMG:n.type.includes("audio")?b.SONG:n.type.includes("video")?b.VIDEO:n.type.includes("vnd.openxmlformats-officedocument.presentationml.presentation")||n.type.includes("vnd.ms-powerpoint")?b.PPT:"other";if(c==="other")return E.error("文件格式不支持"),!1;const B=c==="IMG"?2:c==="SONG"?20:500;if(B&&(i=n.file.size/1024/1024<B,!i)){const U=c==="IMG"?"图片":c==="SONG"?"音频":"视频";return E.error("".concat(U,"大小不能超过").concat(B,"M")),!1}if(!i)return i;try{s.value=!0;const U=n.file.name,te=U.slice(U.lastIndexOf(".")),x="".concat(a.path).concat(Date.now()+n.id+te),ae={filename:x,bucketName:a.bucketName,postData:{filename:x,acl:"public-read",key:x,unknowValueField:[]}},{data:V}=await P(ae);h.push({id:n.id,tempFiileBuffer:n.file,policy:V.policy,signature:V.signature,acl:"public-read",key:x,KSSAccessKeyId:V.kssAccessKeyId,name:x})}catch(U){return s.value=!1,!1}return!0},o=t=>{r(t)},r=async t=>{console.log(t,"onFinishAfter");const n=h.find(c=>c.id==t.file.id),i=L(t.file.url);let u="";i==="IMG"?u=t.file.url:i==="SONG"?u=Y.SONG_DEFAULT_COVER:i==="PPT"?u=Y.PPT_DEFAULT_COVER:i==="VIDEO"&&(u=await d(n.tempFiileBuffer)),S.value.push({coverImg:u,content:t.file.url,id:t.file.id,name:t.file.name?t.file.name.slice(0,t.file.name.lastIndexOf(".")):""}),k.value=!1,s.value=!1},m=t=>new Promise((n,i)=>{const u=document.createElement("video");u.setAttribute("crossOrigin","Anonymous"),u.setAttribute("preload","auto"),u.muted=!0,u.autoplay=!0,u.src=URL.createObjectURL(t),u.addEventListener("loadedmetadata",()=>{u.play(),setTimeout(()=>{u.currentTime=0,u.pause();const c=document.createElement("canvas");c.width=u.videoWidth,c.height=u.videoHeight,c.getContext("2d").drawImage(u,0,0,c.width,c.height),c.toBlob(B=>{n(B)})},500)}),u.addEventListener("error",c=>{i(c)})}),d=async t=>{try{s.value=!0;const n=await m(t||f.value),i="".concat(a.path).concat(Date.now()+".png"),u={filename:i,bucketName:a.bucketName,postData:{filename:i,acl:"public-read",key:i,unknowValueField:[]}},{data:c}=await P(u),B={policy:c.policy,signature:c.signature,key:i,acl:"public-read",KSSAccessKeyId:c.kssAccessKeyId,name:i,file:n};return await ee(I,B)}finally{s.value=!1}},g=async t=>{const n=S.value.findIndex(i=>i.id===t.file.id);return S.value.splice(n,1),s.value=!1,!0},D=X(()=>{let t=!1;return v.value.forEach(n=>{n.status!=="finished"&&(t=!0)}),t||v.value.length<=0}),N=({file:t,action:n,onFinish:i,onError:u,onProgress:c})=>{const B=h.find(U=>U.id==t.id);B.file=t,Fe({file:t,action:n,data:B,onProgress:c,onFinish:i,onError:u})},T=async()=>{const t=[];v.value.forEach(n=>{const i=S.value.find(u=>u.id===n.id);i&&t.push(i)}),A("confrim",t)};return()=>e("div",{class:O.saveModal},[e(z,{ref:M,action:I,customRequest:N,fileList:v.value,"onUpdate:fileList":t=>v.value=t,accept:".jpg,jpeg,.png,audio/mp3,video/mp4",multiple:!0,max:10,showFileList:!0,showPreviewButton:!0,onBeforeUpload:t=>l(t),onFinish:t=>{o(t)},onRemove:t=>g(t)},{default:()=>[e(H,null,{default:()=>[e("div",{class:O.uploadBtn},[e("div",{class:O.iconUploadAdd},null),e("h3",null,[y("点击或者拖动文件到该区域来上传")]),e("p",null,[y("仅支持JPG、PNG、MP3、MP4,单次最多支持"),e("br",null,null),y("上传10个文件")])])]})]}),e(j,{class:O.btnGroup,justify:"center"},{default:()=>[e(w,{round:!0,onClick:()=>A("close")},{default:()=>[y("取消")]}),e(w,{round:!0,type:"primary",disabled:D.value||s.value,onClick:T},{default:()=>[y("确定")]})]})])}});export{rt as S,it as U,L as f};
|