Quellcode durchsuchen

fix: #10124 妙极客倚音音符渲染

TIANYONG vor 1 Jahr
Ursprung
Commit
7f98843410
1 geänderte Dateien mit 13 neuen und 2 gelöschten Zeilen
  1. 13 2
      src/helpers/formateMusic.ts

+ 13 - 2
src/helpers/formateMusic.ts

@@ -661,8 +661,11 @@ export const formatXML = (xml: string, xmlUrl?: string): string => {
 				// if (note.getElementsByTagName("space").length && !note.getElementsByTagName("duration").length) {
 				// 	measure.removeChild(note);
 				// }
-				if (!note.getElementsByTagName("duration").length || (note.getElementsByTagName("duration").length && note.getElementsByTagName("duration")[0]?.textContent == 0)) {
-					measure.removeChild(note);
+				// 非倚音音符
+				if (!note.getElementsByTagName("grace").length) {
+					if (!note.getElementsByTagName("duration").length || (note.getElementsByTagName("duration").length && note.getElementsByTagName("duration")[0]?.textContent == 0)) {
+						measure.removeChild(note);
+					}
 				}
 			});
 		}
@@ -1273,6 +1276,7 @@ export const verifyCanRepeat = (startNum: number, endNum: number) => {
 const customizationXml = (xmlParse: any) => {
 	const credits: any = Array.from(xmlParse.querySelectorAll('credit'));
 	const creators: any = Array.from(xmlParse.querySelectorAll('creator'));
+	const graces: any = Array.from(xmlParse.querySelectorAll('grace'));
 	if (credits && credits.length) {
 		for (const credit of credits) {
 			if (credit.getElementsByTagName("credit-type")?.[0]?.textContent === 'lyricist') {
@@ -1289,6 +1293,13 @@ const customizationXml = (xmlParse: any) => {
 			
 		}
 	}
+	// 妙极客xml的倚音(grace)标签需要加上slash=yes属性
+	if (graces && graces.length) {
+		for (const grace of graces) {
+			grace?.setAttribute('slash','yes');
+			// console.log(grace,'倚音')
+		}
+	}
 }
 
 // 计算evxml的起始播放时间