1 |
- import{d as h,g as T,n as y,c as _,m as t,bJ as b,ad as v,h as l,au as P,$ as C,U as N,bK as w,bL as L,aC as x,bM as B,bN as F,aG as M,bO as R,bP as j,bQ as D,bR as f}from"./index-539481de.js";const k="_skeleton_1jzuh_1",z="_detail_1jzuh_12",A="_container_1jzuh_19",p={skeleton:k,detail:z,container:A},O=h({name:"simple-detail",setup(){const g=T(),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(E){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=(C.get("speeds")||{})[t.examSongId]||t.speed||a.bpm||a.Sheet.userStartTempoInBPM;i&&N(i),w(),L(),t.times=x(a),console.log("🚀 ~ state.times:",t.times,t.subjectId,t),B(t.times),F(),M(),console.log("渲染完成",e),window.parent.postMessage({api:"api_musicPage",height:e},"*"),R({height:e})},s=a=>{const e=n.currentTime;let i=j(e);i&&D(i,a),t.activeNoteIndex=(i==null?void 0:i.i)||0,t.isSingleLine&&f(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(P,{onRendered:S,musicColor:"#FFFFFF"},null)])])}});export{O as default};
|