index-27e1ac7b.js 2.4 KB

12
  1. import{d as h,g as T,n as y,c as _,m as t,bF as v,ae as b,h as l,av as N,a0 as P,V as w,bG as C,bH as L,aD as F,bI as x,bJ as B,aH as M,bK as D,bL as j,bM as R,bN as f}from"./index-740d866a.js";const k="_skeleton_1jzuh_1",z="_detail_1jzuh_12",A="_container_1jzuh_19",p={skeleton:k,detail:z,container:A},J=h({name:"simple-detail",setup(){const g=T(),i=y({isLoading:!0,currentTime:0,totalTime:0}),r=a=>{var n,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"&&(i.currentTime=(n=e==null?void 0:e.content)!=null&&n.currentTime?(o=e==null?void 0:e.content)==null?void 0:o.currentTime:i.currentTime,s())),(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)<i.currentTime&&(t.activeNoteIndex=0),i.currentTime=(u=e==null?void 0:e.content)==null?void 0:u.currentTime)};_(async()=>{const a=g.id||"";t.isSimplePage=!0,await v(a,"open"),i.isLoading=!1,t.isSingleLine=!0,window.addEventListener("message",r)}),b(()=>{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 n=(P.get("speeds")||{})[t.examSongId]||t.speed||a.bpm||a.Sheet.userStartTempoInBPM;n&&w(n),C(),L(),t.times=F(a),console.log("🚀 ~ state.times:",t.times,t.subjectId,t),x(t.times),B(),M(),console.log("渲染完成",e),window.parent.postMessage({api:"api_musicPage",height:e},"*"),D({height:e})},s=()=>{const a=i.currentTime;let e=j(a);e&&R(e),t.activeNoteIndex=(e==null?void 0:e.i)||0,t.isSingleLine&&f(a)},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"]},[!i.isLoading&&l(N,{onRendered:S,musicColor:"#FFFFFF"},null)])])}});export{J as default};