Selaa lähdekoodia

Merge branch 'feature-tianyong-newVersion' of http://git.dayaedu.com/liushengqiang/music-score into hqyDevNewVersion

黄琪勇 11 kuukautta sitten
vanhempi
commit
8363e00bf0

+ 3 - 1
src/helpers/formateMusic.ts

@@ -1218,6 +1218,7 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 			if (svgElement?.modifiers?.length) {
 				hasGraceNote = svgElement?.modifiers.some((item: any) => item?.attrs?.type === "GraceNoteGroup")
 			}
+			const filterRepeatIdx = allNotes.filter((item: any) => item.noteId === note.NoteToGraphicalNoteObjectId).length
 			const nodeDetail = {
 				isStaccato: note.voiceEntry.isStaccato(),
 				isRestFlag: note.isRestFlag,
@@ -1265,7 +1266,8 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 				totalMultipleRestMeasures, // 当前小节总的合并小节数
 				measureSpeed,  // 小节速度
 				maxNoteNum: note.maxNoteNum, // 当前小节音符最多的分轨的音符数量
-				repeatIdx: iterator.repeatIdx || 0, // 标记是第几遍循环,从0开始
+				// repeatIdx: iterator.repeatIdx || 0, // 标记是第几遍循环,从0开始
+				repeatIdx: filterRepeatIdx,
 				xmlNoteTime: retain(xmlNoteTime), // xml上音符开始时间 唱名用
 				xmlNoteEndTime: retain(xmlNoteTime + noteLength), //xml上音符结束时间 唱名用
 				xmlMp3BeatFixTime,  //xml上节拍器的时间

+ 3 - 0
src/page-instrument/custom-plugins/work-ealuating/index.tsx

@@ -80,6 +80,9 @@ export default defineComponent({
 			getWorkData();
 			// verifyMembershipServices();
 		});
+		expose({
+			getWorkData
+		})		
 		return () => <div></div>;
 	},
 });

+ 2 - 1
src/page-instrument/custom-plugins/work-home/index.tsx

@@ -102,7 +102,8 @@ export default defineComponent({
 			// verifyMembershipServices();
 		});
 		expose({
-			handleAdd
+			handleAdd,
+			getWorkData
 		})
 		return () => (
 			<div class={styles.homework}>

+ 14 - 1
src/page-instrument/custom-plugins/work-index/index.tsx

@@ -5,8 +5,10 @@ import { getQuery } from "/src/utils/queryString";
 import { api_lessonTrainingTrainingStudentDetail } from "../../api";
 import { headTopData } from "../../header-top";
 import { evaluatingData } from "/src/view/evaluating";
+import state from "/src/state";
 
 const workHomeRef = ref();
+const workEvaluatRef = ref();
 
 export const data = reactive({
 	/** 作业类型:练习PRACTICE, 评测EVALUATION */
@@ -20,6 +22,17 @@ export const HANDLE_WORK_ADD = () => {
 	}
 };
 
+// 刷新谱面后,设置作业选段
+export const resetSection = () => {
+	if (data.trainingType === "PRACTICE"){
+		workHomeRef.value?.getWorkData();
+	}
+	if (data.trainingType === "EVALUATION") {
+		workHomeRef.value?.getWorkData();
+	}
+	state.workSectionNeedReset = false;
+};
+
 export default defineComponent({
 	name: "workIndex",
 	setup(props) {
@@ -56,7 +69,7 @@ export default defineComponent({
 				{data.trainingType === "PRACTICE" && <WorkHome ref={workHomeRef} workeData={data.worke} />}
 				{/* 评测作业 */}
 				{data.trainingType === "EVALUATION" && (
-					<WorkEaluating workeData={data.worke} />
+					<WorkEaluating ref={workEvaluatRef} workeData={data.worke} />
 				)}
 			</>
 		);

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

@@ -494,7 +494,10 @@ export default defineComponent({
       /** 作业模式 end */
       if (state.defaultModeType == 1) {
         headTopData.handleChangeModeType("practise");
-        if (state.platform === IPlatform.PC || state.isPreView) {
+        // if (state.platform === IPlatform.PC || state.isPreView) {
+        //   headTopData.showBack = false;
+        // }
+        if (state.isPreView) {
           headTopData.showBack = false;
         }
       } else {

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

@@ -22,7 +22,7 @@ import Tick, { handleInitTick } from "/src/view/tick";
 import FollowPractice, { followData } from "/src/view/follow-practice";
 import FollowModel from "../follow-model";
 import RecordingTime from "../custom-plugins/recording-time";
-import WorkIndex from "../custom-plugins/work-index";
+import WorkIndex, { resetSection } from "../custom-plugins/work-index";
 import TheMusicList, { isMusicList } from "../component/the-music-list";
 import { storeData } from "/src/store";
 import ViewFigner from "../view-figner";
@@ -277,7 +277,9 @@ export default defineComponent({
 
       evaluatCreateMusicPlayer();
       resetPlaybackToStart();
-
+      if (state.workSectionNeedReset) {
+        resetSection();
+      }
       // pushAppMusic();
       // console.timeEnd("渲染加载耗时");
     };

+ 11 - 4
src/state.ts

@@ -547,6 +547,8 @@ const state = reactive({
   xmlHasLyric: false,
   /** 生成图片的模式 */
   isCreateImg: false,
+  /** 切换谱面后,作业选段是否需要刷新 */
+  workSectionNeedReset: false,
 });
 const browserInfo = browser();
 let offset_duration = 0;
@@ -1418,7 +1420,8 @@ const setState = (data: any, index: number) => {
   /**
    * 单曲,指法根据用户当前的乐器来显示,如果没有则取musicSheetSoundList第一个track
    */
-  let musicalCode = !storeData.user?.instrumentId ? data.musicSheetSoundList?.find((item:any)=>{ return item.audioPlayType === "PLAY" })?.track || '' : data.musicSheetSoundList?.find((item: any) => item?.musicalInstrumentId == storeData.user?.instrumentId && item.audioPlayType === "PLAY")?.track || '';
+  const currentInstrumentId = query.instrumentId || storeData.user?.instrumentId;
+  let musicalCode = !currentInstrumentId ? data.musicSheetSoundList?.find((item:any)=>{ return item.audioPlayType === "PLAY" })?.track || '' : data.musicSheetSoundList?.find((item: any) => item?.musicalInstrumentId == currentInstrumentId && item.audioPlayType === "PLAY")?.track || '';
   const pitchSubject = musicalInstrumentCodeInfo.find((n) => n.code.toLocaleLowerCase() === subjectCode.toLocaleLowerCase())
   const pitchMusical = musicalInstrumentCodeInfo.find((n) => n.code.toLocaleLowerCase() === musicalCode.toLocaleLowerCase())
   state.subjectCodeId = pitchSubject ? pitchSubject.id : 0
@@ -1530,9 +1533,9 @@ const setState = (data: any, index: number) => {
   let pitchTrack = null
   if (state.isConcert) {
     musicalCode = musicalInstrumentCodeInfo.find((item: any) => item.id === state.musicalCodeId)?.code
-    pitchTrack = data.musicalInstruments?.find((item: any) => item.code === musicalCode)
+    pitchTrack = data.musicalInstruments?.find((item: any) => item.code?.split(',')[0] === musicalCode)
   } else {
-    pitchTrack = data.musicalInstruments?.find((item: any) => item.code === musicalCode)
+    pitchTrack = data.musicalInstruments?.find((item: any) => item.code?.split(',')[0] === musicalCode)
   }
   let musicalRenderType = ''
   // if (pitchTrack?.defaultScore) {
@@ -1700,7 +1703,8 @@ export const fillWordColor = () => {
   })
   const currentLyrics: SVGAElement[] = Array.from(document.querySelectorAll(`.lyric${currentNote?.noteId}`));
   currentLyrics.forEach((lyric, index) => {
-    if (index === currentNote.repeatIdx) {
+    const lyricIndex = lyric.getAttribute('lyricIndex');
+    if ((index === currentNote.repeatIdx && currentNote.repeatIdx + 1 == lyricIndex) || (currentNote.repeatIdx > 0 && currentNote.formatLyricsEntries?.length === 1)) {
       lyric?.classList.add('lyricActive')
     }
   })
@@ -1864,6 +1868,9 @@ export const refreshMusicSvg = () => {
   clearSelection();
   resetBaseRate();
   state.activeMeasureIndex = -1;
+  if (query.workRecord) {
+    state.workSectionNeedReset = true;
+  }
   // 销毁旋律线
   destroySmoothAnimation()
   musicScoreRef.value?.refreshMusicScore()

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

@@ -272,6 +272,8 @@ export const matchVoicePart = (id: number | string, type: "SINGLE" | "CONCERT"):
       "Bass Clarinet in Bb": 4,
       Bassoon: 1,
       "Alto Saxophone": 5,
+      "Alto Saxophone1": 5,
+      "Alto Saxophone2": 5,
       "Tenor Saxophone": 5,
       "Baritone Saxophone": 5,
       "Trumpet in Bb 1": 12,
@@ -336,7 +338,13 @@ export const matchVoicePart = (id: number | string, type: "SINGLE" | "CONCERT"):
       code = code.toLocaleLowerCase().replace(/ /g, "");
       for (let sKey in subject) {
         let pitchKey = sKey;
-        if (typeof sKey === "string") pitchKey = pitchKey.toLocaleLowerCase().replace(/ /g, "");
+        if (typeof sKey === "string") {
+          pitchKey = pitchKey.toLocaleLowerCase().replace(/ /g, "");
+        }
+        if (typeof sKey === "string") {
+          // 去掉声轨后面的数字
+          code = code.replace(/[_0-9]+$/, '');
+        }
         if (pitchKey === code) {
           _track = subject[sKey];
           break;