|
@@ -481,24 +481,29 @@ export const stackInstruments: any = {
|
|
|
Cymbals: '镲'
|
|
|
};
|
|
|
|
|
|
-/** 获取分轨名称 */
|
|
|
-export const getInstrumentName = (instruments: any, 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];
|
|
|
+/**
|
|
|
+ * 获取乐器名称
|
|
|
+ * @param instruments 乐器列表
|
|
|
+ * @param instrumentName 乐器code
|
|
|
+ * @returns
|
|
|
+ */
|
|
|
+export const getInstrumentName = (instruments: any, instrumentName: string) => {
|
|
|
+ const _instrumentName = instrumentName.replace(/ /g, '').toLocaleLowerCase()
|
|
|
+ const _instrument = Object.keys(instruments)
|
|
|
+ for (let i = 0; i < _instrument.length; i++) {
|
|
|
+ const _name = _instrument[i].replace(/ /g, '').toLocaleLowerCase()
|
|
|
+ if (_name === _instrumentName) {
|
|
|
+ return instruments[_instrument[i]] || ''
|
|
|
}
|
|
|
}
|
|
|
- for (let key in instruments) {
|
|
|
- const _key = key.toLocaleLowerCase().replace(/ /g, '');
|
|
|
- if (name.includes(_key)) {
|
|
|
- return instruments[key];
|
|
|
+ for (let i = 0; i < _instrument.length; i++) {
|
|
|
+ const _name = _instrument[i].replace(/ /g, '').toLocaleLowerCase()
|
|
|
+ if (_name.includes(_instrumentName)) {
|
|
|
+ return instruments[_instrument[i]] || ''
|
|
|
}
|
|
|
}
|
|
|
- return '';
|
|
|
-};
|
|
|
+ return ''
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* 乐器排序
|