Commit 0a09ab66 authored by XieZhiXiong's avatar XieZhiXiong

chore: 搬运逻辑

parent ac787994
......@@ -96,6 +96,26 @@ const testOpts = (ext, options) => {
return true
}
const getURL = (target: any) => {
return target?.['url'] || target?.['downloadURL'] || target?.['imgURL']
}
const getThumbURL = (target: any) => {
return (
target?.['thumbUrl'] ||
target?.['url'] ||
target?.['downloadURL'] ||
target?.['imgURL']
)
}
const getState = (target: any) => {
if (target?.success === false) return 'error'
if (target?.failed === true) return 'error'
if (target?.error) return 'error'
return target?.state || target?.status
}
const getImageByUrl = (url, options) => {
for (let i = 0; i < exts.length; i++) {
if (exts[i].ext.test(url) && testOpts(exts[i].ext, options)) {
......@@ -108,17 +128,19 @@ const getImageByUrl = (url, options) => {
const normalizeFileList = fileList => {
if (fileList && fileList.length) {
return fileList.map(file => {
return file.response ? {
uid: file.uid,
status: file.status,
url: file.downloadURL || file.imgURL || file.url,
...file.response.data,
name: file.name,
thumbUrl: file.imgURL || getImageByUrl(file.downloadURL || file.url, {
exclude: ['.png', '.jpg', '.jpeg', '.gif']
}),
} : file;
return fileList.map((file, index) => {
return {
...file,
uid: file.uid || `${index}`,
status: getState(file.response) || getState(file),
url: getURL(file) || getURL(file?.response),
thumbUrl: getImageByUrl(
getThumbURL(file) || getThumbURL(file?.response),
{
exclude: ['.png', '.jpg', '.jpeg', '.gif'],
}
),
}
})
}
return []
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment