index-3c5b5ed1-1715840129614.js 17 KB

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