Prechádzať zdrojové kódy

切换曲目提示 先后顺序修改

黄琪勇 7 mesiacov pred
rodič
commit
1433849f51
1 zmenil súbory, kde vykonal 11 pridanie a 5 odobranie
  1. 11 5
      src/page-instrument/header-top/index.tsx

+ 11 - 5
src/page-instrument/header-top/index.tsx

@@ -94,6 +94,8 @@ export const headTopData = reactive({
     }
     headTopData.modeType = "show";
   },
+  // 改变模式之前的状态
+  oldPlayType: "play"
 });
 
 export const headData = reactive({
@@ -126,6 +128,14 @@ export function handlerModeChange(oldPlayType: "play" | "sing", oldPlaySource: I
     // 隐藏重播按钮
     resetBtn && (resetBtn.value.display = false);
   }
+  // 当模式改变的时候  放在这里是因为需要等谱面加载完成之后再提示
+  if(headTopData.oldPlayType !== state.playType){
+    showToast({
+      message: state.playType === "play" ? "已切换为演奏场景" : "已切换为演唱场景",
+      position: "top",
+      className: "selectionToast",
+    });
+  }
 }
 // 模式切换之后重新给times赋值
 function modeChangeHandleTimes(oldPlayType: "play" | "sing", oldPlaySource: IPlayState) {
@@ -708,6 +718,7 @@ export default defineComponent({
               class={["driver-2", styles.btn, playTypeBtn.value.disabled && styles.disabled,styles.playType]}
               onClick={() => {
                 const oldPlayType = state.playType;
+                headTopData.oldPlayType = oldPlayType
                 const oldPlaySource = state.playSource;
                 if (state.playType === "play") {
                   state.playType = "sing";
@@ -737,11 +748,6 @@ export default defineComponent({
                 } else if (!isRefresh) {
                   handlerModeChange(oldPlayType, oldPlaySource, true);
                 }
-                showToast({
-                  message: state.playType === "play" ? "已切换为演奏场景" : "已切换为演唱场景",
-                  position: "top",
-                  className: "selectionToast",
-                });
               }}
             >
               <img style={{ display: state.playType === "play" ? "" : "none" }} class={styles.iconBtn} src={headImg(`perform.png`)} />