Selaa lähdekoodia

feat: 打击乐声部可能有多个乐器id问题修改

TIANYONG 8 kuukautta sitten
vanhempi
commit
46c9df5f22
3 muutettua tiedostoa jossa 21 lisäystä ja 7 poistoa
  1. 2 0
      src/page-instrument/api.ts
  2. 17 7
      src/state.ts
  3. 2 0
      src/store.ts

+ 2 - 0
src/page-instrument/api.ts

@@ -32,6 +32,7 @@ export const studentQueryUserInfo = async () => {
       const data = res.data
       res.data = {
         instrumentId: "",
+        specialInstrumentIds: [],
         phone:data.phone,
         clientType:"web",
         id:data.id,
@@ -45,6 +46,7 @@ export const studentQueryUserInfo = async () => {
       const data = res.data.student
       res.data = {
         instrumentId: res.data.instrumentId ? res.data.instrumentId.split(',')[0] : "",
+        specialInstrumentIds: res.data.instrumentId ? res.data.instrumentId.split(',') : [],
         phone:data.phone,
         clientType:"STUDENT",
         id:data.id,

+ 17 - 7
src/state.ts

@@ -665,10 +665,13 @@ export const onEnded = () => {
 };
 
 // 根据当前小节动态设置,右上角展示的速度
-const dynamicShowPlaySpeed = (index: number) => {
+const dynamicShowPlaySpeed = (index: number, isPlaying?: boolean) => {
   if (!headerColumnHide.value) {
-    // console.log('动态计算速度')
     const item: any = state.times[index];
+    if (state.section.length === 2 && item.MeasureNumberXML === state.sectionFirst.MeasureNumberXML) {
+      state.speed = state.section[0].measureSpeed || state.speed
+      return;
+    }
     if (item && item.measureSpeed ) {
       // console.log('速度1',item.measureSpeed)
       const newSpeed = Math.floor(state.basePlayRate * item.measureSpeed)
@@ -771,7 +774,7 @@ const handlePlaying = () => {
       }
     }
     gotoNext(item);
-    dynamicShowPlaySpeed(item.i);
+    dynamicShowPlaySpeed(item.i, true);
   }
 
   // 评测不播放叮咚节拍器
@@ -1488,10 +1491,17 @@ function initMusicSource(data: any, tracks: string[], partIndex: number, workRec
     accompanyObj = musicSheetAccompanimentList.find((item: any) => {
       return item.audioPlayType === "PLAY"
     })
-    // 是否全声部(isAllSubject)为true 时候没有乐器只有一个原音(比如节奏练习,这个曲子全部乐器都支持);当前用户有乐器就匹配  不然取第一个原音
-    musicObj = musicSheetSoundList.find((item: any) => {
-      return isAllSubject ? item.audioPlayType === "PLAY" : (item.audioPlayType === "PLAY" && item.musicalInstrumentId == instrumentId)
-    })
+    // 如果specialInstrumentIds有多个,是打击乐的声部,打击乐声部可能有多个乐器id
+    if (storeData.user?.specialInstrumentIds?.length) {
+      musicObj = musicSheetSoundList.find((item: any) => {
+        return isAllSubject ? item.audioPlayType === "PLAY" : (item.audioPlayType === "PLAY" && storeData.user?.specialInstrumentIds?.includes(item.musicalInstrumentId))
+      })
+    } else {
+      // 是否全声部(isAllSubject)为true 时候没有乐器只有一个原音(比如节奏练习,这个曲子全部乐器都支持);当前用户有乐器就匹配  不然取第一个原音
+      musicObj = musicSheetSoundList.find((item: any) => {
+        return isAllSubject ? item.audioPlayType === "PLAY" : (item.audioPlayType === "PLAY" && item.musicalInstrumentId == instrumentId)
+      })
+    }
     // 当没有找到原音的时候,并且instrumentId没有值的时候,取默认第一个乐器
     if(!musicObj && !instrumentId){
       musicObj = musicSheetSoundList.find((item: any) => {

+ 2 - 0
src/store.ts

@@ -23,6 +23,8 @@ type IUser = {
   schoolInfos?: any[];
   // 当前用户 绑定 的乐器
   instrumentId?: string;
+  // 如果学生的声部是打击乐,打击乐可能会有多个乐器id,
+  specialInstrumentIds?: any[];
   // 性别
   gender?: 1|0;
 };