Browse Source

Merge branch 'feature-partName' into feature-tianyong

TIANYONG 1 week ago
parent
commit
8d50bbf4b5

+ 1 - 1
osmd-extended

@@ -1 +1 @@
-Subproject commit 8646ea65db6520df8fe8d5d180d5c9dcf634e2b2
+Subproject commit 43dc4f3b6489924056a28b1c1c5a40771d150378

+ 1 - 0
src/page-instrument/component/the-music-list/list.tsx

@@ -150,6 +150,7 @@ export default defineComponent({
       }
       queryObj.id = item.id
       queryObj["part-index"] = ""
+      queryObj["part-name"] = ""
       location.href =
         location.origin +
         location.pathname +

+ 11 - 5
src/state.ts

@@ -1492,10 +1492,20 @@ const getMusicInfo = async (res: any) => {
   state.isScoreRender = res.data?.isScoreRender
   // 是否默认显示总谱
   state.defaultScoreRender = res.data?.defaultScoreRender
+  /* 获取声轨列表 */
+  let xmlString = await fetch(res.data.xmlFileUrl).then((response) => response.text());
+  xmlString = xmlAddPartName(xmlString);
+  downloadXmlStr.value = xmlString //给musice-score 赋值xmlString 以免加载2次
+  const tracks = xmlToTracks(xmlString) //获取声轨列表
   // 是否显示节拍器  (管乐迷 默认显示节拍器)
   //state.isMixBeat = res.data?.isMixBeat  
   /* 设置partIndex */
   let partIndexs = query["part-index"] ? query["part-index"].split(",") : ["-1"] // -1为partIndex没有值的时候
+  // 如果传入的是part-name,需要将part-name转换成part-index
+  if (query["part-name"]) {
+    let nameIdx = tracks.findIndex((item: any) => item == query["part-name"])
+    partIndexs = [nameIdx]
+  }
   partIndexs = partIndexs.map((indexStr:string) => {
     return parseInt(indexStr)
   }).sort((a, b) => a - b);
@@ -1514,11 +1524,7 @@ const getMusicInfo = async (res: any) => {
   // multiTracksSelection 返回为空,默认代表全部分轨
   state.canSelectTracks = res.data.multiTracksSelection === "null" || res.data.multiTracksSelection === "" || res.data.multiTracksSelection === null ? [] : res.data.multiTracksSelection?.split(',');
   state.canSelectTracks = state.canSelectTracks.map((item: any)=>item.trim())
-  /* 获取声轨列表 */
-  let xmlString = await fetch(res.data.xmlFileUrl).then((response) => response.text());
-  xmlString = xmlAddPartName(xmlString);
-  downloadXmlStr.value = xmlString //给musice-score 赋值xmlString 以免加载2次
-  const tracks = xmlToTracks(xmlString) //获取声轨列表
+
   // 如果是多个分轨合并显示的,需要记录下所选分轨的第一个分轨的名字,渲染计算音符位置的时候需要根据第一个分轨找到对应音符的位置
   if (state.combinePartIndexs.length) {
     (window as any).DYFirstTrackName = tracks[state.combinePartIndexs[0]] || '';

+ 2 - 1
src/view/plugins/toggleMusicSheet/index.tsx

@@ -77,7 +77,8 @@ export default defineComponent({
           ...query,
           behaviorId: sessionStorage.getItem('behaviorId') || '',
           _t: new Date().valueOf(),
-          'part-index': index
+          'part-index': index,
+          'part-name': ''
         })
       console.log(_url)
       // 如果开启了摄像头, 结束录制视频