Selaa lähdekoodia

feat: 跟练修改

TIANYONG 10 kuukautta sitten
vanhempi
commit
828f8d8fb1
1 muutettua tiedostoa jossa 14 lisäystä ja 7 poistoa
  1. 14 7
      src/subpages/colexiu/popups/follow/index.tsx

+ 14 - 7
src/subpages/colexiu/popups/follow/index.tsx

@@ -123,9 +123,10 @@ const handleEnd = () => {
   data.start = false
   openToggleRecord(false)
   data.index = getDefaultIndex()
-  setStepIndex(state.osmd, data.index)
+  setStepIndex(state.osmd, 0)
   // state.osmd.cursor.reset()
   getNoteIndex()
+  onClear()
 }
 
 /**
@@ -134,10 +135,13 @@ const handleEnd = () => {
  * 需要判断当前音符的后面是否都是休止音符(休止音符的频率都是-1),或者是否是最后一个音符了
  */
 const autoEndFollow = () => {
-	if (data.index >= detailState.times.length) {
+	if (data.index >= detailState.times.length-1) {
     // 如果开了自动循环需要重新开始跟练
     if (SettingState.sett.loop) {
-      handleStart()
+      handleEnd()
+      setTimeout(() => {
+        handleStart()
+      }, 0);
     } else {
       handleEnd()
     }
@@ -146,11 +150,14 @@ const autoEndFollow = () => {
 	let nextIndex = data.index + 1;
 	const rightTimes = detailState.times.slice(data.index,detailState.times.length)
 	// 后面的音符是否都是休止音符
-	const isAllRest = !rightTimes.some((item: any) => item.frequency > 1);
-	if (isAllRest && detailState.times[data.index].frequency < 1) {
+	const isAllRest = !rightTimes.some((item: any) => item?.frequency > 1);
+	if (isAllRest && detailState.times[data.index]?.frequency < 1) {
     // 如果开了自动循环需要重新开始跟练
     if (SettingState.sett.loop) {
-      handleStart()
+      handleEnd()
+      setTimeout(() => {
+        handleStart()
+      }, 0);
     } else {
       handleEnd()
     }
@@ -207,7 +214,7 @@ const checked = () => {
   for (let i = 0; i < data.list.length; i++) {
     const frequency = data.list[i]
     if (frequency > item.min && frequency < item.max) {
-      console.log(item.min, frequency, item.max)
+      // console.log(item.min, frequency, item.max)
       next()
       data.index += 1
       data.list = data.list.slice(i + 1)