Quellcode durchsuchen

Merge branch 'feature-patch' into gym-test

TIANYONG vor 1 Monat
Ursprung
Commit
ec6cc34b21
2 geänderte Dateien mit 24 neuen und 17 gelöschten Zeilen
  1. 24 16
      src/constant/instruments.ts
  2. 0 1
      src/state.ts

+ 24 - 16
src/constant/instruments.ts

@@ -436,22 +436,30 @@ export let instruments: any = {}
 
 /** 获取分轨名称 */
 export const getInstrumentName = (name = '') => {
-  name = name.toLocaleLowerCase().replace(/ /g, '')
-  if (!name) return ''
-  for(let key in instruments){
-    const _key = key.toLocaleLowerCase().replace(/ /g, '')
-    if (_key.includes(name)){
-      return instruments[key]
-    }
-  }
-  for(let key in instruments){
-    const _key = key.toLocaleLowerCase().replace(/ /g, '')
-    if (name.includes(_key)){
-      return instruments[key]
-    }
-  }
-  return ''
-};
+	name = name.toLocaleLowerCase().replace(/[0-9\s]/g, '')
+	if (!name) return ''
+	// 全匹配声轨名称
+	for(let key in instruments){
+	  const _key = key.toLocaleLowerCase().replace(/ /g, '')
+	  if (_key === name){
+		return instruments[key]
+	  }
+	}
+	// 用返回的code模糊匹配传入的xml声轨名称name
+	for(let key in instruments){
+	  const _key = key.toLocaleLowerCase().replace(/ /g, '')
+	  if (_key.includes(name)){
+		return instruments[key]
+	  }
+	}
+  //   for(let key in instruments){
+  //     const _key = key.toLocaleLowerCase().replace(/ /g, '')
+  //     if (name.includes(_key)){
+  //       return instruments[key]
+  //     }
+  //   }
+	return ''
+  };
 
 /**
  * 乐器排序

+ 0 - 1
src/state.ts

@@ -26,7 +26,6 @@ import { HANDLE_WORK_ADD } from "/src/page-instrument/custom-plugins/work-index"
 import { speedBeatTo, unitImgs } from "/src/helpers/beatConfig"
 import IndexedDBService from "/src/utils/indexedDB";
 import { musicalInstrumentCodeInfo, instruments, fixInstrumentNameCode } from "/src/constant/instruments";
-import { match } from "assert";
 
 const query: any = getQuery();