index-80197ae6-1708220053196.js 17 KB

1
  1. import{d as ge,e as V,X as d,r as $,p as ve,H as oe,O as he,f as s,Y as _e,Z as be,k as x,F as J,c as le,a as Ie,u as Se,U,ab as Be,y as ce,w as D,ac as Ae,ad as re,ae as O,j as N,v as Ce,x as Le,A as ue,W as ke,l as Te,a3 as Ne,af as Pe}from"./index-9bb5784d-1708220053196.js";import{i as Me}from"./icon_back-c5ec0a72-1708220053196.js";import{i as Re,P as Ee,a as de,b as pe,c as Fe,d as Ue}from"./index-65a7445b-1708220053196.js";import{T as $e}from"./index-a77359ad-1708220053196.js";import{i as je,a as Ge}from"./icon-collect-active-4272e308-1708220053196.js";import{i as De}from"./icon_default-d1bcaf5f-1708220053196.js";import{T as Oe}from"./index-7dd384d5-1708220053196.js";import{u as We}from"./catchData-6634d298-1708220053196.js";import{c as ze,d as Ve,e as Je}from"./api-1d8d3b51-1708220053196.js";import{g as W,s as w,a as qe,b as me}from"./api-c4d392f8-1708220053196.js";import{T as fe}from"./index-0ad8ff6b-1708220053196.js";import{s as Xe}from"./state-b10d3a85-1708220053196.js";import{u as He}from"./index-d3c99e4e-1708220053196.js";import{a as z}from"./urlUtils-080cac35-1708220053196.js";import"./Slider-bc98d7ef-1708220053196.js";import"./index-c16bb585-1708220053196.js";const Ye="_container_1xbx8_1",Ze="_iconBack_1xbx8_6",Ke="_separator_1xbx8_39",Qe="_wrap_1xbx8_44",et="_wrapBottom_1xbx8_50",tt="_content_1xbx8_53",st="_tools_1xbx8_60",at="_contentWrap_1xbx8_84",it="_musicList_1xbx8_91",nt="_wrapList_1xbx8_105",ot="_empty_1xbx8_111",lt="_itemContainer_1xbx8_117",ct="_item_1xbx8_117",rt="_active_1xbx8_139",ut="_arrow_1xbx8_142",dt="_img_1xbx8_145",pt="_title_1xbx8_167",mt="_titleName_1xbx8_174",ft="_titleDes_1xbx8_181",gt="_btn_1xbx8_191",vt="_showPlayLoading_1xbx8_216",ht="_loadingWrap_1xbx8_219",wt="_showLoading_1xbx8_224",xt="_musicStaff_1xbx8_229",yt="_goBtn_1xbx8_244",_t="_rightBtns_1xbx8_253",bt="_textBtn_1xbx8_260",It="_transBtn_1xbx8_268",St="_favitor_1xbx8_273",Bt="_musicName_1xbx8_288",At="_staffImgs_1xbx8_296",Ct="_previewWindow_1xbx8_313",Lt="_previewClose_1xbx8_318",kt="_previewIframe_1xbx8_325",Tt="_popSelect_1xbx8_331",Nt="_popSelect1_1xbx8_343",Pt="_popTrans_1xbx8_353",Mt="_iconArrow_1xbx8_364",Rt="_textBtnActive_1xbx8_376",i={container:Ye,iconBack:Ze,separator:Ke,wrap:Qe,wrapBottom:et,content:tt,tools:st,contentWrap:at,musicList:it,wrapList:nt,empty:ot,itemContainer:lt,item:ct,active:rt,arrow:ut,img:dt,title:pt,titleName:mt,titleDes:ft,btn:gt,showPlayLoading:vt,loadingWrap:ht,showLoading:wt,musicStaff:xt,goBtn:yt,rightBtns:_t,textBtn:bt,transBtn:It,favitor:St,musicName:Bt,staffImgs:At,previewWindow:Ct,previewClose:Lt,previewIframe:kt,popSelect:Tt,popSelect1:Nt,popTrans:Pt,iconArrow:Mt,textBtnActive:Rt},Et=""+new URL("icon_goXiaoku-5d0db670.png",import.meta.url).href,Ft=""+new URL("icon-close-1bf25bcf.png",import.meta.url).href,Ut=""+new URL("icon_trans-e9b9e2da.png",import.meta.url).href,$t=ge({name:"music-guide",emits:["close"],setup(S,{emit:q}){const o=V({box:{height:"0px"},show:!1,steps:[{ele:"",eleRect:{},img:W("music1.png"),handStyle:{top:"0.91rem"},imgStyle:{top:d(-4),left:d(0),width:d(533),height:d(271)},btnsStyle:{bottom:d(40),left:d(159)},eleRectPadding:{left:7,top:7,width:14,height:14},boxStyle:{}},{ele:"",img:W("music2.png"),imgStyle:{top:d(-4),left:d(-205),width:d(420),height:d(228)},btnsStyle:{bottom:d(35),left:d(-48)},boxStyle:{borderRadius:"25px"},eleRectPadding:{left:7,top:7,width:14,height:14}},{ele:"",img:W("music3.png"),imgStyle:{top:"100%",left:d(-130),width:d(401),height:d(304)},btnsStyle:{bottom:d(100),left:d(30)},boxStyle:{borderRadius:"40px"},eleRectPadding:{left:7,top:7,width:14,height:14},type:"bottom"}],step:0}),h=$(!1),r=$({});(async()=>{var l;try{const p=await qe({guideTag:"teacher-guideInfo"});p.data?r.value=JSON.parse((l=p.data)==null?void 0:l.guideValue)||null:r.value={},r.value&&r.value.musicGuide?h.value=!1:h.value=!0}catch(p){console.log(p)}})();const y=()=>{var p,b,I,A;const l=document.getElementById("music-".concat(o.step));if(l){const f=l.getBoundingClientRect();if(console.log(l.style.display,"ele"),l.style.display=="none"){_();return}const m=((p=o.steps[o.step].eleRectPadding)==null?void 0:p.left)||0,M=((b=o.steps[o.step].eleRectPadding)==null?void 0:b.top)||0,L=((I=o.steps[o.step].eleRectPadding)==null?void 0:I.width)||0,R=((A=o.steps[o.step].eleRectPadding)==null?void 0:A.height)||0;o.box={left:f.x-m+"px",top:f.y-M+"px",width:f.width+L+"px",height:f.height+R+"px"}}else _()},T=async l=>{try{if(l!=="xiaoku-music")return;r.value?r.value.musicGuide=!1:r.value={musicGuide:!1};try{await me({guideTag:"teacher-guideInfo",guideValue:JSON.stringify(r.value)})}catch(p){console.log(p)}o.step=0,y(),h.value=!0}catch(p){}};ve(()=>{y(),window.addEventListener("resize",P),oe.on("teacher-guideInfo",l=>T(l))});const P=()=>{y()};he(()=>{window.removeEventListener("resize",P),oe.off("teacher-guideInfo",T)});const _=()=>{if(o.step>=3){B();return}o.step=o.step+1,y()},B=async()=>{r.value?r.value.musicGuide=!0:r.value={musicGuide:!0};try{const l=await me({guideTag:"teacher-guideInfo",guideValue:JSON.stringify(r.value)})}catch(l){console.log(l)}h.value=!1};return()=>s(J,null,[h.value?_e(s("div",{"onUpdate:show":l=>h.value=l,class:["n-modal-mask","n-modal-mask-guide"]},[s("div",{class:w.content,onClick:()=>_()},[s("div",{class:w.backBtn,onClick:l=>{l.stopPropagation(),B()}},[x("跳过")]),s("div",{class:w.box,style:{...o.box,...o.steps[o.step].boxStyle},id:"modeType-".concat(o.step)},[o.steps.map((l,p)=>{var b,I,A,f;return s("div",{onClick:m=>m.stopPropagation(),class:w.item,style:l.type=="bottom"?{display:p===o.step?"":"none",left:"".concat((b=l.eleRect)==null?void 0:b.left,"px"),top:"-".concat((I=l.imgStyle)==null?void 0:I.height)}:{display:p===o.step?"":"none",left:"".concat((A=l.eleRect)==null?void 0:A.left,"px"),top:"".concat((f=o.box)==null?void 0:f.height)}},[s("img",{class:w.img,style:l.imgStyle,src:l.img},null),s("div",{class:w.btns,style:l.btnsStyle},[o.step+1==o.steps.length?s(J,null,[s("div",{class:[w.endBtn],onClick:()=>B()},[x("完成")]),s("div",{class:w.nextBtn,onClick:()=>{o.step=0,y()}},[x("再看一遍")])]):s("div",{class:w.btn,onClick:()=>_()},[x("下一步 ("),o.step+1,x("/"),o.steps.length,x(")")])])])})])])]),[[be,h.value,"show"]]):null])}});function jt(S){return typeof S=="function"||Object.prototype.toString.call(S)==="[object Object]"&&!Ne(S)}const ss=ge({name:"XiaokuMusic",setup(){const S=We(),q=le(),o=Ie(),h=Se(),r=V({page:1,rows:20,status:!0,name:"",musicSheetCategoriesId:o.query.id||""}),e=V({loading:!1,finshed:!1,reshing:!1,tags:[],tagIndex:0,list:[],listActive:0,musicInstrumentIndex:0,playState:"pause",showPlayer:!1,previewModal:!1,showPreivew:!1,previewUrl:"",showCloseBtn:!0,iframeSrc:"",showMusicImg:"staff",trackList:[],showTransBtn:!0,trackName:"切换声轨"}),y=$(!1),T=le(),P=async()=>{const a=S.getSubjectInstruments,t=sessionStorage.getItem("musicSubjectList")?JSON.parse(sessionStorage.getItem("musicSubjectList")):[],n=[];a.forEach(c=>{t.find(v=>v.id===c.id)&&n.push(c)}),e.tags=[{name:"全部",id:0,value:0,label:"全部"},...n]},_=async()=>{var t;e.loading=!0;let a={};try{a=await ze({...r,musicalInstrumentId:e.tagIndex?e.tagIndex:""})}catch(n){console.log(n)}console.log(a,"data",e.reshing,"musicSubject"),e.reshing&&(e.list=[],e.reshing=!1),(a==null?void 0:a.code)===200&&Array.isArray((t=a==null?void 0:a.data)==null?void 0:t.rows)&&(e.list=[...e.list,...a.data.rows],e.finshed=a.data.rows.length<r.rows),e.list[e.listActive]&&I(e.list[e.listActive]),e.loading=!1,setTimeout(()=>{y.value=!0},500)},B=()=>{e.listActive=0,e.showPlayer=!1,e.playState="pause",r.page=1,e.finshed=!1,_()},l=$(),p=()=>{e.loading||e.finshed||(r.page=r.page+1,_())},b=a=>{var t;((t=a.data)==null?void 0:t.api)==="api_fingerPreView"&&(e.showCloseBtn=!a.data.state)};ve(async()=>{await S.getSubjects(),He(document.querySelector(".musicList-container"),t=>{const n=t[0],{height:c}=n.contentRect;document.documentElement.style.setProperty("--xiaoku-music-height",c+"px")}),P(),await _(),new IntersectionObserver(t=>{t[0].intersectionRatio>0&&p()}).observe(l.value),H(),window.addEventListener("message",b)}),he(()=>{window.removeEventListener("message",b)});const I=async a=>{const t=await Ve({type:"MUSIC",materialId:a.id});(t==null?void 0:t.code)===200&&(a.favitor=t.data)},A=a=>{const t=e.list.findIndex(n=>n.id===a.id);t>-1&&(e.listActive=t),I(a)},f=a=>{const t={};return a==null||a.forEach(n=>{n.id===e.tagIndex&&(t.selected=!0,t.name=n.name)}),t},m=U(()=>(e.list[e.listActive]&&"".concat(z(),"/instrument?modelType=practise&id=").concat(e.list[e.listActive].xmlFileUrl,"&Authorization=").concat(T.getToken,"/#/preview"),e.list[e.listActive]||{})),M=()=>{e.list[e.listActive].favitor=!e.list[e.listActive].favitor,Je({favoriteFlag:e.list[e.listActive].favitor,type:"MUSIC",materialId:e.list[e.listActive].id})},L=a=>{const t=e.list.findIndex(n=>n.id===a.id);t>-1&&(e.listActive===t?e.playState=e.playState==="play"?"pause":"play":e.playState="play",e.showPlayer=!0,e.listActive=t)};U(()=>{const a=e.list[e.listActive],t=(a==null?void 0:a.musicalInstruments)||[],n=[];return t.forEach((c,g)=>{n.push({label:c.name,value:g})}),n});const R=U(()=>{const a=e.list[e.listActive],t=a==null?void 0:a.musicalInstruments;return!!(t&&t.length>1)}),j=()=>{const a=T.getToken,t=e.list[e.listActive],n=e.showMusicImg==="first"?"firstTone":e.showMusicImg==="fixed"?"fixedTone":e.showMusicImg==="staff"?"staff":"firstTone";e.iframeSrc="".concat(z(),"/instrument/?id=").concat(t.id,"&modelType=practise&modeType=json&Authorization=").concat(a,"&isPreView=true&part-index=").concat(e.musicInstrumentIndex,"&musicRenderType=").concat(n)},X=a=>{a==="play"?e.playState="play":a==="pause"?e.playState="pause":a==="pre"?e.list[e.listActive-1]&&L(e.list[e.listActive-1]):a==="next"?e.list[e.listActive+1]&&L(e.list[e.listActive+1]):a==="favitor"&&M()},we=[{value:"staff",label:"五线谱"},{value:"first",label:"首调"},{value:"fixed",label:"固定调"}],H=async()=>{var t;const a=e.list[e.listActive];if(((t=a.musicalInstruments)==null?void 0:t.length)>1){if(a.xmlFileUrl){const n=await fetch(a.xmlFileUrl).then(c=>c.text());xe(n)}}else{const{defaultScore:n,transferFlag:c}=a.musicalInstruments[0]||{};let g="staff";g=n==="STAVE"?"staff":n==="JIAN"?"fixed":n==="FIRST"?"first":"staff",e.showMusicImg=g,e.showTransBtn=c}},xe=a=>{var ee,te,E,se,ae,ie,ne;const t=new DOMParser().parseFromString(a,"text/xml"),n=((te=(ee=t.getElementsByTagName("part-list"))==null?void 0:ee[0])==null?void 0:te.getElementsByTagName("score-part"))||[],c=Array.from(n).map(u=>{var C,F,k;return((k=(F=(C=u.getElementsByTagName("part-name"))==null?void 0:C[0])==null?void 0:F.textContent)==null?void 0:k.trim())||""});t.getElementsByTagName("part"),((se=(E=c[0])==null?void 0:E.toLocaleUpperCase)==null?void 0:se.call(E))==="COMMON"&&c.shift();const g=(ae=e.list[e.listActive])==null?void 0:ae.multiTracksSelection,v=g?g==null?void 0:g.split(","):[],Z=c.map((u,C)=>{const F=!!(v.length==0||v.includes(u)),k=Be(u),ye=Pe(k,C);return{label:u+(k?"(".concat(k,")"):""),value:C,sortId:ye,canselect:F,track:u}}).filter(u=>u.canselect).sort((u,C)=>u.sortId-C.sortId);e.trackList=Z;let G=(ie=Z.find(u=>u.value===e.musicInstrumentIndex))==null?void 0:ie.track;G=G.replace(/[0-9]+/g,"").replace(/\s/g,"").toLocaleLowerCase();let K="first",Q=!0;(ne=e.list[e.listActive])==null||ne.musicalInstruments.forEach(u=>{u.code.toLocaleLowerCase()===G&&(K=u.defaultScore==="STAVE"?"staff":u.defaultScore==="JIAN"?"fixed":(u.defaultScore==="FIRST","first"),Q=u.transferFlag)}),e.showTransBtn=Q,e.showMusicImg=K};ce(()=>e.listActive,async()=>{e.musicInstrumentIndex=0,H()}),ce(()=>e.musicInstrumentIndex,async()=>{var a;e.trackName=((a=e.trackList.find(t=>t.value===e.musicInstrumentIndex))==null?void 0:a.label)||"切换声轨",j()});const Y=U(()=>{var t,n,c,g;let a=[];if(e.showMusicImg==="first"){const v=(t=m.value)==null?void 0:t.musicFirstSvg;a=v?v.split(","):[]}else if(e.showMusicImg==="fixed"){const v=(n=m.value)==null?void 0:n.musicJianSvg;a=v?v.split(","):[]}else if(e.showMusicImg==="staff"){const v=((c=m.value)==null?void 0:c.musicImg)||((g=m.value)==null?void 0:g.musicSvg);a=v?v.split(","):[]}return a});return()=>{let a;return s("div",{class:i.container},[s(D,{align:"center",wrapItem:!1,size:16},{default:()=>[s("img",{style:{cursor:"pointer"},src:Me,class:i.iconBack,onClick:()=>h.push({path:"/xiaoku-ai"})},null),s(Ae,{separator:""},{default:()=>[s(re,{onClick:()=>h.push({path:"/xiaoku-ai"})},{default:()=>[x("全部列表")]}),s("img",{class:i.separator,src:Re},null),s(re,null,{default:()=>[o.query.name]})]})]}),s("div",{class:[i.wrap,e.showPlayer?i.wrapBottom:""]},[s("div",{class:i.content},[s("div",{class:i.tools},[s(D,{style:{width:"100%"},size:[24,12],wrapItem:!1},{default:()=>[s("div",{id:"music-0"},[s(D,{style:{width:"100%"},size:[24,12],wrapItem:!1},jt(a=e.tags.map(t=>t.instruments&&t.instruments.length>1?s(O,{options:t.instruments,trigger:"hover",value:e.tagIndex,"onUpdate:value":[n=>e.tagIndex=n,()=>{e.reshing=!0,document.querySelector(".musicList-container").scroll(0,0),B()}],key:t.value,class:[i.popSelect1]},{default:()=>[s(N,{round:!0,textColor:f(t.instruments).selected?"#fff":"#000",color:f(t.instruments).selected?"#198CFE":"#fff",type:f(t.instruments).selected?"primary":"default",class:[i.textBtn,f(t.instruments).selected&&i.textBtnActive]},{default:()=>[f(t.instruments).name||t.name,s("i",{class:i.iconArrow},null)]})]}):s(N,{round:!0,textColor:e.tagIndex===t.value?"#fff":"#000",color:e.tagIndex===t.value?"#198CFE":"#fff",type:e.tagIndex===t.value?"primary":"default",onClick:()=>{e.tagIndex=t.value||0,e.reshing=!0,document.querySelector(".musicList-container").scroll(0,0),B()}},{default:()=>[t.name]})))?a:{default:()=>[a]})])]}),s($e,{style:{marginLeft:"auto"},round:!0,border:!1,onSearch:t=>{r.name=t,e.reshing=!0,B()}},null)]),s("div",{class:i.contentWrap},[s("div",{class:[i.musicList,"musicList-container"]},[s("div",{class:[i.wrapList,"music-wrap-list"]},[e.list.map((t,n)=>s("div",{class:i.itemContainer},[s("div",{class:[i.item,e.listActive===n&&i.active],onClick:()=>{A(t),j()}},[s("div",{class:i.img},[s(Ce,{lazy:!0,objectFit:"cover",previewDisabled:!0,src:t.titleImg||De,onLoad:c=>{c.target.dataset.loaded="true"}},null),s(Ee,{class:[e.listActive===n&&e.playState==="play"?"":i.showPlayLoading]},null)]),s("div",{class:i.title},[s("div",{class:i.titleName},[s(Oe,{text:t.musicSheetName},null)]),s("div",{class:i.titleDes},[t.composer])]),n==0?s(N,Le({color:"#259CFE",textColor:"#fff"},{id:"music-1"},{round:!0,class:i.btn,type:"primary",onClick:c=>{c.stopPropagation(),L(t)}}),{default:()=>[x("试听"),s("img",{src:e.listActive===n&&e.playState==="play"?de:pe},null)]}):s(N,{color:"#259CFE",textColor:"#fff",round:!0,class:i.btn,type:"primary",onClick:c=>{c.stopPropagation(),L(t)}},{default:()=>[x("试听"),s("img",{src:e.listActive===n&&e.playState==="play"?de:pe},null)]}),s("img",{class:i.arrow,src:Fe},null)])])),s("div",{ref:l,class:[i.loadingWrap,e.finshed&&i.showLoading]},[s(ue,{show:!0},null)]),!e.loading&&e.list.length===0&&s("div",{class:i.empty},[s(fe,null,null)])])]),s("div",{class:i.musicStaff},[s("div",{class:i.musicName},[m.value.musicSheetName]),s("img",{id:"music-2",style:{display:m.value.id?"":"none"},class:[i.goBtn],src:Et,onClick:()=>{X("pause");let t="staff";e.showMusicImg==="first"?t="firstTone":e.showMusicImg==="fixed"?t="fixedTone":e.showMusicImg==="staff"&&(t="staff");const n="".concat(z(),"/instrument?v=").concat(+new Date,"&platform=pc&showGuide=true&id=").concat(m.value.id,"&Authorization=").concat(q.getToken,"&musicRenderType=").concat(t,"&showGuide=true&part-index=").concat(e.musicInstrumentIndex);window.matchMedia("(display-mode: standalone)").matches?(Xe.application=window.matchMedia("(display-mode: standalone)").matches,e.previewModal=!0,e.previewUrl=n,e.showPreivew=!1):window.open(n)}},null),s("div",{class:i.rightBtns,style:{display:m.value.id?"":"none"}},[R.value&&s(O,{options:e.trackList,trigger:"hover",value:e.musicInstrumentIndex,"onUpdate:value":[t=>e.musicInstrumentIndex=t,async t=>{}],class:[i.popSelect]},{default:()=>[s(N,{round:!0,class:[i.textBtn]},{default:()=>[e.trackName,s("i",{class:i.iconArrow},null)]})]}),e.showTransBtn&&s(O,{options:we,trigger:"hover",value:e.showMusicImg,"onUpdate:value":[t=>e.showMusicImg=t,async t=>{e.showMusicImg=t}],class:[i.popTrans]},{default:()=>[s("img",{class:[i.transBtn],src:Ut},null)]}),s("div",{class:i.favitor,onClick:()=>M()},[s(ke,{name:"favitor",mode:"out-in"},{default:()=>[m.value.favitor?s("img",{src:je,key:"1"},null):s("img",{src:Ge,key:"2"},null)]})])]),s("div",{class:i.staffImgs},[R.value?s("iframe",{id:"staffIframeRef",style:{width:"100%",height:"100%"},src:e.iframeSrc,onLoad:j},null):s(J,null,[Y.value.length>0?Y.value.map(t=>s("img",{src:t,key:t},null)):s(fe,null,null)])])])])])]),e.list.length!==0&&s(Ue,{show:e.showPlayer,playState:e.playState,item:m.value,onChange:t=>X(t)},null),y.value?s($t,null,null):null,s(Te,{show:e.previewModal,"onUpdate:show":[t=>e.previewModal=t,t=>{t||(e.previewUrl="")}],class:i.previewWindow,showIcon:!1,displayDirective:"show"},{default:()=>[s(ue,{show:e.showPreivew,style:"--n-opacity-spinning: 1;"},{default:()=>[s("img",{style:{display:e.showCloseBtn?"":"none"},src:Ft,class:i.previewClose,onClick:()=>{e.previewModal=!1,e.previewUrl=""}},null),s("iframe",{class:i.previewIframe,onLoad:()=>{e.showPreivew=!1},frameborder:"0",src:e.previewUrl},null)]})]})])}}});export{ss as default};