Commit 6d844a0d by qinjianhui

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

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