1 |
- import{d as ve,e as V,X as p,r as $,p as ge,H as ne,O as he,f as s,c1 as Ie,bT as Se,k as y,F as le,c as oe,a as xe,u as be,U,cm as Be,y as ce,w as D,ck as Ae,cl as re,cn as O,j as N,v as Ce,x as ke,A as ue,W as Le,a6 as Te,l as Ne,aV as Pe,co as Me}from"./index-f5a86b16-1706882452509.js";import{i as Re}from"./icon_back-c5ec0a72-1706882452509.js";import{i as Ee,P as Fe,a as pe,b as de,c as Ue,d as $e}from"./index-9ac67cff-1706882452509.js";import{T as Ge}from"./index-d0ad6070-1706882452509.js";import{i as je,a as De}from"./icon-collect-active-4272e308-1706882452509.js";import{i as Oe}from"./icon_default-d1bcaf5f-1706882452509.js";import{T as We}from"./index-f8be86e8-1706882452509.js";import{u as ze}from"./catchData-557c9c01-1706882452509.js";import{c as Ve,d as Je,e as qe}from"./api-743c4898-1706882452509.js";import{g as W,s as w,a as Xe,b as me}from"./api-fb529348-1706882452509.js";import{T as fe}from"./index-dcd64cc7-1706882452509.js";import{s as He}from"./state-6ce04b36-1706882452509.js";import{u as Ke}from"./index-abb91ec6-1706882452509.js";import{a as z}from"./urlUtils-080cac35-1706882452509.js";import"./Slider-bd85da84-1706882452509.js";import"./index-0239170e-1706882452509.js";const Qe="_container_lv7pn_1",Ye="_iconBack_lv7pn_6",Ze="_separator_lv7pn_39",et="_wrap_lv7pn_44",tt="_wrapBottom_lv7pn_50",st="_content_lv7pn_53",at="_tools_lv7pn_60",it="_contentWrap_lv7pn_84",nt="_musicList_lv7pn_91",lt="_wrapList_lv7pn_105",ot="_empty_lv7pn_111",ct="_itemContainer_lv7pn_117",rt="_item_lv7pn_117",ut="_active_lv7pn_139",pt="_arrow_lv7pn_142",dt="_img_lv7pn_145",mt="_title_lv7pn_167",ft="_titleName_lv7pn_174",vt="_titleDes_lv7pn_181",gt="_btn_lv7pn_191",ht="_showPlayLoading_lv7pn_216",wt="_loadingWrap_lv7pn_219",yt="_showLoading_lv7pn_224",_t="_musicStaff_lv7pn_229",It="_goBtn_lv7pn_244",St="_rightBtns_lv7pn_253",xt="_textBtn_lv7pn_260",bt="_transBtn_lv7pn_268",Bt="_favitor_lv7pn_273",At="_musicName_lv7pn_288",Ct="_staffImgs_lv7pn_296",kt="_previewWindow_lv7pn_313",Lt="_previewClose_lv7pn_318",Tt="_previewIframe_lv7pn_325",Nt="_popSelect_lv7pn_331",Pt="_popSelect1_lv7pn_343",Mt="_popTrans_lv7pn_353",Rt="_iconArrow_lv7pn_364",Et="_textBtnActive_lv7pn_376",i={container:Qe,iconBack:Ye,separator:Ze,wrap:et,wrapBottom:tt,content:st,tools:at,contentWrap:it,musicList:nt,wrapList:lt,empty:ot,itemContainer:ct,item:rt,active:ut,arrow:pt,img:dt,title:mt,titleName:ft,titleDes:vt,btn:gt,showPlayLoading:ht,loadingWrap:wt,showLoading:yt,musicStaff:_t,goBtn:It,rightBtns:St,textBtn:xt,transBtn:bt,favitor:Bt,musicName:At,staffImgs:Ct,previewWindow:kt,previewClose:Lt,previewIframe:Tt,popSelect:Nt,popSelect1:Pt,popTrans:Mt,iconArrow:Rt,textBtnActive:Et},Ft=""+new URL("icon_goXiaoku-5d0db670.png",import.meta.url).href,Ut=""+new URL("icon-close-1bf25bcf.png",import.meta.url).href,$t=""+new URL("icon_trans-e9b9e2da.png",import.meta.url).href,Gt=ve({name:"music-guide",emits:["close"],setup(b,{emit:J}){const l=V({box:{height:"0px"},show:!1,steps:[{ele:"",eleRect:{},img:W("music1.png"),handStyle:{top:"0.91rem"},imgStyle:{top:p(-4),left:p(0),width:p(533),height:p(271)},btnsStyle:{bottom:p(40),left:p(159)},eleRectPadding:{left:7,top:7,width:14,height:14},boxStyle:{}},{ele:"",img:W("music2.png"),imgStyle:{top:p(-4),left:p(-205),width:p(420),height:p(228)},btnsStyle:{bottom:p(35),left:p(-48)},boxStyle:{borderRadius:"25px"},eleRectPadding:{left:7,top:7,width:14,height:14}},{ele:"",img:W("music3.png"),imgStyle:{top:"100%",left:p(-130),width:p(401),height:p(304)},btnsStyle:{bottom:p(100),left:p(30)},boxStyle:{borderRadius:"40px"},eleRectPadding:{left:7,top:7,width:14,height:14},type:"bottom"}],step:0}),h=$(!1),r=$({});(async()=>{var o;try{const d=await Xe({guideTag:"teacher-guideInfo"});d.data?r.value=JSON.parse((o=d.data)==null?void 0:o.guideValue)||null:r.value={},r.value&&r.value.musicGuide?h.value=!1:h.value=!0}catch(d){console.log(d)}})();const _=()=>{var d,S,x,A;const o=document.getElementById("music-".concat(l.step));if(o){const f=o.getBoundingClientRect();if(console.log(o.style.display,"ele"),o.style.display=="none"){I();return}const m=((d=l.steps[l.step].eleRectPadding)==null?void 0:d.left)||0,M=((S=l.steps[l.step].eleRectPadding)==null?void 0:S.top)||0,k=((x=l.steps[l.step].eleRectPadding)==null?void 0:x.width)||0,R=((A=l.steps[l.step].eleRectPadding)==null?void 0:A.height)||0;l.box={left:f.x-m+"px",top:f.y-M+"px",width:f.width+k+"px",height:f.height+R+"px"}}else I()},T=async o=>{try{if(o!=="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(d){console.log(d)}l.step=0,_(),h.value=!0}catch(d){}};ge(()=>{_(),window.addEventListener("resize",P),ne.on("teacher-guideInfo",o=>T(o))});const P=()=>{_()};he(()=>{window.removeEventListener("resize",P),ne.off("teacher-guideInfo",T)});const I=()=>{if(l.step>=3){B();return}l.step=l.step+1,_()},B=async()=>{r.value?r.value.musicGuide=!0:r.value={musicGuide:!0};try{const o=await me({guideTag:"teacher-guideInfo",guideValue:JSON.stringify(r.value)})}catch(o){console.log(o)}h.value=!1};return()=>s(le,null,[h.value?Ie(s("div",{"onUpdate:show":o=>h.value=o,class:["n-modal-mask","n-modal-mask-guide"]},[s("div",{class:w.content,onClick:()=>I()},[s("div",{class:w.backBtn,onClick:o=>{o.stopPropagation(),B()}},[y("跳过")]),s("div",{class:w.box,style:{...l.box,...l.steps[l.step].boxStyle},id:"modeType-".concat(l.step)},[l.steps.map((o,d)=>{var S,x,A,f;return s("div",{onClick:m=>m.stopPropagation(),class:w.item,style:o.type=="bottom"?{display:d===l.step?"":"none",left:"".concat((S=o.eleRect)==null?void 0:S.left,"px"),top:"-".concat((x=o.imgStyle)==null?void 0:x.height)}:{display:d===l.step?"":"none",left:"".concat((A=o.eleRect)==null?void 0:A.left,"px"),top:"".concat((f=l.box)==null?void 0:f.height)}},[s("img",{class:w.img,style:o.imgStyle,src:o.img},null),s("div",{class:w.btns,style:o.btnsStyle},[l.step+1==l.steps.length?s(le,null,[s("div",{class:[w.endBtn],onClick:()=>B()},[y("完成")]),s("div",{class:w.nextBtn,onClick:()=>{l.step=0,_()}},[y("再看一遍")])]):s("div",{class:w.btn,onClick:()=>I()},[y("下一步 ("),l.step+1,y("/"),l.steps.length,y(")")])])])})])])]),[[Se,h.value,"show"]]):null])}});function jt(b){return typeof b=="function"||Object.prototype.toString.call(b)==="[object Object]"&&!Pe(b)}const as=ve({name:"XiaokuMusic",setup(){const b=ze(),J=oe(),l=xe(),h=be(),r=V({page:1,rows:20,status:!0,name:"",musicSheetCategoriesId:l.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:"切换声轨"}),_=$(!1),T=oe(),P=async()=>{const a=b.getSubjectInstruments,t=sessionStorage.getItem("musicSubjectList")?JSON.parse(sessionStorage.getItem("musicSubjectList")):[],n=[];a.forEach(c=>{t.find(g=>g.id===c.id)&&n.push(c)}),e.tags=[{name:"全部",id:0,value:0,label:"全部"},...n]},I=async()=>{var t;e.loading=!0;let a={};try{a=await Ve({...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]&&x(e.list[e.listActive]),e.loading=!1,setTimeout(()=>{_.value=!0},500)},B=()=>{e.listActive=0,e.showPlayer=!1,e.playState="pause",r.page=1,e.finshed=!1,I()},o=$(),d=()=>{e.loading||e.finshed||(r.page=r.page+1,I())},S=a=>{var t;((t=a.data)==null?void 0:t.api)==="api_fingerPreView"&&(e.showCloseBtn=!a.data.state)};ge(async()=>{await b.getSubjects(),Ke(document.querySelector(".musicList-container"),t=>{const n=t[0],{height:c}=n.contentRect;document.documentElement.style.setProperty("--xiaoku-music-height",c+"px")}),P(),await I(),new IntersectionObserver(t=>{t[0].intersectionRatio>0&&d()}).observe(o.value),X(),window.addEventListener("message",S)}),he(()=>{window.removeEventListener("message",S)});const x=async a=>{const t=await Je({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),x(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,qe({favoriteFlag:e.list[e.listActive].favitor,type:"MUSIC",materialId:e.list[e.listActive].id})},k=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,v)=>{n.push({label:c.name,value:v})}),n});const R=U(()=>{const a=e.list[e.listActive],t=a==null?void 0:a.musicalInstruments;return!!(t&&t.length>1)}),G=()=>{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)},q=a=>{a==="play"?e.playState="play":a==="pause"?e.playState="pause":a==="pre"?e.list[e.listActive-1]&&k(e.list[e.listActive-1]):a==="next"?e.list[e.listActive+1]&&k(e.list[e.listActive+1]):a==="favitor"&&M()},we=[{value:"staff",label:"五线谱"},{value:"first",label:"首调"},{value:"fixed",label:"固定调"}],X=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());ye(n)}}else{const{defaultScore:n,transferFlag:c}=a.musicalInstruments[0]||{};let v="staff";v=n==="STAVE"?"staff":n==="JIAN"?"fixed":n==="FIRST"?"first":"staff",e.showMusicImg=v,e.showTransBtn=c}},ye=a=>{var Z,ee,E,te,se,ae,ie;const t=new DOMParser().parseFromString(a,"text/xml"),n=((ee=(Z=t.getElementsByTagName("part-list"))==null?void 0:Z[0])==null?void 0:ee.getElementsByTagName("score-part"))||[],c=Array.from(n).map(u=>{var C,F,L;return((L=(F=(C=u.getElementsByTagName("part-name"))==null?void 0:C[0])==null?void 0:F.textContent)==null?void 0:L.trim())||""});t.getElementsByTagName("part"),((te=(E=c[0])==null?void 0:E.toLocaleUpperCase)==null?void 0:te.call(E))==="COMMON"&&c.shift();const v=(se=e.list[e.listActive])==null?void 0:se.multiTracksSelection,g=v?v==null?void 0:v.split(","):[],K=c.map((u,C)=>{const F=!!(g.length==0||g.includes(u)),L=Be(u),_e=Me(L,C);return{label:u+(L?"(".concat(L,")"):""),value:C,sortId:_e,canselect:F,track:u}}).filter(u=>u.canselect).sort((u,C)=>u.sortId-C.sortId);e.trackList=K;let j=(ae=K.find(u=>u.value===e.musicInstrumentIndex))==null?void 0:ae.track;j=j.replace(/[0-9]+/g,"").replace(/\s/g,"").toLocaleLowerCase();let Q="first",Y=!0;(ie=e.list[e.listActive])==null||ie.musicalInstruments.forEach(u=>{u.code.toLocaleLowerCase()===j&&(Q=u.defaultScore==="STAVE"?"staff":u.defaultScore==="JIAN"?"fixed":(u.defaultScore==="FIRST","first"),Y=u.transferFlag)}),e.showTransBtn=Y,e.showMusicImg=Q};ce(()=>e.listActive,async()=>{e.musicInstrumentIndex=0,X()}),ce(()=>e.musicInstrumentIndex,async()=>{var a;e.trackName=((a=e.trackList.find(t=>t.value===e.musicInstrumentIndex))==null?void 0:a.label)||"切换声轨",G()});const H=U(()=>{var t,n,c,v;let a=[];if(e.showMusicImg==="first"){const g=(t=m.value)==null?void 0:t.musicFirstSvg;a=g?g.split(","):[]}else if(e.showMusicImg==="fixed"){const g=(n=m.value)==null?void 0:n.musicJianSvg;a=g?g.split(","):[]}else if(e.showMusicImg==="staff"){const g=((c=m.value)==null?void 0:c.musicImg)||((v=m.value)==null?void 0:v.musicSvg);a=g?g.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:Re,class:i.iconBack,onClick:()=>h.push({path:"/xiaoku-ai"})},null),s(Ae,{separator:""},{default:()=>[s(re,{onClick:()=>h.push({path:"/xiaoku-ai"})},{default:()=>[y("全部列表")]}),s("img",{class:i.separator,src:Ee},null),s(re,null,{default:()=>[l.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(Ge,{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),G()}},[s("div",{class:i.img},[s(Ce,{lazy:!0,objectFit:"cover",previewDisabled:!0,src:t.titleImg||Oe,onLoad:c=>{c.target.dataset.loaded="true"}},null),s(Fe,{class:[e.listActive===n&&e.playState==="play"?"":i.showPlayLoading]},null)]),s("div",{class:i.title},[s("div",{class:i.titleName},[s(We,{text:t.musicSheetName},null)]),s("div",{class:i.titleDes},[t.composer])]),n==0?s(N,ke({color:"#259CFE",textColor:"#fff"},{id:"music-1"},{round:!0,class:i.btn,type:"primary",onClick:c=>{c.stopPropagation(),k(t)}}),{default:()=>[y("试听"),s("img",{src:e.listActive===n&&e.playState==="play"?pe:de},null)]}):s(N,{color:"#259CFE",textColor:"#fff",round:!0,class:i.btn,type:"primary",onClick:c=>{c.stopPropagation(),k(t)}},{default:()=>[y("试听"),s("img",{src:e.listActive===n&&e.playState==="play"?pe:de},null)]}),s("img",{class:i.arrow,src:Ue},null)])])),s("div",{ref:o,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:Ft,onClick:()=>{q("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(J.getToken,"&musicRenderType=").concat(t,"&showGuide=true&part-index=").concat(e.musicInstrumentIndex);window.matchMedia("(display-mode: standalone)").matches?(He.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:$t},null)]}),s("div",{class:i.favitor,onClick:()=>M()},[s(Le,{name:"favitor",mode:"out-in"},{default:()=>[m.value.favitor?s("img",{src:je,key:"1"},null):s("img",{src:De,key:"2"},null)]})])]),s("div",{class:i.staffImgs},[R.value?s("iframe",{id:"staffIframeRef",style:{width:"100%",height:"100%"},src:e.iframeSrc,onLoad:G},null):s(Te,{name:"van-fade"},{default:()=>[H.value.length>0?H.value.map(t=>s("img",{src:t,key:t},null)):s(fe,null,null)]})])])])])]),e.list.length!==0&&s($e,{show:e.showPlayer,playState:e.playState,item:m.value,onChange:t=>q(t)},null),_.value?s(Gt,null,null):null,s(Ne,{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:Ut,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{as as default};
|