Explorar o código

feat: 声轨名称匹配规则修改

TIANYONG hai 3 semanas
pai
achega
5e9349c439
Modificáronse 1 ficheiros con 24 adicións e 16 borrados
  1. 24 16
      src/constant/instruments.ts

+ 24 - 16
src/constant/instruments.ts

@@ -433,22 +433,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 ''
+  };
 
 /**
  * 乐器排序