Browse Source

演奏模式下没有原音伴奏 不展示唱名,修复唱名切换到跟练模式和评测模式时值没改变的bug

黄琪勇 1 month ago
parent
commit
043b522831

+ 1 - 1
src/page-instrument/custom-plugins/guide-driver/index.tsx

@@ -58,7 +58,7 @@ export const PractiseDriver = defineComponent({
     };
 
     const driverOptions = (): Config => {
-      let length = 10;
+      let length = 11;
 
       if (!props.statusAll.playBtnStatus) {
         length -= 1;

+ 31 - 4
src/page-instrument/header-top/index.tsx

@@ -63,6 +63,15 @@ export const headTopData = reactive({
       metronomeData.cursorMode = 1;
     }
     if (value === "practise") {
+      // 切回当前的时值
+      const isModeChange = modeChangeHandleTimes("play", "music")
+      // 没有切换的时候 不处理下面的
+      if (isModeChange) {
+        try {
+          metronomeData.metro.calculation(state.times);
+        } catch (error) {}
+        console.log("重新之后的times", state.times, state.fixtime);
+      }
       // state.playIngSpeed = state.speed
     }
     if (value === "evaluating") {
@@ -87,6 +96,17 @@ export const headTopData = reactive({
       //   state.isSingleLine = true;
       //   refreshMusicSvg();
       // }
+      /* 当前是唱名的模式 */
+      if(state.playSource === "mingSong") {
+        const isModeChange = modeChangeHandleTimes("play","mingSong","play","music")
+        // 没有切换的时候 不处理下面的
+        if (isModeChange) {
+          try {
+            metronomeData.metro.calculation(state.times);
+          } catch (error) {}
+          console.log("重新之后的times", state.times, state.fixtime);
+        }
+      }
       // 关闭节奏律动
       headTopData.rhythmMode = false
       smoothAnimationState.isShow.value = false; // 隐藏旋律线
@@ -162,11 +182,19 @@ export async function handlerModeChange(oldPlayType: "play" | "sing", oldPlaySou
   }
 }
 // 模式切换之后重新给times赋值
-function modeChangeHandleTimes(oldPlayType: "play" | "sing", oldPlaySource: IPlayState) {
-  const playType = state.playType;
-  const playSource = state.playSource;
+function modeChangeHandleTimes(oldPlayType: "play" | "sing", oldPlaySource: IPlayState, nowPlayType?:"play" | "sing", nowPlaySource?: IPlayState) {
+  const playType = nowPlayType || state.playType;
+  const playSource = nowPlaySource || state.playSource;
   const { notBeatFixtime, xmlMp3BeatFixTime, difftime } = state.times[0];
   const { isOpenMetronome, isSingOpenMetronome } = state;
+  // 跟练模式不切换时值  因为演奏加了唱名,所以往跟练模式切换的时候,刷新谱面的时候需要更新时值,这时候调用handleRessetState 会回到练习模式
+  if(state.modeType === "follow") {
+    return false
+  }
+  // 当相同时候也不处理
+  if(oldPlayType === playType && oldPlaySource === playSource) {
+    return false
+  }
   // 原声向伴奏和伴奏向原声不处理  范唱向伴唱和伴唱向范唱切不处理
   if((oldPlaySource==="music"&&playSource==="background")||(oldPlaySource==="background"&&playSource==="music")){
     return false
@@ -387,7 +415,6 @@ export default defineComponent({
         let index = 0;
         state.music && index++;
         state.accompany && index++;
-        state.mingSong && index++;
         let songIndex = 0;
         state.fanSong && songIndex++;
         state.banSong && songIndex++;

+ 0 - 2
src/state.ts

@@ -1606,8 +1606,6 @@ const setState = (data: any, index: number) => {
         state.playSource = "music"
       }else if(state.accompany){
         state.playSource = "background"
-      }else if(state.mingSong){
-        state.playSource = "mingSong"
       }else{
         if(state.fanSong){
           state.playType = "sing"