Commit 6d844a0d by qinjianhui

fix: DTF列表下载素材名称修改

parent a19250fe
......@@ -242,12 +242,21 @@ async function batchDownloadByList(urlList, targetDir, options = {}) {
// 2. 并发执行下载
const limit = pLimit(concurrency);
const tasks = urlList.map(urlStr =>
const tasks = urlList.map(item =>
limit(async () => {
const fullUrl = baseUrl ? resolveUrl(urlStr, baseUrl) : urlStr;
const fileName = fileNameFormatter
? fileNameFormatter(urlStr, baseUrl)
: getFileName(urlStr);
let fullUrl, fileName;
if (typeof item === "object" && item !== null) {
const rawUrl = item.url;
fullUrl = isAbsoluteUrl(rawUrl)
? rawUrl
: `${baseUrl.replace(/\/$/, "")}/${rawUrl.replace(/^\//, "")}`;
fileName = item.fileName || getFileName(rawUrl);
} else {
fullUrl = baseUrl ? resolveUrl(item, baseUrl) : item;
fileName = fileNameFormatter
? fileNameFormatter(item, baseUrl)
: getFileName(item);
}
const savePath = path.join(targetDir, fileName);
try {
......
......@@ -446,11 +446,10 @@ export default {
const { data } = await this.$api.post(pathMap["listMaterialsByBatch"], {
batchArrangeNum: value
});
// const newUrls = data.flatMap(el => el.urls);
const newUrls = data.flatMap(({ operationNo, urls }) =>
urls.map(url => `${url}-${operationNo}`)
);
console.log(newUrls);
const newUrls = data.map(item => ({
url: item.fileUrl,
fileName: item.fileName
}));
if (newUrls.length === 0) {
this.$message.warning("该批次暂无素材可下载");
......
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