index-7761cb3c-1706862545052.js 17 KB

1
  1. import{d as fe,e as J,X as d,r as G,p as ge,H as ie,O as we,f as s,c1 as _e,bT as Ie,k as h,F as ne,c as oe,a as ke,u as Se,U as D,cm as xe,y as le,w as O,ck as be,cl as re,cn as W,j as P,v as Be,x as Ae,A as ce,W as Ce,a6 as Le,l as Te,aV as Ne,co as Pe}from"./index-6ad4ed72-1706862545052.js";import{i as Re}from"./icon_back-c5ec0a72-1706862545052.js";import{i as Me,P as Ee,a as ue,b as de,c as Ue,d as Fe}from"./index-df9ac3ec-1706862545052.js";import{T as $e}from"./index-6f712dff-1706862545052.js";import{i as Ge,a as je}from"./icon-collect-active-4272e308-1706862545052.js";import{i as De}from"./icon_default-d1bcaf5f-1706862545052.js";import{T as Oe}from"./index-8a9bdf52-1706862545052.js";import{u as We}from"./catchData-f7c2e350-1706862545052.js";import{c as ze,d as Ve,e as Je}from"./api-26ca54b6-1706862545052.js";import{g as z,s as v,a as qe,b as pe}from"./api-f1196699-1706862545052.js";import{T as me}from"./index-2d8c3c2d-1706862545052.js";import{s as Xe}from"./state-431f066c-1706862545052.js";import{u as He}from"./index-9b835c6b-1706862545052.js";import{a as V}from"./urlUtils-080cac35-1706862545052.js";import"./Slider-86de3b61-1706862545052.js";import"./index-118e1e19-1706862545052.js";const Ke="_container_1pkwd_1",Qe="_iconBack_1pkwd_6",Ye="_separator_1pkwd_39",Ze="_wrap_1pkwd_44",et="_wrapBottom_1pkwd_50",tt="_content_1pkwd_53",st="_tools_1pkwd_60",at="_contentWrap_1pkwd_84",it="_musicList_1pkwd_91",nt="_wrapList_1pkwd_105",ot="_empty_1pkwd_111",lt="_itemContainer_1pkwd_117",rt="_item_1pkwd_117",ct="_active_1pkwd_139",ut="_arrow_1pkwd_142",dt="_img_1pkwd_145",pt="_title_1pkwd_167",mt="_titleName_1pkwd_174",ft="_titleDes_1pkwd_181",gt="_btn_1pkwd_191",wt="_showPlayLoading_1pkwd_216",vt="_loadingWrap_1pkwd_219",ht="_showLoading_1pkwd_224",yt="_musicStaff_1pkwd_229",_t="_goBtn_1pkwd_244",It="_rightBtns_1pkwd_253",kt="_textBtn_1pkwd_260",St="_transBtn_1pkwd_268",xt="_favitor_1pkwd_273",bt="_musicName_1pkwd_288",Bt="_staffImgs_1pkwd_296",At="_previewWindow_1pkwd_313",Ct="_previewClose_1pkwd_318",Lt="_previewIframe_1pkwd_325",Tt="_popSelect_1pkwd_331",Nt="_popTrans_1pkwd_343",Pt="_iconArrow_1pkwd_354",Rt="_textBtnActive_1pkwd_366",i={container:Ke,iconBack:Qe,separator:Ye,wrap:Ze,wrapBottom:et,content:tt,tools:st,contentWrap:at,musicList:it,wrapList:nt,empty:ot,itemContainer:lt,item:rt,active:ct,arrow:ut,img:dt,title:pt,titleName:mt,titleDes:ft,btn:gt,showPlayLoading:wt,loadingWrap:vt,showLoading:ht,musicStaff:yt,goBtn:_t,rightBtns:It,textBtn:kt,transBtn:St,favitor:xt,musicName:bt,staffImgs:Bt,previewWindow:At,previewClose:Ct,previewIframe:Lt,popSelect:Tt,popTrans:Nt,iconArrow:Pt,textBtnActive:Rt},Mt=""+new URL("icon_goXiaoku-5d0db670.png",import.meta.url).href,Et=""+new URL("icon-close-1bf25bcf.png",import.meta.url).href,Ut=""+new URL("icon_trans-e9b9e2da.png",import.meta.url).href,Ft=fe({name:"music-guide",emits:["close"],setup(S,{emit:q}){const o=J({box:{height:"0px"},show:!1,steps:[{ele:"",eleRect:{},img:z("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:z("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:z("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}),w=G(!1),c=G({});(async()=>{var l;try{const p=await qe({guideTag:"teacher-guideInfo"});p.data?c.value=JSON.parse((l=p.data)==null?void 0:l.guideValue)||null:c.value={},c.value&&c.value.musicGuide?w.value=!1:w.value=!0}catch(p){console.log(p)}})();const y=()=>{var p,I,k,b;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=((I=o.steps[o.step].eleRectPadding)==null?void 0:I.top)||0,C=((k=o.steps[o.step].eleRectPadding)==null?void 0:k.width)||0,E=((b=o.steps[o.step].eleRectPadding)==null?void 0:b.height)||0;o.box={left:f.x-m+"px",top:f.y-M+"px",width:f.width+C+"px",height:f.height+E+"px"}}else _()},T=async l=>{try{if(l!=="xiaoku-music")return;c.value?c.value.musicGuide=!1:c.value={musicGuide:!1};try{await pe({guideTag:"teacher-guideInfo",guideValue:JSON.stringify(c.value)})}catch(p){console.log(p)}o.step=0,y(),w.value=!0}catch(p){}};ge(()=>{y(),window.addEventListener("resize",R),ie.on("teacher-guideInfo",l=>T(l))});const R=()=>{y()};we(()=>{window.removeEventListener("resize",R),ie.off("teacher-guideInfo",T)});const _=()=>{if(o.step>=3){x();return}o.step=o.step+1,y()},x=async()=>{c.value?c.value.musicGuide=!0:c.value={musicGuide:!0};try{const l=await pe({guideTag:"teacher-guideInfo",guideValue:JSON.stringify(c.value)})}catch(l){console.log(l)}w.value=!1};return()=>s(ne,null,[w.value?_e(s("div",{"onUpdate:show":l=>w.value=l,class:["n-modal-mask","n-modal-mask-guide"]},[s("div",{class:v.content,onClick:()=>_()},[s("div",{class:v.backBtn,onClick:l=>{l.stopPropagation(),x()}},[h("跳过")]),s("div",{class:v.box,style:{...o.box,...o.steps[o.step].boxStyle},id:"modeType-".concat(o.step)},[o.steps.map((l,p)=>{var I,k,b,f;return s("div",{onClick:m=>m.stopPropagation(),class:v.item,style:l.type=="bottom"?{display:p===o.step?"":"none",left:"".concat((I=l.eleRect)==null?void 0:I.left,"px"),top:"-".concat((k=l.imgStyle)==null?void 0:k.height)}:{display:p===o.step?"":"none",left:"".concat((b=l.eleRect)==null?void 0:b.left,"px"),top:"".concat((f=o.box)==null?void 0:f.height)}},[s("img",{class:v.img,style:l.imgStyle,src:l.img},null),s("div",{class:v.btns,style:l.btnsStyle},[o.step+1==o.steps.length?s(ne,null,[s("div",{class:[v.endBtn],onClick:()=>x()},[h("完成")]),s("div",{class:v.nextBtn,onClick:()=>{o.step=0,y()}},[h("再看一遍")])]):s("div",{class:v.btn,onClick:()=>_()},[h("下一步 ("),o.step+1,h("/"),o.steps.length,h(")")])])])})])])]),[[Ie,w.value,"show"]]):null])}});function $t(S){return typeof S=="function"||Object.prototype.toString.call(S)==="[object Object]"&&!Ne(S)}const ts=fe({name:"XiaokuMusic",setup(){const S=We(),q=oe(),o=ke(),w=Se(),c=J({page:1,rows:20,status:!0,name:"",musicSheetCategoriesId:o.query.id||""}),e=J({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=G(!1),T=oe(),R=async()=>{const a=S.getSubjectInstruments,t=sessionStorage.getItem("musicSubjectList")?JSON.parse(sessionStorage.getItem("musicSubjectList")):[],n=[];a.forEach(r=>{t.find(B=>B.id===r.id)&&n.push(r)}),e.tags=[{name:"全部",id:0,value:0,label:"全部"},...n]},_=async()=>{var t;e.loading=!0;let a={};try{a=await ze({...c,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<c.rows),e.list[e.listActive]&&k(e.list[e.listActive]),e.loading=!1,setTimeout(()=>{y.value=!0},500)},x=()=>{e.listActive=0,e.showPlayer=!1,e.playState="pause",c.page=1,e.finshed=!1,_()},l=G(),p=()=>{e.loading||e.finshed||(c.page=c.page+1,_())},I=a=>{var t;((t=a.data)==null?void 0:t.api)==="api_fingerPreView"&&(e.showCloseBtn=!a.data.state)};ge(async()=>{await S.getSubjects(),He(document.querySelector(".musicList-container"),t=>{const n=t[0],{height:r}=n.contentRect;document.documentElement.style.setProperty("--xiaoku-music-height",r+"px")}),R(),await _(),new IntersectionObserver(t=>{t[0].intersectionRatio>0&&p()}).observe(l.value),H(),window.addEventListener("message",I)}),we(()=>{window.removeEventListener("message",I)});const k=async a=>{const t=await Ve({type:"MUSIC",materialId:a.id});(t==null?void 0:t.code)===200&&(a.favitor=t.data)},b=a=>{const t=e.list.findIndex(n=>n.id===a.id);t>-1&&(e.listActive=t),k(a)},f=a=>{const t={};return a==null||a.forEach(n=>{n.id===e.tagIndex&&(t.selected=!0,t.name=n.name)}),t},m=D(()=>(e.list[e.listActive]&&"".concat(V(),"/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})},C=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)};D(()=>{const a=e.list[e.listActive],t=(a==null?void 0:a.musicalInstruments)||[],n=[];return t.forEach((r,g)=>{n.push({label:r.name,value:g})}),n});const E=D(()=>{const a=e.list[e.listActive],t=a==null?void 0:a.musicalInstruments;return!!(t&&t.length>1)}),U=()=>{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(V(),"/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]&&C(e.list[e.listActive-1]):a==="next"?e.list[e.listActive+1]&&C(e.list[e.listActive+1]):a==="favitor"&&M()},ve=[{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(r=>r.text());he(n)}}else{const{defaultScore:n,transferFlag:r}=a.musicalInstruments[0]||{};let g="staff";g=n==="STAVE"?"staff":n==="JIAN"?"fixed":n==="FIRST"?"first":"staff",e.showMusicImg=g,e.showTransBtn=r}},he=a=>{var Y,Z,F,ee,te,se,ae;const t=new DOMParser().parseFromString(a,"text/xml"),n=((Z=(Y=t.getElementsByTagName("part-list"))==null?void 0:Y[0])==null?void 0:Z.getElementsByTagName("score-part"))||[],r=Array.from(n).map(u=>{var A,$,L;return((L=($=(A=u.getElementsByTagName("part-name"))==null?void 0:A[0])==null?void 0:$.textContent)==null?void 0:L.trim())||""});t.getElementsByTagName("part"),((ee=(F=r[0])==null?void 0:F.toLocaleUpperCase)==null?void 0:ee.call(F))==="COMMON"&&r.shift();const g=(te=e.list[e.listActive])==null?void 0:te.multiTracksSelection,B=g?g==null?void 0:g.split(","):[],N=r.map((u,A)=>{const $=!!(B.length==0||B.includes(u)),L=xe(u),ye=Pe(L,A);return{label:u+(L?"(".concat(L,")"):""),value:A,sortId:ye,canselect:$,track:u}}).filter(u=>u.canselect).sort((u,A)=>u.sortId-A.sortId);e.trackList=N;let j=(se=N.find(u=>u.value===e.musicInstrumentIndex))==null?void 0:se.track;j=j.replace(/[0-9]+/g,"").replace(/\s/g,"").toLocaleLowerCase();let K="first",Q=!0;(ae=e.list[e.listActive])==null||ae.musicalInstruments.forEach(u=>{u.code.toLocaleLowerCase()===j&&(K=u.defaultScore==="STAVE"?"staff":u.defaultScore==="JIAN"?"fixed":(u.defaultScore==="FIRST","first"),Q=u.transferFlag)}),e.showTransBtn=Q,e.showMusicImg=K};return le(()=>e.listActive,async()=>{e.musicInstrumentIndex=0,H()}),le(()=>e.musicInstrumentIndex,async()=>{var a;e.trackName=((a=e.trackList.find(t=>t.value===e.musicInstrumentIndex))==null?void 0:a.label)||"切换声轨",U()}),()=>{let a;return s("div",{class:i.container},[s(O,{align:"center",wrapItem:!1,size:16},{default:()=>[s("img",{style:{cursor:"pointer"},src:Re,class:i.iconBack,onClick:()=>w.push({path:"/xiaoku-ai"})},null),s(be,{separator:""},{default:()=>[s(re,{onClick:()=>w.push({path:"/xiaoku-ai"})},{default:()=>[h("全部列表")]}),s("img",{class:i.separator,src:Me},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(O,{style:{width:"100%"},size:[24,12],wrapItem:!1},{default:()=>[s("div",{id:"music-0"},[s(O,{style:{width:"100%"},size:[24,12],wrapItem:!1},$t(a=e.tags.map(t=>t.instruments&&t.instruments.length>1?s(W,{options:t.instruments,trigger:"hover",value:e.tagIndex,"onUpdate:value":[n=>e.tagIndex=n,()=>{e.reshing=!0,document.querySelector(".musicList-container").scroll(0,0),x()}],key:t.value,class:[i.popSelect]},{default:()=>[s(P,{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(P,{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),x()}},{default:()=>[t.name]})))?a:{default:()=>[a]})])]}),s($e,{style:{marginLeft:"auto"},round:!0,border:!1,onSearch:t=>{c.name=t,e.reshing=!0,x()}},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:()=>{b(t),U()}},[s("div",{class:i.img},[s(Be,{lazy:!0,objectFit:"cover",previewDisabled:!0,src:t.titleImg||De,onLoad:r=>{r.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(P,Ae({color:"#259CFE",textColor:"#fff"},{id:"music-1"},{round:!0,class:i.btn,type:"primary",onClick:r=>{r.stopPropagation(),C(t)}}),{default:()=>[h("试听"),s("img",{src:e.listActive===n&&e.playState==="play"?ue:de},null)]}):s(P,{color:"#259CFE",textColor:"#fff",round:!0,class:i.btn,type:"primary",onClick:r=>{r.stopPropagation(),C(t)}},{default:()=>[h("试听"),s("img",{src:e.listActive===n&&e.playState==="play"?ue:de},null)]}),s("img",{class:i.arrow,src:Ue},null)])])),s("div",{ref:l,class:[i.loadingWrap,e.finshed&&i.showLoading]},[s(ce,{show:!0},null)]),!e.loading&&e.list.length===0&&s("div",{class:i.empty},[s(me,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:Mt,onClick:()=>{X("pause");let t="staff";e.showMusicImg==="first"?t="firstTone":e.showMusicImg==="fixed"?t="fixedTone":e.showMusicImg==="staff"&&(t="staff");const n="".concat(V(),"/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"}},[E.value&&s(W,{options:e.trackList,trigger:"hover",value:e.musicInstrumentIndex,"onUpdate:value":[t=>e.musicInstrumentIndex=t,async t=>{}],class:[i.popSelect]},{default:()=>[s(P,{round:!0,class:[i.textBtn]},{default:()=>[e.trackName,s("i",{class:i.iconArrow},null)]})]}),e.showTransBtn&&s(W,{options:ve,trigger:"hover",value:e.showMusicImg,"onUpdate:value":[t=>e.showMusicImg=t,async t=>{e.showMusicImg=t,U()}],class:[i.popTrans]},{default:()=>[s("img",{class:[i.transBtn],src:Ut},null)]}),s("div",{class:i.favitor,onClick:()=>M()},[s(Ce,{name:"favitor",mode:"out-in"},{default:()=>[m.value.favitor?s("img",{src:Ge,key:"1"},null):s("img",{src:je,key:"2"},null)]})])]),s("div",{class:i.staffImgs},[E.value?s("iframe",{id:"staffIframeRef",style:{width:"100%",height:"100%"},src:e.iframeSrc,onLoad:U},null):s(Le,{name:"van-fade"},{default:()=>{var t,n,r,g,B;return[(t=m.value)!=null&&t.musicSvg||(n=m.value)!=null&&n.musicImg?(B=((r=m.value)==null?void 0:r.musicSvg)||((g=m.value)==null?void 0:g.musicImg))==null?void 0:B.split(",").map(N=>s("img",{src:N,key:N},null)):s(me,null,null)]}})])])])])]),e.list.length!==0&&s(Fe,{show:e.showPlayer,playState:e.playState,item:m.value,onChange:t=>X(t)},null),y.value?s(Ft,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(ce,{show:e.showPreivew,style:"--n-opacity-spinning: 1;"},{default:()=>[s("img",{style:{display:e.showCloseBtn?"":"none"},src:Et,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{ts as default};