Browse Source

fix: bug修复

TIANYONG 1 year ago
parent
commit
79574a939a
4 changed files with 17 additions and 6 deletions
  1. 1 1
      osmd-extended
  2. 2 0
      src/helpers/formateMusic.ts
  3. 8 4
      src/state.ts
  4. 6 1
      src/view/selection/index.tsx

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit 78cf85a380c3a18fe0a71a890ff37dbc25707eae
+Subproject commit ff177488dd2d563ad84730f7fb37a7a6c00e02da

+ 2 - 0
src/helpers/formateMusic.ts

@@ -932,6 +932,7 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 			// console.log('relaEndtime',noteLength, relativeTime)
 			const fixedKey = note.fixedKey || 0;
 			const svgElement = activeVerticalMeasureList[0]?.vfVoices["1"]?.tickables[si];
+			// console.log('si',si,i)
 			// console.log(note.sourceMeasure.MeasureNumberXML,note,svgElement, NoteRealValue, measureLength)
 			if (allNotes.length && allNotes[allNotes.length - 1].relativeTime === relativeTime) {
 				continue;
@@ -1038,6 +1039,7 @@ export const formateTimes = (osmd: OpenSheetMusicDisplay) => {
 			}
 			// console.log(note.sourceMeasure.MeasureNumberXML, note.sourceMeasure.verticalSourceStaffEntryContainers.length)
 			// console.log('👀看看endtime', nodeDetail.duration, relaEndtime, fixtime, i)
+			tickables = tickables.filter((tickable: any) => tickable.attrs?.type !== "GhostNote")
 			nodeDetail.noteLength = tickables.length || 1;
 			allNotes.push(nodeDetail);
 			allNoteId.push(nodeDetail.id);

+ 8 - 4
src/state.ts

@@ -817,10 +817,14 @@ export const handleChangeSection = () => {
 const formateSelectMearure = (_list: any[]): any[] => {
   if (!_list.length) return [];
   const list = _list.sort((a, b) => a.time - b.time);
-  const startXml = list[0]?.measureOpenIndex;
-  const endXml = list.last()?.measureOpenIndex;
-  const selectStartMeasure = state.times.filter((n: any) => startXml === n.measureOpenIndex) || [];
-  const selectEndMeasure = state.times.filter((n: any) => endXml === n.measureOpenIndex) || [];
+  /**
+   * bug: #9860
+   * measureOpenIndex替换为MeasureNumberXML匹配
+   */
+  const startXml = list[0]?.MeasureNumberXML;
+  const endXml = list.last()?.MeasureNumberXML;
+  const selectStartMeasure = state.times.filter((n: any) => startXml === n.MeasureNumberXML) || [];
+  const selectEndMeasure = state.times.filter((n: any) => endXml === n.MeasureNumberXML) || [];
   // 没有找到选段小节
   if (!selectStartMeasure.length || !selectEndMeasure.length) {
     clearSelection();

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

@@ -76,6 +76,11 @@ const calcNoteData = () => {
 					}
 					
 				}
+				// if (selectData.notes.find((item:any) => item.id === noteItem.id)) {
+				// 	// 
+				// } else {
+				// 	selectData.notes.push(noteItem);
+				// }
 				selectData.notes.push(noteItem);
 				notesList.push(item.noteId);
 			}
@@ -140,7 +145,7 @@ const calcNoteData = () => {
 			}
 		}
 	}
-	console.log("🚀 ~ selectData.notes:", selectData.notes, selectData.staves);
+	console.log("🚀 ~ selectData.notes:", selectData.notes, selectData.staves,notesList,MeasureNumberXMLList);
 };
 
 /** 重新计算 */