فهرست منبع

Merge branch 'gyt-feature-tianyong' into online

TIANYONG 1 سال پیش
والد
کامیت
f8b3974e7e
2فایلهای تغییر یافته به همراه32 افزوده شده و 5 حذف شده
  1. 22 3
      src/pages/detail/runtime.ts
  2. 10 2
      src/subpages/colexiu/buttons/evaluating.tsx

+ 22 - 3
src/pages/detail/runtime.ts

@@ -143,13 +143,14 @@ const state = reactive({
 })
 
 const syncStepIndex = (i: number) => {
-  // console.log("🚀 ~ i", i)
+  console.log("🚀 ~ i", i)
   
   if (state.osmd.hidden !== false) {
     state.osmd.cursor.show()
   }
   prevIndex = i
   setStepIndex(state.osmd, i)
+  // console.log(66666664444)
   refreshIndex(detailState.times[i]?.time)
 }
 
@@ -339,6 +340,7 @@ export const resetCursor = () => {
 }
 
 export const refreshIndexBase = (index: number) => {
+  
   if (index < 0) return
   const { osmd }: any = state
   if (osmd) {
@@ -356,7 +358,6 @@ export const refreshIndexBase = (index: number) => {
           detailState.fixedKey = 0
         }
       }
-      
       if (prevIndex !== index) {
         setStepIndex(state.osmd, detailState.times[index].i, prevIndex)
         prevIndex = index
@@ -376,7 +377,8 @@ export const refreshIndex = (ctime?: number) => {
     } catch (error) {}
 
     const index = getIndex(detailState.times, currentTimeNum)
-
+    // 监听app返回的ctime
+    // console.log(777777777,index,ctime)
     state.activeIndex = index
     removeRepateBackground(index)
     // console.log(currentTimeNum, index, detailState.times[detailState.times.length - 1]?.endtime)
@@ -777,6 +779,7 @@ export const startIntervalTimeline = (maxTime: number, end: () => void) => {
   const start = () => {
     requestAnimationFrame(() => {
       currenttTime = (new Date().getTime() - nowTimeline) / 1000
+      // console.log(66666661111)
       refreshIndex(currenttTime)
       if (maxTime && currenttTime >= maxTime) {
         clearIntervalTimeline()
@@ -864,6 +867,19 @@ export const setPlayState = async () => {
   setTick(setTickStop)
 }
 
+export const testPlay = async () => {
+  if (detailState.activeTick > -1 || state.ticking) {
+    return
+  }
+  await syncPlayState()
+  if (state.playState !== 'pause' && state.playState !== 'suspend') {
+    await toggleState()
+    return
+  }
+  setPlayerView()
+  //setTick(setTickStop)
+}
+
 export const stopTick = () => {
   if (state.tickPlayer) {
     state.tickPlayer.destroy()
@@ -971,6 +987,7 @@ export const setAudioInit = () => {
       state.currentTimeNum = time
       state.currentTime = formatTime(time)
       refreshPlayer(time)
+      // console.log(66666662222)
       refreshIndex(time)
     }
     refreshView()
@@ -983,9 +1000,11 @@ export const setAudioInit = () => {
       if (state.playState === 'play') {
         state.currentTimeNum = time
         refreshPlayer(time)
+        // console.log(66666663333)
         refreshIndex(time)
         // 播放到最后一秒,停止播放
         if (res?.content?.totalDuration > 1000 && res?.content?.currentTime >= res?.content?.totalDuration) {
+          console.log('播放结束123')
           state.playState = 'pause'
           state.playEndCallback.endEvaluat()
           ended(new Event('ended'))

+ 10 - 2
src/subpages/colexiu/buttons/evaluating.tsx

@@ -75,6 +75,7 @@ const playUrl: Ref<string> = ref('')
 const endResult = ref(null)
 const browserInfo = browser()
 const scoreList: any[] = []
+const recordList: any[] = [] 
 let calculateInfo: any = {}
 /** 延迟数据 */
 export const delayData =  reactive({
@@ -732,7 +733,10 @@ const submitEvaluationScore = async (data: any) => {
       Toast('完整演奏结束才算测验分数!')
       return
     }
-    (endResult.value as any)?.score && scoreList.push((endResult.value as any)?.score)
+    if ((endResult.value as any)?.score) {
+      scoreList.push((endResult.value as any)?.score)
+      recordList.push(endResult.value)
+    }
     /** 有单元测验时,存储分数缓存 */
     postMessage({
       api: 'setCache',
@@ -743,6 +747,7 @@ const submitEvaluationScore = async (data: any) => {
           unitId: search.unitId || '',
           questionId: search.questionId || '',
           score: canSubmit.value ? (endResult.value as any)?.score || 0 : 0,
+          recordId: canSubmit.value ? (endResult.value as any)?.recordIdStr : '',
         }),
       },
     })
@@ -868,6 +873,8 @@ export const submitMaxScore = () => {
   const search = useOriginSearch()
   if (search.unitId && scoreList.length) {
     console.log('最高分',scoreList,Math.max(...scoreList))
+    const maxScore = Math.max(...scoreList)
+    const recordIdStr = recordList.find((item: any) => item.score === maxScore)?.recordIdStr
     postMessage({
       api: 'setCache',
       content: {
@@ -876,7 +883,8 @@ export const submitMaxScore = () => {
           musicId: search.id || '',
           unitId: search.unitId || '',
           questionId: search.questionId || '',
-          score: Math.max(...scoreList),
+          score: maxScore,
+          recordId: recordIdStr
         }),
       },
     })