1 |
- import{d as fe,e as J,_ as g,r as G,p as ve,A as le,Q as he,f as s,U as Ie,V as Se,k as y,F as q,c as re,a as xe,u as be,X as $,aJ as Be,y as D,w as z,aK as Ae,aL as ce,ay as O,j as P,v as Ce,x as Le,C as ue,Z as ke,l as Te,B as Ne,aM as Me}from"./index-b5d795c3-1711617551545.js";import{i as Pe}from"./icon_back-c5ec0a72-1711617551545.js";import{i as Re}from"./icon_separator-e0f6c575-1711617551545.js";import{T as Ee}from"./index-45f92ba4-1711617551545.js";import{P as Fe,T as Ue,i as ge,a as de,b as $e,c as Ge}from"./index-1c020504-1711617551545.js";import{i as je,a as De}from"./icon-collect-active-4272e308-1711617551545.js";import{i as ze}from"./icon_default-d1bcaf5f-1711617551545.js";import{u as Oe}from"./catchData-cd60b28d-1711617551545.js";import{c as We,d as Ve,e as Je}from"./api-c04c7c4b-1711617551545.js";import{g as W,s as w,a as qe,b as pe}from"./api-9a7b72d1-1711617551545.js";import{T as me}from"./index-6ff67e88-1711617551545.js";import{s as Xe}from"./state-d3d93622-1711617551545.js";import{u as He}from"./index-4806286c-1711617551545.js";import{a as V}from"./urlUtils-ae95598a-1711617551545.js";import"./Slider-ad466832-1711617551545.js";import"./index-08708473-1711617551545.js";const Ke="_container_1g7gg_1",Qe="_iconBack_1g7gg_6",Ze="_separator_1g7gg_39",Ye="_wrap_1g7gg_44",et="_wrapBottom_1g7gg_50",tt="_content_1g7gg_53",st="_tools_1g7gg_60",at="_contentWrap_1g7gg_84",it="_musicList_1g7gg_91",nt="_wrapList_1g7gg_105",ot="_empty_1g7gg_111",lt="_itemContainer_1g7gg_117",rt="_item_1g7gg_117",ct="_active_1g7gg_139",ut="_arrow_1g7gg_142",gt="_img_1g7gg_145",dt="_title_1g7gg_167",pt="_titleName_1g7gg_174",mt="_titleDes_1g7gg_181",ft="_btn_1g7gg_191",vt="_showPlayLoading_1g7gg_216",ht="_loadingWrap_1g7gg_219",wt="_showLoading_1g7gg_224",yt="_musicStaff_1g7gg_229",_t="_goBtn_1g7gg_244",It="_rightBtns_1g7gg_253",St="_textBtn_1g7gg_260",xt="_transBtn_1g7gg_268",bt="_favitor_1g7gg_273",Bt="_musicName_1g7gg_288",At="_staffImgs_1g7gg_296",Ct="_previewWindow_1g7gg_313",Lt="_previewClose_1g7gg_318",kt="_previewIframe_1g7gg_325",Tt="_popSelect_1g7gg_331",Nt="_popSelect1_1g7gg_343",Mt="_popTrans_1g7gg_353",Pt="_iconArrow_1g7gg_364",Rt="_textBtnActive_1g7gg_376",n={container:Ke,iconBack:Qe,separator:Ze,wrap:Ye,wrapBottom:et,content:tt,tools:st,contentWrap:at,musicList:it,wrapList:nt,empty:ot,itemContainer:lt,item:rt,active:ct,arrow:ut,img:gt,title:dt,titleName:pt,titleDes:mt,btn:ft,showPlayLoading:vt,loadingWrap:ht,showLoading:wt,musicStaff:yt,goBtn:_t,rightBtns:It,textBtn:St,transBtn:xt,favitor:bt,musicName:Bt,staffImgs:At,previewWindow:Ct,previewClose:Lt,previewIframe:kt,popSelect:Tt,popSelect1:Nt,popTrans:Mt,iconArrow:Pt,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=fe({name:"music-guide",emits:["close"],setup(b,{emit:X}){const o=J({box:{height:"0px"},show:!1,steps:[{ele:"",eleRect:{},img:W("music1.png"),handStyle:{top:"0.91rem"},imgStyle:{top:g(-4),left:g(0),width:g(533),height:g(271)},btnsStyle:{bottom:g(40),left:g(159)},eleRectPadding:{left:7,top:7,width:14,height:14},boxStyle:{}},{ele:"",img:W("music2.png"),imgStyle:{top:g(-4),left:g(-205),width:g(420),height:g(228)},btnsStyle:{bottom:g(35),left:g(-48)},boxStyle:{borderRadius:"25px"},eleRectPadding:{left:7,top:7,width:14,height:14}},{ele:"",img:W("music3.png"),imgStyle:{top:"100%",left:g(-130),width:g(401),height:g(304)},btnsStyle:{bottom:g(100),left:g(30)},boxStyle:{borderRadius:"40px"},eleRectPadding:{left:7,top:7,width:14,height:14},type:"bottom"}],step:0}),h=G(!1),c=G({});(async()=>{var l;try{const d=await qe({guideTag:"teacher-guideInfo"});d.data?c.value=JSON.parse((l=d.data)==null?void 0:l.guideValue)||null:c.value={},c.value&&c.value.musicGuide?h.value=!1:h.value=!0}catch(d){console.log(d)}})();const _=()=>{var d,S,x,A;const l=document.getElementById("music-".concat(o.step));if(l){const m=l.getBoundingClientRect();if(console.log(l.style.display,"ele"),l.style.display=="none"){I();return}const p=((d=o.steps[o.step].eleRectPadding)==null?void 0:d.left)||0,E=((S=o.steps[o.step].eleRectPadding)==null?void 0:S.top)||0,k=((x=o.steps[o.step].eleRectPadding)==null?void 0:x.width)||0,C=((A=o.steps[o.step].eleRectPadding)==null?void 0:A.height)||0;o.box={left:m.x-p+"px",top:m.y-E+"px",width:m.width+k+"px",height:m.height+C+"px"}}else I()},M=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(d){console.log(d)}o.step=0,_(),h.value=!0}catch(d){}};ve(()=>{_(),window.addEventListener("resize",R),le.on("teacher-guideInfo",l=>M(l))});const R=()=>{_()};he(()=>{window.removeEventListener("resize",R),le.off("teacher-guideInfo",M)});const I=()=>{if(o.step>=3){B();return}o.step=o.step+1,_()},B=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)}h.value=!1};return()=>s(q,null,[h.value?Ie(s("div",{"onUpdate:show":l=>h.value=l,class:["n-modal-mask","n-modal-mask-guide"]},[s("div",{class:w.content,onClick:()=>I()},[s("div",{class:w.backBtn,onClick:l=>{l.stopPropagation(),B()}},[y("跳过")]),s("div",{class:w.box,style:{...o.box,...o.steps[o.step].boxStyle},id:"modeType-".concat(o.step)},[o.steps.map((l,d)=>{var S,x,A,m;return s("div",{onClick:p=>p.stopPropagation(),class:w.item,style:l.type=="bottom"?{display:d===o.step?"":"none",left:"".concat((S=l.eleRect)==null?void 0:S.left,"px"),top:"-".concat((x=l.imgStyle)==null?void 0:x.height)}:{display:d===o.step?"":"none",left:"".concat((A=l.eleRect)==null?void 0:A.left,"px"),top:"".concat((m=o.box)==null?void 0:m.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(q,null,[s("div",{class:[w.endBtn],onClick:()=>B()},[y("完成")]),s("div",{class:w.nextBtn,onClick:()=>{o.step=0,_()}},[y("再看一遍")])]):s("div",{class:w.btn,onClick:()=>I()},[y("下一步 ("),o.step+1,y("/"),o.steps.length,y(")")])])])})])])]),[[Se,h.value,"show"]]):null])}});function Gt(b){return typeof b=="function"||Object.prototype.toString.call(b)==="[object Object]"&&!Ne(b)}const ss=fe({name:"XiaokuMusic",setup(){const b=Oe(),X=re(),o=xe(),h=be(),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:"切换声轨"}),_=G(!1),M=re(),R=async()=>{const a=b.getSubjectInstruments,t=sessionStorage.getItem("musicSubjectList")?JSON.parse(sessionStorage.getItem("musicSubjectList")):[],i=[];a.forEach(r=>{t.find(v=>v.id===r.id)&&i.push(r)}),e.tags=[{name:"全部",id:0,value:0,label:"全部"},...i]},I=async()=>{var t;e.loading=!0;let a={};try{a=await We({...c,musicalInstrumentId:e.tagIndex?e.tagIndex:""})}catch(i){console.log(i)}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.finshed=!0,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",c.page=1,e.finshed=!1,I()},l=G(),d=()=>{e.loading||e.finshed||(c.page=c.page+1,I())},S=a=>{var t;((t=a.data)==null?void 0:t.api)==="api_fingerPreView"&&(e.showCloseBtn=!a.data.state)};ve(async()=>{await b.getSubjects(),He(document.querySelector(".musicList-container"),t=>{const i=t[0],{height:r}=i.contentRect;document.documentElement.style.setProperty("--xiaoku-music-height",r+"px")}),R(),await I(),new IntersectionObserver(t=>{t[0].intersectionRatio>0&&d()}).observe(l.value),K(),window.addEventListener("message",S)}),he(()=>{window.removeEventListener("message",S)});const x=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(i=>i.id===a.id);t>-1&&(e.listActive=t),x(a)},m=a=>{const t={};return a==null||a.forEach(i=>{i.id===e.tagIndex&&(t.selected=!0,t.name=i.name)}),t},p=$(()=>(e.list[e.listActive]&&"".concat(V(),"/instrument?modelType=practise&id=").concat(e.list[e.listActive].xmlFileUrl,"&Authorization=").concat(M.getToken,"/#/preview"),e.list[e.listActive]||{})),E=()=>{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})},k=a=>{const t=e.list.findIndex(i=>i.id===a.id);t>-1&&(e.listActive===t?e.playState=e.playState==="play"?"pause":"play":e.playState="play",e.showPlayer=!0,e.listActive=t)};$(()=>{const a=e.list[e.listActive],t=(a==null?void 0:a.musicalInstruments)||[],i=[];return t.forEach((r,f)=>{i.push({label:r.name,value:f})}),i});const C=$(()=>{const a=e.list[e.listActive],t=a==null?void 0:a.musicalInstruments;return!!(t&&t.length>1)}),T=()=>{const a=M.getToken,t=e.list[e.listActive],i=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(i)},H=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"&&E()},we=[{value:"staff",label:"五线谱"},{value:"first",label:"首调"},{value:"fixed",label:"固定调"}],K=async()=>{var t;const a=e.list[e.listActive];if(((t=a.musicalInstruments)==null?void 0:t.length)>1){if(a.xmlFileUrl){const i=await fetch(a.xmlFileUrl).then(r=>r.text());ye(i)}}else{const{defaultScore:i,transferFlag:r}=a.musicalInstruments[0]||{};let f="staff";f=i==="STAVE"?"staff":i==="JIAN"?"fixed":i==="FIRST"?"first":"staff",e.showMusicImg=f,e.showTransBtn=r}},ye=a=>{var te,se,F,ae,ie,ne,oe;const t=new DOMParser().parseFromString(a,"text/xml"),i=((se=(te=t.getElementsByTagName("part-list"))==null?void 0:te[0])==null?void 0:se.getElementsByTagName("score-part"))||[],r=Array.from(i).map(u=>{var L,U,N;return((N=(U=(L=u.getElementsByTagName("part-name"))==null?void 0:L[0])==null?void 0:U.textContent)==null?void 0:N.trim())||""});t.getElementsByTagName("part"),((ae=(F=r[0])==null?void 0:F.toLocaleUpperCase)==null?void 0:ae.call(F))==="COMMON"&&r.shift();const f=(ie=e.list[e.listActive])==null?void 0:ie.multiTracksSelection,v=f?f==null?void 0:f.split(","):[],Z=r.map((u,L)=>{const U=!!(v.length==0||v.includes(u)),N=Be(u),_e=Me(N,L);return{label:u+(N?"(".concat(N,")"):""),value:L,sortId:_e,canselect:U,track:u}}).filter(u=>u.canselect).sort((u,L)=>u.sortId-L.sortId);e.trackList=Z;let j=(ne=Z.find(u=>u.value===e.musicInstrumentIndex))==null?void 0:ne.track;j=j.replace(/[0-9]+/g,"").replace(/\s/g,"").toLocaleLowerCase();let Y="first",ee=!0;(oe=e.list[e.listActive])==null||oe.musicalInstruments.forEach(u=>{u.code.toLocaleLowerCase()===j&&(Y=u.defaultScore==="STAVE"?"staff":u.defaultScore==="JIAN"?"fixed":(u.defaultScore==="FIRST","first"),ee=u.transferFlag)}),e.showTransBtn=ee,e.showMusicImg=Y};D(()=>e.listActive,async()=>{e.musicInstrumentIndex=0,K()}),D(()=>e.musicInstrumentIndex,async()=>{var a;e.trackName=((a=e.trackList.find(t=>t.value===e.musicInstrumentIndex))==null?void 0:a.label)||"切换声轨",T()}),D(()=>e.showMusicImg,()=>{C.value&&T()});const Q=$(()=>{var t,i,r,f;let a=[];if(e.showMusicImg==="first"){const v=(t=p.value)==null?void 0:t.musicFirstImg;a=v?v.split(","):[]}else if(e.showMusicImg==="fixed"){const v=(i=p.value)==null?void 0:i.musicJianImg;a=v?v.split(","):[]}else if(e.showMusicImg==="staff"){const v=((r=p.value)==null?void 0:r.musicImg)||((f=p.value)==null?void 0:f.musicSvg);a=v?v.split(","):[]}return a});return()=>{let a;return s("div",{class:n.container},[s(z,{align:"center",wrapItem:!1,size:16},{default:()=>[s("img",{style:{cursor:"pointer"},src:Pe,class:n.iconBack,onClick:()=>h.push({path:"/xiaoku-ai"})},null),s(Ae,{separator:""},{default:()=>[s(ce,{onClick:()=>h.push({path:"/xiaoku-ai"})},{default:()=>[y("全部列表")]}),s("img",{class:n.separator,src:Re},null),s(ce,null,{default:()=>[o.query.name]})]})]}),s("div",{class:[n.wrap,e.showPlayer?n.wrapBottom:""]},[s("div",{class:n.content},[s("div",{class:n.tools},[s(z,{style:{width:"100%"},size:[24,12],wrapItem:!1},{default:()=>[s("div",{id:"music-0"},[s(z,{style:{width:"100%"},size:[24,12],wrapItem:!1},Gt(a=e.tags.map(t=>t.instruments&&t.instruments.length>1?s(O,{options:t.instruments,trigger:"hover",value:e.tagIndex,"onUpdate:value":[i=>e.tagIndex=i,()=>{e.reshing=!0,document.querySelector(".musicList-container").scroll(0,0),B()}],key:t.value,class:[n.popSelect1]},{default:()=>[s(P,{round:!0,textColor:m(t.instruments).selected?"#fff":"#000",color:m(t.instruments).selected?"#198CFE":"#fff",type:m(t.instruments).selected?"primary":"default",class:[n.textBtn,m(t.instruments).selected&&n.textBtnActive]},{default:()=>[m(t.instruments).name||t.name,s("i",{class:n.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),B()}},{default:()=>[t.name]})))?a:{default:()=>[a]})])]}),s(Ee,{style:{marginLeft:"auto"},round:!0,border:!1,onSearch:t=>{c.name=t,e.reshing=!0,B()}},null)]),s("div",{class:n.contentWrap},[s("div",{class:[n.musicList,"musicList-container"]},[s("div",{class:[n.wrapList,"music-wrap-list"]},[e.list.map((t,i)=>s("div",{class:n.itemContainer},[s("div",{class:[n.item,e.listActive===i&&n.active],onClick:()=>{A(t),T()}},[s("div",{class:n.img},[s(Ce,{lazy:!0,objectFit:"cover",previewDisabled:!0,src:t.titleImg||ze,onLoad:r=>{r.target.dataset.loaded="true"}},null),s(Fe,{class:[e.listActive===i&&e.playState==="play"?"":n.showPlayLoading]},null)]),s("div",{class:n.title},[s("div",{class:n.titleName},[s(Ue,{text:t.musicSheetName},null)]),s("div",{class:n.titleDes},[t.composer])]),i==0?s(P,Le({color:"#259CFE",textColor:"#fff"},{id:"music-1"},{round:!0,class:n.btn,type:"primary",onClick:r=>{r.stopPropagation(),k(t),e.listActive===i&&e.playState==="play"&&C.value&&T()}}),{default:()=>[y("试听"),s("img",{src:e.listActive===i&&e.playState==="play"?ge:de},null)]}):s(P,{color:"#259CFE",textColor:"#fff",round:!0,class:n.btn,type:"primary",onClick:r=>{r.stopPropagation(),k(t),e.listActive===i&&e.playState==="play"&&C.value&&T()}},{default:()=>[y("试听"),s("img",{src:e.listActive===i&&e.playState==="play"?ge:de},null)]}),s("img",{class:n.arrow,src:$e},null)])])),s("div",{ref:l,class:[n.loadingWrap,e.finshed&&n.showLoading]},[s(ue,{show:!0},null)]),!e.loading&&e.list.length===0&&s("div",{class:n.empty},[s(me,null,null)])])]),s("div",{class:n.musicStaff},[s("div",{class:n.musicName},[p.value.musicSheetName]),s("img",{id:"music-2",style:{display:p.value.id?"":"none"},class:[n.goBtn],src:Et,onClick:()=>{H("pause");let t="staff";e.showMusicImg==="first"?t="firstTone":e.showMusicImg==="fixed"?t="fixedTone":e.showMusicImg==="staff"&&(t="staff");const i="".concat(V(),"/instrument?v=").concat(+new Date,"&platform=pc&showGuide=true&id=").concat(p.value.id,"&Authorization=").concat(X.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=i,e.showPreivew=!1):window.open(i)}},null),s("div",{class:n.rightBtns,style:{display:p.value.id?"":"none"}},[C.value&&s(O,{options:e.trackList,trigger:"hover",value:e.musicInstrumentIndex,"onUpdate:value":[t=>e.musicInstrumentIndex=t,async t=>{}],class:[n.popSelect]},{default:()=>[s(P,{round:!0,class:[n.textBtn]},{default:()=>[e.trackName,s("i",{class:n.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:[n.popTrans]},{default:()=>[s("img",{class:[n.transBtn],src:Ut},null)]}),s("div",{class:n.favitor,onClick:()=>E()},[s(ke,{name:"favitor",mode:"out-in"},{default:()=>[p.value.favitor?s("img",{src:je,key:"1"},null):s("img",{src:De,key:"2"},null)]})])]),s("div",{class:n.staffImgs},[C.value?s("iframe",{id:"staffIframeRef",style:{width:"100%",height:"100%",paddingTop:"20px"},src:e.iframeSrc,onLoad:T},null):s(q,null,[Q.value.length>0?Q.value.map(t=>s("img",{src:t,key:t},null)):s(me,null,null)])])])])])]),e.list.length!==0&&s(Ge,{show:e.showPlayer,playState:e.playState,item:p.value,onChange:t=>H(t)},null),_.value?s($t,null,null):null,s(Te,{show:e.previewModal,"onUpdate:show":[t=>e.previewModal=t,t=>{t||(e.previewUrl="")}],class:n.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:n.previewClose,onClick:()=>{e.previewModal=!1,e.previewUrl=""}},null),s("iframe",{class:n.previewIframe,onLoad:()=>{e.showPreivew=!1},frameborder:"0",src:e.previewUrl},null)]})]})])}}});export{ss as default};
|