Browse Source

fix: 阶段评测,评测分数逻辑问题修复

TIANYONG 1 year ago
parent
commit
676abe3652
1 changed files with 27 additions and 0 deletions
  1. 27 0
      src/subpages/colexiu/buttons/evaluating.tsx

+ 27 - 0
src/subpages/colexiu/buttons/evaluating.tsx

@@ -58,6 +58,9 @@ const formatTimes = () => {
   let skip = false
   const datas = []
   let times = detailState.times
+  // 阶段评测前一个节拍的标示
+  let preLyricsContent = ''
+  let preTimes = []
   if (unitTestData.isSelectMeasureMode) {
     const startIndex = detailState.times.findIndex(
       (n: any) => n.NoteToGraphicalNoteObjectId == detailState.section[0].NoteToGraphicalNoteObjectId
@@ -68,9 +71,28 @@ const formatTimes = () => {
     times = detailState.times.filter((n: any, index: number) => {
       return index >= startIndex && index <= endIndex
     })
+    preTimes = detailState.times.filter((n: any, index: number) => {
+      return index < startIndex
+    })
     starTime = times[0].sourceRelativeTime || times[0].relativeTime
     // console.log("🚀 ~ times", times)
   }
+  // 找到阶段评测,开始小节前面最近的是play或者listen的小节
+  if (preTimes.length) {
+    for (let index = preTimes.length-1; index >= 0; index--) {
+      const item = preTimes[index]
+      const note = getNoteByMeasuresSlursStart(item)
+      if (note.formatLyricsEntries.contains('Play') || note.formatLyricsEntries.contains('Play...')) {
+        preLyricsContent = 'Play'
+        break
+      }
+      if (note.formatLyricsEntries.contains('Listen')) {
+        preLyricsContent = 'Listen'
+        break
+      }
+    }
+    preLyricsContent = preLyricsContent ? preLyricsContent : 'Play'
+  }
   let measureIndex = -1
   let recordMeasure = -1
   for (let index = 0; index < times.length; index++) {
@@ -83,6 +105,11 @@ const formatTimes = () => {
     const isStaccato =
       typeof note.voiceEntry.isStaccato === 'function' ? note.voiceEntry.isStaccato() : note.voiceEntry.isStaccato
     const noteRate = isStaccato ? 0.5 : 1
+    // console.log('注脚', note.formatLyricsEntries)
+    // 如果阶段评测,开始小节没有注脚,则取前面最近的小节的注脚
+    if (index == 0 && !note.formatLyricsEntries.length) {
+      ListenMode = preLyricsContent === 'Play' ? false : preLyricsContent === 'Listen' ? true : false
+    }
     if (note.formatLyricsEntries.contains('Play') || note.formatLyricsEntries.contains('Play...')) {
       ListenMode = false
     }