From a26761b0895fc89280937dab533f154a8c46f1aa Mon Sep 17 00:00:00 2001 From: LiuJiaNan <15703339975@163.com> Date: Tue, 31 Mar 2026 14:11:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96addingPrefixToFile=E5=92=8Cge?= =?UTF-8?q?tLabelName=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/index.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index bdbe792..5fa1ed9 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -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]; } /**