1 |
- import{d as T,g as h,n as y,c as _,m as t,bK as b,ad as v,h as l,at as N,$ as P,U as C,bL as L,bM as M,aB as w,aE as x,bN as B,bO as F,aF as R,bP as f,bQ as k,bR as D,bS as E,bT as j}from"./index-ec9ac6df.js";const z="_skeleton_1jzuh_1",A="_detail_1jzuh_12",O="_container_1jzuh_19",p={skeleton:z,detail:A,container:O},Q=T({name:"simple-detail",setup(){const g=h(),n=y({isLoading:!0,currentTime:0,totalTime:0}),r=a=>{var i,o,d,m,u;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",c()),(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?(o=e==null?void 0:e.content)==null?void 0:o.currentTime:n.currentTime,s(!0))),(e==null?void 0:e.api)==="api_playProgress"&&(d=e==null?void 0:e.content)!=null&&d.currentTime&&(((m=e==null?void 0:e.content)==null?void 0:m.currentTime)<n.currentTime&&(t.activeNoteIndex=0),n.currentTime=(u=e==null?void 0:e.content)==null?void 0:u.currentTime)};_(async()=>{const a=g.id||"";t.isSimplePage=!0,await b(a,"open"),n.isLoading=!1,t.isSingleLine=!0,window.addEventListener("message",r)}),v(()=>{t.isSimplePage=!1,window.removeEventListener("message",r)});const S=async a=>{var o;const e=(o=document.getElementById("scrollContainer"))==null?void 0:o.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,j()}),B(t.times),F(),R(),console.log("渲染完成",e),window.parent.postMessage({api:"api_musicPage",height:e},"*"),f({height:e})},s=a=>{const e=n.currentTime;let i=k(e);i&&D(i,a),t.activeNoteIndex=(i==null?void 0:i.i)||0,t.isSingleLine&&E(e)},c=()=>{if(t.playState!=="play"){console.log("暂停播放");return}let a=Date.now();requestAnimationFrame(()=>{Date.now()-a<16.7?(s(),c()):setTimeout(()=>{s(),c()},16.7)})};return()=>l("div",{class:p.detail},[l("div",{id:"scrollContainer",class:[p.container,"hideCursor"]},[!n.isLoading&&l(N,{onRendered:S,musicColor:"#FFFFFF"},null)])])}});export{Q as default};
|