index-0121179c.js 2.5 KB

1
  1. import{d as T,g as _,n as y,c as v,m as t,bK as h,ad as b,h as o,at as N,$ as P,U as C,bL as L,bM as M,aB as w,aE as x,bN as k,bO as B,aF as F,bP as R,bQ as f,bR as z,bS as D,bT as E}from"./index-091a54d2.js";const A="_skeleton_zs6vu_1",O="_detail_zs6vu_12",q="_mask_zs6vu_20",J="_container_zs6vu_26",r={skeleton:A,detail:O,mask:q,container:J},V=T({name:"simple-detail",setup(){const g=_(),n=y({isLoading:!0,currentTime:0,totalTime:0}),d=a=>{var i,s,m,u,p;let e={};try{e=typeof(a==null?void 0:a.data)=="string"?JSON.parse(a.data):a.data}catch(Q){console.error("parse_error: Invalid JSON data received")}(e==null?void 0:e.api)==="api_play"&&(console.log("h5开始播放"),t.playState="play",l()),(e==null?void 0:e.api)==="api_paused"&&(console.log("暂停播放"),t.playState="paused"),(e==null?void 0:e.api)==="api_updateProgress"&&(console.log("拖动的进度"),t.playState==="paused"&&(n.currentTime=(i=e==null?void 0:e.content)!=null&&i.currentTime?(s=e==null?void 0:e.content)==null?void 0:s.currentTime:n.currentTime,c(!0))),(e==null?void 0:e.api)==="api_playProgress"&&(m=e==null?void 0:e.content)!=null&&m.currentTime&&(((u=e==null?void 0:e.content)==null?void 0:u.currentTime)<n.currentTime&&(t.activeNoteIndex=0),n.currentTime=(p=e==null?void 0:e.content)==null?void 0:p.currentTime)};v(async()=>{const a=g.id||"";t.isSimplePage=!0,await h(a,"open"),n.isLoading=!1,t.isSingleLine=!0,window.addEventListener("message",d)}),b(()=>{t.isSimplePage=!1,window.removeEventListener("message",d)});const S=async a=>{var s;const e=(s=document.getElementById("scrollContainer"))==null?void 0:s.getBoundingClientRect().height;t.osmd=a,t.originSpeed===0&&(t.originSpeed=t.speed=a.bpm||a.Sheet.userStartTempoInBPM||100);const i=(P.get("speeds")||{})[t.examSongId]||t.speed||a.bpm||a.Sheet.userStartTempoInBPM;i&&C(i),L(),M(),t.times=w(a),console.log("🚀 ~ state.times:",t.times,t),x(()=>{t.activeMeasureIndex=t.times[0].MeasureNumberXML,E()}),k(t.times),B(),F(),console.log("渲染完成",e),window.parent.postMessage({api:"api_musicPage",height:e},"*"),R({height:e})},c=a=>{const e=n.currentTime;let i=f(e);i&&z(i,a),t.activeNoteIndex=(i==null?void 0:i.i)||0,t.isSingleLine&&D(e)},l=()=>{if(t.playState!=="play"){console.log("暂停播放");return}let a=Date.now();requestAnimationFrame(()=>{Date.now()-a<16.7?(c(),l()):setTimeout(()=>{c(),l()},16.7)})};return()=>o("div",{class:r.detail},[o("div",{class:r.mask},null),o("div",{id:"scrollContainer",class:[r.container,"hideCursor"]},[!n.isLoading&&o(N,{onRendered:S,musicColor:"#FFFFFF"},null)])])}});export{V as default};