Переглянути джерело

Merge branch 'fix-tianyong' into online

TIANYONG 1 рік тому
батько
коміт
8da9cbc179

+ 13 - 2
src/helpers/communication.ts

@@ -65,9 +65,9 @@ export const cancelEvaluating = () => {
 };
 
 /** 评测开始录音 */
-export const api_startRecording = (): Promise<IPostMessage | undefined> => {
+export const api_startRecording = (content: any): Promise<IPostMessage | undefined> => {
 	if (!storeData.isApp) return Promise.resolve({} as any);
-	return promisefiyPostMessage({ api: "startRecording" });
+	return promisefiyPostMessage({ api: "startRecording", content: content });
 };
 /** 评测结束录音 */
 export const api_stopRecording = (): Promise<IPostMessage | undefined> => {
@@ -310,4 +310,15 @@ export const hideComplexButton = (callback: CallBack, listen?: boolean) => {
 	} else {
 		removeListenerMessage("hideComplexButton", callback);
 	}
+};
+
+
+/** 评测模式是否开启/关闭伴奏 */
+export const api_onoffAccompaniment = () => {
+	postMessage({
+		api: "onoffAccompaniment",
+		content: {
+			state: 0,
+		},
+	});
 };

+ 9 - 8
src/page-instrument/header-top/index.tsx

@@ -352,14 +352,15 @@ export default defineComponent({
                 </>}
               </span>
             </div>
-            {/* {state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert && (
-              <div class={[styles.btn]} onClick={() => {
-                toggleMusicSheet.toggle(true)
-              }}>
+            {state.musicRendered && !query.lessonTrainingId && !query.questionId && state.isConcert && (
+              <div class={[styles.btn, (state.playState === "play" && fingeringBtn.value.disabled) && styles.disabled]} 
+                onClick={() => {
+                  toggleMusicSheet.toggle(true)
+                }}>
                 <img class={styles.iconBtn} src={headImg(`shenggui.svg`)} />
                 <span>声轨</span>
               </div>
-            )} */}
+            )}
             <div
               id={state.platform === IPlatform.PC ? "teacherTop-1" : "studnetT-1"}
               style={{ display: originBtn.value.display ? "" : "none" }}
@@ -372,8 +373,8 @@ export default defineComponent({
               <img style={{ display: state.playSource === "music" ? "none" : "" }} class={styles.iconBtn} src={headImg(`background.svg`)} />
               <span>{state.playSource === "music" ? "原声" : "伴奏"}</span>
             </div>
-            {/* <div
-              class={styles.btn}
+            <div
+              class={[styles.btn]}
               onClick={async () => {
                 metronomeData.disable = !metronomeData.disable;
                 metronomeData.metro?.initPlayer();
@@ -382,7 +383,7 @@ export default defineComponent({
               <img style={{ display: metronomeData.disable ? "block" : "none" }} class={styles.iconBtn} src={headImg("tickoff.svg")} />
               <img style={{ display: !metronomeData.disable ? "block" : "none" }} class={styles.iconBtn} src={headImg("tickon.svg")} />
               <span style={{ whiteSpace: "nowrap" }}>节拍器</span>
-            </div>             */}
+            </div>            
             <div id={state.platform === IPlatform.PC ? "teacherTop-2" : "studnetT-2"} style={{ display: selectBtn.value.display ? "" : "none" }} class={[styles.btn, selectBtn.value.disabled && styles.disabled]} onClick={() => handleChangeSection()}>
               <img style={{ display: state.section.length === 0 ? "" : "none" }} class={styles.iconBtn} src={headImg(`section0.svg`)} />
               <img style={{ display: state.section.length === 1 ? "" : "none" }} class={styles.iconBtn} src={headImg(`section1.svg`)} />

+ 4 - 4
src/page-instrument/view-detail/index.tsx

@@ -110,7 +110,7 @@ export default defineComponent({
     /** 获取曲谱数据 */
     const getMusicInfo = (res: any) => {
       const index = query["part-index"] ? parseInt(query["part-index"] as string) : 0;
-      const musicData = res.data.background[index] || {};
+      const musicData = res.data.background?.[index] || {};
       const musicInfo = {
         ...res.data,
         music: musicData.audioFileUrl || res.data.audioFileUrl,
@@ -159,6 +159,8 @@ export default defineComponent({
 			const track = data.code || data.track;
 			state.track = track ? track.replace(/ /g, "").toLocaleLowerCase() : "";
 			state.enableNotation = data.notation ? true : false;
+      // 是否是合奏,先根据background判断
+      state.isConcert = data.background?.length > 1
 
       // console.log("🚀 ~ state.subjectId:", state.subjectId, state.track as any , state.subjectId)
       // 是否打击乐
@@ -172,7 +174,7 @@ export default defineComponent({
       state.isSpecialBookCategory = !classids.includes(data.musicSheetCategoriesId) 
 
       // 设置指法
-      const code = mappingVoicePart(state.subjectId, "INSTRUMENT");
+      const code = state.isConcert ? mappingVoicePart(state.trackId, "ENSEMBLE") : mappingVoicePart(state.subjectId, "INSTRUMENT");
       state.fingeringInfo = subjectFingering(code);
       console.log("🚀 ~ state.fingeringInfo:", code, state.fingeringInfo, state.trackId, state.track);
 
@@ -189,8 +191,6 @@ export default defineComponent({
 
       //课堂乐器, 渲染类型: 五线谱, 简谱
       state.musicRenderType = query.musicRenderType || EnumMusicRenderType.firstTone;
-      // 是否是合奏,先根据background判断
-      state.isConcert = data.background?.length > 1
       console.log('state对象', state)
     };
 

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

@@ -270,7 +270,9 @@ export const handleStartBegin = async () => {
 		onPlay();
 	}
 	//开始录音
-	await api_startRecording();
+	await api_startRecording({
+		accompanimentState: state.setting.enableAccompaniment ? 1 : 0
+	});
 
 	// 如果开启了摄像头, 开启录制视频
 	if (state.setting.camera) {

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

@@ -56,7 +56,7 @@ export type IVocals =
 /** 映射声部ID */
 export const mappingVoicePart = (
 	id: number | string,
-	soruce: "GYM" | "COLEXIU" | "ORCHESTRA" | "INSTRUMENT"
+	soruce: "GYM" | "COLEXIU" | "ORCHESTRA" | "INSTRUMENT" | "ENSEMBLE"
 ): number => {
 	if (soruce === "GYM") {
 		return Number(id);
@@ -123,6 +123,14 @@ export const mappingVoicePart = (
 			1: "pan-flute",
 			2: "ocarina",
 			5: "melodica",
+			23: 2,
+			24: 6,
+			25: 4,
+			26: 12,
+			27: 14,
+			28: 13,
+			29: 15,
+			30: 17,
 			tenorrecorder: "piccolo",
 			woodwind: "hulusi-flute",
 			panpipes: "pan-flute",
@@ -130,6 +138,84 @@ export const mappingVoicePart = (
 			nai: "melodica",
 		};
 		return subject[code] || 0;
+	} else if (soruce === "ENSEMBLE") {
+		let code = id;
+		const subject: { [_key: string | number]: any } = {
+			"Piccolo": "piccolo",
+			"Flute": 2,
+			"Flute 1": 2,
+			"Flute 2": 2,
+			"Oboe": 1,
+			"Clarinet in Bb 1": 4,
+			"Clarinet in Bb 2": 4,
+			"Alto Clarinet in Eb": 4,
+			"Bass Clarinet in Bb": 4,
+			"Bassoon": 1,
+			"Alto Saxophone": 5,
+			"Tenor Saxophone": 5,
+			"Baritone Saxophone": 5,
+			"Trumpet in Bb 1": 12,
+			"Trumpet in Bb 2": 12,
+			"Horn in F": 13,
+			"Horn in F 1": 13,
+			"Horn in F 2": 13,
+			"Trombone 1": 14,
+			"Trombone 2": 14,
+			"Trombone 3": 14,
+			"Euphonium": 15,
+			"Tuba": 17,
+			"Chimes": 1,
+			"Bells": 1,
+			"Xylophone": 1,
+			"Snare Drum": 1,
+			"Bass Drum": 1,
+			"Triangle": 1,
+			"Suspended Cymbal": 1,
+			"Crash Cymbals": 1,
+			"Concert Toms": 1,
+			"Timpani": 1,
+			flute: 2,
+			oboe: 4,
+			clarinet: 4,
+			trombone: 14,
+			tuba: 17,
+			trumpet: 12,
+			horn: 13,
+			altosaxophone: 6,
+			tenorsaxophone: 6,
+			saxophone: 6,
+			upbasshorn: 15,
+			melodica: 137,
+			hulusiFlute: 136,
+			panflute: 135,
+			recorder: 120,
+			ukulele: 130,
+			mouthorgan: 140,
+			piano: 150,
+			4: "piccolo",
+			3: "hulusi-flute",
+			1: "pan-flute",
+			2: "ocarina",
+			5: "melodica",
+			26: 12,
+			tenorrecorder: "piccolo",
+			woodwind: "hulusi-flute",
+			panpipes: "pan-flute",
+			ocarina: "ocarina",
+			nai: "melodica",
+		};
+		let _track;
+		if (typeof code === 'string') {
+			for (let sKey in subject) {
+				if(sKey === code) {
+					_track = subject[sKey]
+					break;
+				}
+			}
+		} else {
+			_track = subject.code
+		}
+		return _track;
 	}
 	return 0;
 };

+ 20 - 20
src/view/fingering/index.module.less

@@ -17,26 +17,26 @@
     flex: 1;
   }
 
-  &::before {
-    content: '';
-    position: absolute;
-    left: 0;
-    top: 0;
-    right: 0;
-    height: 30px;
-    background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
-    z-index: 1;
-  }
-  &::after {
-    content: '';
-    position: absolute;
-    left: 0;
-    bottom: 0;
-    right: 0;
-    height: 30px;
-    background: linear-gradient(360deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
-    z-index: 1;
-  }
+  // &::before {
+  //   content: '';
+  //   position: absolute;
+  //   left: 0;
+  //   top: 0;
+  //   right: 0;
+  //   height: 30px;
+  //   background: linear-gradient(180deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
+  //   z-index: 1;
+  // }
+  // &::after {
+  //   content: '';
+  //   position: absolute;
+  //   left: 0;
+  //   bottom: 0;
+  //   right: 0;
+  //   height: 30px;
+  //   background: linear-gradient(360deg, #FFFFFF 0%, rgba(255, 255, 255, 0) 100%);
+  //   z-index: 1;
+  // }
 }
 
 .imgs {

+ 13 - 2
src/view/plugins/toggleMusicSheet/choosePartName/index.tsx

@@ -1,4 +1,4 @@
-import { PropType, computed, defineComponent, ref, toRefs } from 'vue'
+import { PropType, computed, defineComponent, ref, toRefs, onMounted } from 'vue'
 import { Picker, Button, Icon } from 'vant'
 import styles from './index.module.less'
 
@@ -21,7 +21,16 @@ export default defineComponent({
     const columns = computed(() => {
       return partListNames.value
     })
-    console.log(partListNames.value, partIndex.value, selectIndex.value, columns.value, 999999)
+    // console.log(partListNames.value, partIndex.value, selectIndex.value, columns.value, 999999)
+    /**
+     * 默认选中的
+     * picker组件,3.x的版本可以使用defaultIndex,4.x的版本只能使用v-model传递
+     * */ 
+    const selValues = ref([partIndex.value]);
+    const myPicker = ref();
+    onMounted(() => {
+			console.log(myPicker.value)
+		});
     return () => (
       <div class={styles.container}>
         <div class={styles.top}>
@@ -29,8 +38,10 @@ export default defineComponent({
           <Icon name="cross" size={24} onClick={() => emit('close')} />
         </div>
         <Picker
+          ref={myPicker}
           class={styles.picker}
           defaultIndex={props.partIndex}
+          v-model={selValues.value}
           showToolbar={false}
           columns={columns.value}
           visibleItemCount={Math.ceil(document.body.clientHeight / 44 / 3)}

+ 1 - 1
src/view/plugins/toggleMusicSheet/index.tsx

@@ -2,7 +2,6 @@ import { computed, defineComponent, reactive } from 'vue'
 import styles from './index.module.less'
 import { Icon, Popup } from 'vant'
 import ChoosePartName from './choosePartName'
-import runtime, * as RuntimeUtils from '/src/pages/detail/runtime'
 import state, { togglePlay } from "/src/state";
 import qs from 'query-string'
 import { getInstrumentName } from "/src/constant/instruments";
@@ -33,6 +32,7 @@ export default defineComponent({
     })
 
     const switchMusic = (index: number) => {
+      if (state.partIndex === index) return
       // 暂停播放
       togglePlay("paused");
       // 销毁播放器