优化addingPrefixToFile和getLabelName实现
parent
c745ad72e1
commit
a26761b089
|
|
@ -264,12 +264,11 @@ export function addingPrefixToFile(list, options = {}) {
|
||||||
return [];
|
return [];
|
||||||
const { pathKey = "filePath", nameKey = "fileName", idKey = "id" } = options;
|
const { pathKey = "filePath", nameKey = "fileName", idKey = "id" } = options;
|
||||||
const FILE_URL = getFileUrl();
|
const FILE_URL = getFileUrl();
|
||||||
for (let i = 0; i < list.length; i++) {
|
return list.filter(item => item[pathKey]).map(item => ({
|
||||||
list[i].url = FILE_URL + list[i][pathKey];
|
url: FILE_URL + item[pathKey],
|
||||||
list[i].name = list[i][nameKey] || getFileName(list[i][pathKey]);
|
name: item[nameKey] || getFileName(item[pathKey]),
|
||||||
list[i].id = list[i][idKey];
|
id: item[idKey],
|
||||||
}
|
}));
|
||||||
return list;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -277,10 +276,8 @@ export function addingPrefixToFile(list, options = {}) {
|
||||||
*/
|
*/
|
||||||
export function getLabelName(options) {
|
export function getLabelName(options) {
|
||||||
const { status, list, idKey = "bianma", nameKey = "name" } = options;
|
const { status, list, idKey = "bianma", nameKey = "name" } = options;
|
||||||
for (let i = 0; i < list.length; i++) {
|
const item = list.find(item => item[idKey]?.toString() === status?.toString()) || { [nameKey]: "" };
|
||||||
if (status?.toString() === list[i][idKey]?.toString())
|
return item[nameKey];
|
||||||
return list[i][nameKey];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue