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