Quellcode durchsuchen

feat: 支持传入part-name

TIANYONG vor 1 Woche
Ursprung
Commit
baedd5899a

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

@@ -95,6 +95,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

@@ -1469,10 +1469,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);
@@ -1491,11 +1501,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]] || '';

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

@@ -77,6 +77,7 @@ export default defineComponent({
           behaviorId: sessionStorage.getItem('behaviorId') || '',
           _t: new Date().valueOf(),
           'part-index': index,
+          'part-name': ''
         })
       console.log(_url)
       location.href = _url