Browse Source

Merge branch 'gyt-feature-tianyong' into online

TIANYONG 1 year ago
parent
commit
fa2d1e15ea
3 changed files with 58 additions and 0 deletions
  1. 44 0
      src/music-sheet/index.tsx
  2. 2 0
      src/pages/detail/state.ts
  3. 12 0
      src/subpages/colexiu/uses/use-app.ts

+ 44 - 0
src/music-sheet/index.tsx

@@ -207,6 +207,50 @@ export default defineComponent({
       // if (svgBBox.y < 0) {
       //   svg.setAttribute('height', Number(svg.getAttribute('height')) - svgBBox.y + '')
       // }
+      const stafflines: SVGAElement[] = Array.from((container.value as HTMLElement).querySelectorAll(".staffline"));
+      const musicalDistance = 28; // 音阶与第一条线谱的间距,默认设置为28
+			for (let i = 0, len = stafflines.length; i < len; i++) {
+				const staffline = stafflines[i];
+				const stafflineBox = staffline.getBBox();
+				const stafflineCenter = stafflineBox.y + stafflineBox.height / 2;
+				const paths: SVGAElement[] = Array.from(staffline.querySelectorAll(".vf-measure > .vf-stave path"));
+				// 获取第一个线谱的y轴坐标
+				const firstLinePathY = paths[0]?.getBBox().y || 0
+
+        let vftexts = Array.from(staffline.querySelectorAll(".vf-text > text")).filter((n: any) => n.getBBox().y < stafflineCenter);
+				// 修改音阶和线谱的间距
+				const clefList = ['C', 'G', 'D', 'A', 'E', 'B', 'F#', 'C#', 'G#', 'F', 'Bb', 'Eb', 'Ab', 'Db', 'Gb', 'Cb', 'Fb', 'D#', 'A#', 'E#']
+				const btransList = ['Bb', 'Eb', 'Ab', 'Db', 'Gb', 'Cb', 'Fb']
+				const jtrsnsList = ['F#', 'C#', 'G#', 'D#', 'A#', 'E#', 'B#']
+				vftexts.forEach((label: any) => {
+					const labelText = label.textContent as string
+					if (clefList.includes(labelText)){
+						const _y = Number(label.getAttribute("y"))
+						const endY = firstLinePathY ? firstLinePathY - musicalDistance : _y
+						label.setAttribute("y", endY)
+					}
+					if (btransList.includes(labelText)) {
+						label.textContent = labelText.replace('b','♭')
+					}
+					if (jtrsnsList.includes(labelText)) {
+						label.textContent = labelText.replace('#','♯')
+					}
+				});
+
+			}
+
+      setTimeout(() => resetGlobalText())
+
+    }
+    const resetGlobalText = () => {
+      if (!container.value) return
+      // 速度dom
+      const vfstavetempo: SVGAElement[] = Array.from(container.value.querySelectorAll('.vf-stavetempo'))
+      if (detailState.isDaYaCategory) {
+        vfstavetempo.forEach((child: SVGAElement, i: number) => {
+          child.style.display = 'none'
+        })
+      }
     }
     /**
      * 重新渲染曲谱方法

+ 2 - 0
src/pages/detail/state.ts

@@ -90,6 +90,8 @@ const state = reactive({
   isHideEvaluatReportSaveBtn: false,    
   /** 合奏曲目是否合并展示 */
   isCombineRender: false,
+  /** 大雅金唐类目 */
+  isDaYaCategory: false,
 })
 
 export const isRhythmicExercises = (musicName?: string) => {

+ 12 - 0
src/subpages/colexiu/uses/use-app.ts

@@ -25,6 +25,12 @@ const skpList = ['Ukulele']
  */
 export const classids = [1, 2, 6, 7, 8, 9, 3, 10, 11, 12, 13, 4, 14, 15, 16, 17, 30, 31, 35, 36, 108];  // 大雅金唐, 竖笛教程, 声部训练展开的分类ID
 // export const classids = [1, 30, 97]; // [大雅金唐, 竖笛教程, 声部训练]
+
+/**
+ * 大雅金唐类目
+ */
+const daYaClassids = [1, 2, 6, 7, 8, 9, 3, 10, 11, 12, 13, 4, 14, 15, 16, 17]
+
 /**
  * 获取xml并前置格式化
  * @param url xml地址
@@ -175,6 +181,12 @@ export const useDetail = (id: number | string): [Ref<ShaeetStatusType>, Ref<Musi
       }
       // 设置是否特殊曲谱, 是特殊曲谱取反(不理解之前的思考逻辑), 使用后台设置的速度
       detailState.isSpecialBookCategory = !classids.includes(res.data.musicSheetCategoriesId) 
+      // 大雅金唐类目,#9248 优化
+      detailState.isDaYaCategory = daYaClassids.includes(res.data.musicSheetCategoriesId)
+      if (detailState.isDaYaCategory) {
+        ;(window as any).customSectionAmount = true
+        setGlobalData('wrapNum', 4)
+      }
       detailState.subjectId = Number(musicInfo.musicSubject)
       // 打击乐声部下的曲目,需要合并展示所有分轨
       if (Number(res.data.musicSubject) === 1 && res.data.background?.length > 1) {