chore: 优化代码

This commit is contained in:
dap 2025-01-03 15:30:55 +08:00
parent 103b1a6f4a
commit 1a535e5202

View File

@ -90,8 +90,25 @@ watch(
value = v;
const withUrlList: UploadProps['fileList'] = [];
for (const item of _fileList) {
// ossId
if (props.resultField !== 'ossId') {
// ossId
if (props.resultField === 'ossId') {
const resp = await ossInfo([item]);
if (item && isString(item)) {
withUrlList.push({
uid: item, // ossIduid 便getValue
name: item.slice(Math.max(0, item.lastIndexOf('/') + 1)),
status: 'done',
url: resp?.[0]?.url,
});
} else if (item && isObject(item)) {
withUrlList.push({
...(item as any),
uid: item,
url: resp?.[0]?.url,
});
}
} else {
// ossId
if (item && isString(item)) {
withUrlList.push({
uid: uniqueId(),
@ -102,23 +119,6 @@ watch(
} else if (item && isObject(item)) {
withUrlList.push(item);
}
return;
}
// ossId
const resp = await ossInfo([item]);
if (item && isString(item)) {
withUrlList.push({
uid: item, // ossIduid 便getValue
name: item.slice(Math.max(0, item.lastIndexOf('/') + 1)),
status: 'done',
url: resp?.[0]?.url,
});
} else if (item && isObject(item)) {
withUrlList.push({
...(item as any),
uid: item,
url: resp?.[0]?.url,
});
}
}
fileList.value = withUrlList;