Pārlūkot izejas kodu

Merge branch 'feature-tianyong-newVersion' into ktyq-test-new

TIANYONG 11 mēneši atpakaļ
vecāks
revīzija
13495f7a98

+ 6 - 0
src/helpers/communication.ts

@@ -266,6 +266,12 @@ export const api_createMusicPlayer = (content: any) => {
 	return promisefiyPostMessage({ api: "createMusicPlayer", content });
 };
 
+/** 初始化曲谱音频 和效音音频 */
+export const api_updateMusicPlayer = (content: any) => {
+	if (!storeData.isApp) return Promise.resolve({} as any);
+	return promisefiyPostMessage({ api: "createMusicPlayer", content });
+};
+
 /** 进入页面设置常量 */
 export const api_keepScreenLongLight = () => {
 	postMessage({

+ 5 - 2
src/page-instrument/evaluat-model/index.tsx

@@ -488,7 +488,7 @@ export default defineComponent({
     return () => (
       <div>
         <div class={styles.operatingBtn}>
-          {evaluatingData.websocketState && !evaluatingData.startBegin && evaluatingData.checkEnd && (
+          {evaluatingData.websocketState && !evaluatingData.startBegin && (
             <img
               class={[styles.iconBtn, "evaluting-1"]}
               src={headImg("icon_play.png")}
@@ -543,7 +543,10 @@ export default defineComponent({
             onClose={() => {
               clearTimeout(checkErjiTimer);
               checkErjiTimer = null;
-              evaluatingData.earphoneMode = false;
+              // #11035,可能刚好关闭耳机弹窗的时候,第二次又出现了弹窗
+              setTimeout(() => {
+                evaluatingData.earphoneMode = false;
+              }, 0);
               // handlePerformDetection();
               checkEarphoneStatus("start");
             }}

+ 10 - 0
src/page-instrument/header-top/speed/index.module.less

@@ -176,6 +176,16 @@
                         }
                     }
                 }
+                .switchLoading {
+                    :global {
+                        .van-switch__node{
+                            display: block;
+                            width: 16px;
+                            height: 16px;
+                            // top: 3px;
+                        }
+                    }
+                }
             }
         }
     }

+ 33 - 1
src/page-instrument/header-top/speed/index.tsx

@@ -6,11 +6,14 @@ import { headImg } from "../image";
 import state, { handleSetSpeed, resetBaseRate } from "../../../state";
 import { metronomeData } from "../../../helpers/metronome"; 
 import { getQuery } from "/src/utils/queryString";
+import { api_createMusicPlayer, api_updateMusicPlayer } from "/src/helpers/communication";
+import { storeData } from "/src/store";
 
 export default defineComponent({
 	name: "speed",
 	setup() {
 		const speed = ref(state.speed);
+		const switchLoading = ref(false);
 		const query: any = getQuery();
 		const minusSpeed = () => {
 			let canSpeed = Math.max(speed.value - 1, 45);
@@ -50,6 +53,30 @@ export default defineComponent({
 				metronomeData.disable = !val
 			}
 		})
+		const toggleSwitch = async (res: any) => {
+			switchLoading.value = true;
+			try {
+			  // 模拟异步操作,例如 API 调用
+			  console.log(123567,res)
+			  if (storeData.isApp) {
+				const targetSrc = res ? state.beatSong.accompany || state.beatSong.music : state.accompany || state.music;
+				api_updateMusicPlayer({
+					musicSrc: targetSrc || state.accompany || state.music, // 曲谱音频url,有可能含节拍器的音频不存在
+					tuneSrc: "https://oss.dayaedu.com/MECMP/1722593665681.mp3", //效音音频url
+					checkFrequence: 496,
+				})
+				metronomeDisable.value = res;
+				switchLoading.value = false;
+			  } else {
+				metronomeDisable.value = res;
+				switchLoading.value = false;
+			  }
+			} catch (error) {
+			  console.log(error)
+			} finally {
+				//switchLoading.value = false;
+			}
+		  };
 		return () => (
 			<div class={[styles.speedContainer, styles[state.modeType]]}>
 				<div class={styles.head}>
@@ -84,7 +111,12 @@ export default defineComponent({
 						</div>
 						<div class={styles.metronome}>
 							<div class={styles.tit}>节拍器</div>
-							<Switch v-model={metronomeDisable.value}></Switch>
+							<Switch 
+								class={switchLoading.value ? styles.switchLoading : ''}
+								v-model:modelValue={metronomeDisable.value} 
+								loading={switchLoading.value}
+								onChange={toggleSwitch}			
+							></Switch>
 						</div>
 					</div>
 				</div>

+ 5 - 2
src/page-instrument/view-evaluat-report/index.tsx

@@ -283,8 +283,11 @@ export default defineComponent({
            */
           // const isNeedCopyElement = scoreData.itemType === "integrity" ? false : ["HIGH", "LOW", "EARLY", "LATE"].includes(errType);
           const isNeedCopyElement = false;
+          // if (scoreData.itemType === "integrity") {
+          //   errType = errType = note.pitchAssessment.result === "HIGH" || note.pitchAssessment.result === "LOW" || note.pitchAssessment.result === "WRONG" ? "RIGHT" : errType;
+          // }
           if (scoreData.itemType === "integrity") {
-            errType = errType = note.pitchAssessment.result === "HIGH" || note.pitchAssessment.result === "LOW" || note.pitchAssessment.result === "WRONG" ? "RIGHT" : errType;
+            errType = errType = note.integrityAssessment.result === "NORMAL" ? "RIGHT" : note.integrityAssessment.result === "SHORT" ? "SHORT" : errType;
           }
           stemEl?.classList.add(colorsClass[errType]);
           svgEl?.classList.add(colorsClass[errType]);
@@ -402,7 +405,7 @@ export default defineComponent({
       allNote.value = formateTimes(osmd);
       console.log("🚀 ~ state.times:", allNote.value);
       // @ts-ignore
-      const startMeasureNum = detailData.musicalNotesPlayStats?.[0].measureRenderIndex, endMeasureNum = detailData.musicalNotesPlayStats?.last()?.measureRenderIndex;
+      const startMeasureNum = detailData.musicalNotesPlayStats?.[0]?.measureRenderIndex, endMeasureNum = detailData.musicalNotesPlayStats?.last()?.measureRenderIndex;
       allNote.value = allNote.value.filter((item: any) => (item.MeasureNumberXML >= startMeasureNum+1 && item.MeasureNumberXML <= endMeasureNum+1))
       // @ts-ignore
       const beams = Array.from(new Set(document.getElementsByClassName("vf-beam")));

+ 5 - 3
src/state.ts

@@ -723,7 +723,8 @@ const handlePlaying = () => {
   // if (state.modeType !== "evaluating") {
   //   metronomeData.metro?.sound(currentTime);
   // }
-  metronomeData.metro?.sound(currentTime);
+  // 不需要播放节拍器的声音,因为音频带有节拍器的声音
+  // metronomeData.metro?.sound(currentTime);
   // 一行谱,需要滚动小节
   if (state.isSingleLine) {
     moveSmoothAnimationByPlayTime()
@@ -745,7 +746,8 @@ export const skipNotePlay = async (itemIndex: number, isStart = false) => {
     setAudioCurrentTime(itemTime, itemIndex);
     // 一行谱,点击音符,或者播放完成,需要跳转音符位置
     gotoNext(item, true);
-    metronomeData.metro?.sound(itemTime);
+    // 不需要播放节拍器的声音,因为音频带有节拍器的声音
+    // metronomeData.metro?.sound(itemTime);
     if (state.isAppPlay) {
       await api_cloudSetCurrentTime({
         currentTime: itemTime * 1000,
@@ -1324,7 +1326,7 @@ function xmlToTracks(xmlString: string) {
   const partNames = Array.from(xmlParse.getElementsByTagName('part-name'));
   return partNames.reduce((arr: string[], item) => {
     const textContent = item?.textContent?.trim()
-    if (textContent !== "COMMON" && textContent) {
+    if (textContent != "COMMON" && textContent != "common" && textContent) {
       arr.push(textContent)
     }
     return arr

+ 1 - 0
src/view/fingering/fingering-config.ts

@@ -342,6 +342,7 @@ export const matchVoicePart = (id: number | string, type: "SINGLE" | "CONCERT"):
         let pitchKey = sKey;
         if (typeof sKey === "string") {
           pitchKey = pitchKey.toLocaleLowerCase().replace(/ /g, "");
+          pitchKey = pitchKey.replace(/[_0-9]+$/, '');
         }
         if (typeof sKey === "string") {
           // 去掉声轨后面的数字

+ 12 - 4
src/view/follow-practice/index.tsx

@@ -21,7 +21,8 @@ export const followData = reactive({
 	rendered: false,
 	/** 麦克风权限 */
 	earphone: false,
-	isBeginMask: false // 倒计时和系统节拍器时候的遮罩,防止用户点击
+	isBeginMask: false, // 倒计时和系统节拍器时候的遮罩,防止用户点击
+	dontAccredit: true, // 没有开启麦克风权限,不需要调用结束收音的api
 });
 
 // 记录跟练时长
@@ -49,7 +50,10 @@ export const toggleFollow = (notCancel = true) => {
 	// 取消跟练
 	if (!notCancel) {
 		followData.start = false;
-		openToggleRecord(false);
+		// 开启了麦克风授权,才需要调用结束收音
+		if (storeData.isApp && !followData.dontAccredit) {
+			openToggleRecord(false);
+		}
 	}
 };
 
@@ -106,6 +110,7 @@ export const handleFollowStart = async () => {
 		followData.isBeginMask = false
 		followData.start = false;
 	} else {
+		followData.dontAccredit = false;
 		// 跟练模式开始前,增加播放系统节拍器
 		const tickend = await handleStartTick();
 		// console.log("🚀 ~ tickend:", tickend)
@@ -312,10 +317,13 @@ export default defineComponent({
 			console.log("进入跟练模式");
 		});
 		onUnmounted(() => {
-			api_cloudFollowTime(onFollowTime, false);
+			// api_cloudFollowTime(onFollowTime, false);
 			resetPlaybackToStart();
 			onClear();
-			openToggleRecord(false);
+			// 开启了麦克风授权,才需要调用结束收音
+			if (storeData.isApp && !followData.dontAccredit) {
+				openToggleRecord(false);
+			}
 			console.log("退出跟练模式");
 		});
 		return () => <div></div>;

+ 3 - 1
src/view/selection/index.tsx

@@ -1,5 +1,5 @@
 import { computed, defineComponent, onMounted, reactive, Transition, nextTick, watch } from "vue";
-import state, { EnumMusicRenderType, handleSelection, skipNotePlay, IPlatform } from "/src/state";
+import state, { EnumMusicRenderType, handleSelection, skipNotePlay, IPlatform, resetBaseRate } from "/src/state";
 import styles from "./index.module.less";
 import { metronomeData } from "/src/helpers/metronome";
 import { evaluatingData } from "../evaluating";
@@ -340,6 +340,8 @@ export default defineComponent({
 									// 如果选择了2个 删除左边的时候
 									if(state.section.length===2&&index === 0){
 										state.section = []
+										// 重置速度和播放倍率
+										resetBaseRate(state.activeNoteIndex);
 										showToast({
 											message: "请选择开始小节",
 											duration: 0,