فهرست منبع

feat: 播放中小节背景问题修复

TIANYONG 1 سال پیش
والد
کامیت
9c864c0e54
4فایلهای تغییر یافته به همراه31 افزوده شده و 7 حذف شده
  1. 2 1
      src/helpers/customMusicScore.ts
  2. 24 2
      src/state.ts
  3. 3 2
      src/view/selection/index.tsx
  4. 2 2
      vite.config.ts

+ 2 - 1
src/helpers/customMusicScore.ts

@@ -536,10 +536,11 @@ export const resetFormate = () => {
 		// 给小节添加背景色
 		staves.forEach((stave: any) => {
 			const list = [
+				Array.from(stave?.querySelectorAll(".vf-StaveSection") || []),
+				Array.from(stave?.querySelectorAll(".vf-Volta") || []),
 				Array.from(stave?.querySelectorAll(".vf-clef") || []),
 				Array.from(stave?.querySelectorAll(".vf-keysignature") || []),
 				Array.from(stave?.getElementsByTagName("text") || []),
-				Array.from(stave?.querySelectorAll(".vf-StaveSection") || []),
 			].flat();
 			try {
 				if (list.length) {

+ 24 - 2
src/state.ts

@@ -1566,9 +1566,31 @@ export const moveSvgDom = (skipNote?: boolean) => {
 watch(
 	() => state.activeMeasureIndex,
 	() => {
-    console.log('当前小节',state.activeMeasureIndex)
+    // 需要减去的合并小节数
+    let needReduceMultipleRestNum = 0;
+    for(let noteIndex = 0; noteIndex < state.times.length; noteIndex++){
+      const note =  state.times[noteIndex];
+      if (note.MeasureNumberXML > state.activeMeasureIndex) {
+        break;
+      }
+      if (note.multipleRestMeasures) {
+        // if (note.multipleRestMeasures < note.totalMultipleRestMeasures) {
+        //   needReduceMultipleRestNum += note.MeasureNumberXML - note.multipleRestMeasures + 1;
+        // } else {
+        //   needReduceMultipleRestNum += note.totalMultipleRestMeasures - 1;
+        // }
+        // needReduceMultipleRestNum += note.MeasureNumberXML - note.multipleRestMeasures + 1;
+        needReduceMultipleRestNum += 1;
+      }
+      // if (note.multipleRestMeasures === 0 && state.times[noteIndex-1]?.multipleRestMeasures) {
+      //   needReduceMultipleRestNum += state.times[noteIndex-1]?.multipleRestMeasures
+      // }
+    }
+    needReduceMultipleRestNum = needReduceMultipleRestNum >= 0 ? needReduceMultipleRestNum : 0;
+    const matchMeasureNum = state.activeMeasureIndex - needReduceMultipleRestNum
+    console.log('选中的小节',matchMeasureNum,'需要减去的小节',needReduceMultipleRestNum,'当前的小节',state.activeMeasureIndex)
     state.vfmeasures.forEach((item: any, idx: number) => {
-      if (idx === (state.activeMeasureIndex-1)) {
+      if (idx === matchMeasureNum) {
         item.querySelector('.vf-custom-bg')?.setAttribute("fill", "#132D4C")
         item.querySelector('.vf-custom-bot')?.setAttribute("fill", "#040D1E")
       } else {

+ 3 - 2
src/view/selection/index.tsx

@@ -208,13 +208,14 @@ export default defineComponent({
 								}
 								return styles.rightStaveBox;
 							}
-							return styles.staveBox + " staveBox";  // 加上固定css 一行谱可以隐藏
+							return "";
 						}
 					}
 				} else {
 					if (state.activeMeasureIndex == item.MeasureNumberXML && !state.isReport) {
+						// console.log('当前的小节',state.activeMeasureIndex,item.MeasureNumberXML)
 						item.staveBox.height = selectData.measureHeight + 'px';
-						return styles.staveBox + " staveBox"; // 加上固定css 一行谱可以隐藏
+						return "";
 					}
 				}
 			};

+ 2 - 2
vite.config.ts

@@ -76,9 +76,9 @@ export default defineConfig({
         // target: "https://kt.colexiu.com",
         // target: "https://test.lexiaoya.cn",
         // target: "https://kt.colexiu.com",
-        //target: "https://test.resource.colexiu.com", // 内容平台开发环境,内容平台开发,需在url链接上加上isCbs=true
+        target: "https://test.resource.colexiu.com", // 内容平台开发环境,内容平台开发,需在url链接上加上isCbs=true
         //target: "https://dev.resource.colexiu.com",
-        target: "https://dev.kt.colexiu.com",
+        // target: "https://dev.kt.colexiu.com",
         //target: "https://mec.colexiu.com",
         changeOrigin: true,
         rewrite: (path) => path.replace(/^\/instrument/, ""),