浏览代码

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

TIANYONG 1 年之前
父节点
当前提交
22ab76b969
共有 3 个文件被更改,包括 19 次插入3 次删除
  1. 1 1
      src/helpers/formateMusic.ts
  2. 10 0
      src/page-instrument/view-detail/index.module.less
  3. 8 2
      src/state.ts

+ 1 - 1
src/helpers/formateMusic.ts

@@ -1258,7 +1258,7 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 			 * evxml的曲子,如果曲谱xml中带有times信息,则音符时值优先取times中的值
 			 * 曲子:1795013295024062466(春暖花开),如果音符有times信息,休止符没有times信息,此种规则是认为休止符不参与时值计算的,需要过滤掉该休止符
 			 */
-			if (state.isEvxml && note.isRestFlag && note?.noteTimeInfo?.length === 0 && state.xmlHasTimes) {
+			if (state.isEvxml && note.isRestFlag && note?.noteTimeInfo?.length === 0 && state.xmlHasTimes && _notes[i-1]?.note?.noteTimeInfo?.[0]?.end === _notes[i+1]?.note?.noteTimeInfo?.[0]?.begin) {
 				note.maxNoteNum = note.maxNoteNum - 1;
 				continue;
 			}

+ 10 - 0
src/page-instrument/view-detail/index.module.less

@@ -254,6 +254,16 @@
                 stroke: #000000;
             }
         }
+        .voiceActive {
+            rect {
+                fill: #000000;
+                stroke: #000000;
+            }
+        }
+        .rectActive {
+            fill: #000000;
+            stroke: #000000;
+        }
     }
 }
 

+ 8 - 2
src/state.ts

@@ -1837,7 +1837,10 @@ export const fillWordColor = () => {
     // stemLine?.classList.remove('noteActive')
     svgEl?.parentElement?.classList.remove('voiceActive')
     const si = state.times[prevActiveNoteIndex].si || 0;
-    svgEl?.parentElement?.querySelectorAll('rect')?.[si]?.classList.remove('rectActive');
+    svgEl?.parentElement?.querySelectorAll('rect')?.forEach((item: any) => {
+      item?.classList.remove('rectActive');
+    })
+    // svgEl?.parentElement?.querySelectorAll('rect')?.[si]?.classList.remove('rectActive');
   }
   const activeNoteId = state.times[state.activeNoteIndex]?.svgElement?.attrs?.id
   const svgEl = document.getElementById(`vf-${activeNoteId}`)
@@ -1854,7 +1857,10 @@ export const fillWordColor = () => {
       // 如果是二分音符,只亮该音符后面那个"-",本小节其它的"-"不亮
       if (state.times[state.activeNoteIndex].noteElement?.length?.realValue === 0.5) {
         const si = state.times[state.activeNoteIndex].si || 0;
-        svgEl?.parentElement?.querySelectorAll('rect')[si].classList.add('rectActive');
+        const halfNotes = state.times[state.activeNoteIndex].measures.filter((item: any) => item?.noteElement?.length?.realValue === 0.5) || [];
+        const sIdx = halfNotes?.findIndex((item: any) => item?.noteElement === state.times[state.activeNoteIndex]?.noteElement);
+        const filterRects = svgEl?.parentElement?.querySelectorAll('rect')?.length ? Array.from(svgEl?.parentElement?.querySelectorAll('rect')).filter(item => item.parentElement === svgEl?.parentElement) : [];
+        filterRects?.[sIdx]?.classList.add('rectActive');
       } else {
         svgEl?.parentElement?.classList.add('voiceActive');
       }