Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
electron-printer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhuzhequan
electron-printer
Commits
be92fa13
Commit
be92fa13
authored
Jul 29, 2026
by
qinjianhui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 排版时有异常素材时将素材下载致手动排版素材或者自动排版素材
parent
eaf3d836
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
140 additions
and
28 deletions
+140
-28
src/utils/download-queue.js
+33
-2
src/utils/download-typesetting.js
+20
-3
src/views/dtf-batch-detail/components/detailHead.vue
+49
-19
src/views/dtf-list/index.vue
+38
-4
No files found.
src/utils/download-queue.js
View file @
be92fa13
...
@@ -2,7 +2,7 @@ const path = require("path");
...
@@ -2,7 +2,7 @@ const path = require("path");
const
{
pathMap
}
=
require
(
"@/config/index.js"
);
const
{
pathMap
}
=
require
(
"@/config/index.js"
);
const
{
getDTFSetting
,
getHostApi
}
=
require
(
"@/server/utils/store"
);
const
{
getDTFSetting
,
getHostApi
}
=
require
(
"@/server/utils/store"
);
import
api
from
"./request"
;
import
api
from
"./request"
;
const
{
batchDownloadByStr
}
=
require
(
"./download-core.js"
);
const
{
batchDownloadByStr
,
batchDownloadByList
}
=
require
(
"./download-core.js"
);
/* ========== 全局状态 ========== */
/* ========== 全局状态 ========== */
const
taskState
=
{
const
taskState
=
{
...
@@ -67,13 +67,44 @@ async function processBatchItem(item) {
...
@@ -67,13 +67,44 @@ async function processBatchItem(item) {
}
}
// 调用核心批量下载
// 调用核心批量下载
await
batchDownloadByStr
(
urlStr
,
saveDir
,
{
const
downloadRes
=
await
batchDownloadByStr
(
urlStr
,
saveDir
,
{
concurrency
:
taskState
.
maxImageConcurrency
,
concurrency
:
taskState
.
maxImageConcurrency
,
timeout
:
30000
,
timeout
:
30000
,
baseUrl
:
getHostApi
().
fileApiUrl
,
baseUrl
:
getHostApi
().
fileApiUrl
,
isCheck
:
true
,
isCheck
:
true
,
batchId
:
batchArrangeNum
batchId
:
batchArrangeNum
});
});
if
(
downloadRes
&&
downloadRes
.
skipped
)
return
;
try
{
const
listRes
=
await
api
.
post
(
pathMap
[
"listMaterialsByBatch"
],
{
batchArrangeNum
});
const
materials
=
Array
.
isArray
(
listRes
&&
listRes
.
data
)
?
listRes
.
data
:
Array
.
isArray
(
listRes
)
?
listRes
:
[];
const
abnormalItems
=
materials
.
filter
(
item
=>
item
&&
item
.
abnormal
);
if
(
!
abnormalItems
.
length
)
return
;
const
extraFiles
=
abnormalItems
.
map
(
item
=>
({
url
:
item
.
fileUrl
,
fileName
:
`异常素材
${
item
.
fileName
}
`
}));
console
.
log
(
`[自动排版] 批次
${
batchArrangeNum
}
异常素材
${
extraFiles
.
length
}
个`
);
await
batchDownloadByList
(
extraFiles
,
saveDir
,
{
concurrency
:
taskState
.
maxImageConcurrency
,
timeout
:
30000
,
baseUrl
:
getHostApi
().
fileApiUrl
});
}
catch
(
err
)
{
console
.
error
(
"自动排版补下载异常素材失败"
,
err
);
}
}
}
async
function
runTask
()
{
async
function
runTask
()
{
...
...
src/utils/download-typesetting.js
View file @
be92fa13
const
{
ipcMain
,
BrowserWindow
}
=
require
(
"electron"
);
const
{
ipcMain
,
BrowserWindow
}
=
require
(
"electron"
);
const
path
=
require
(
"path"
);
const
path
=
require
(
"path"
);
const
{
getHostApi
}
=
require
(
"@/server/utils/store"
);
const
{
getHostApi
}
=
require
(
"@/server/utils/store"
);
const
{
batchDownloadByStr
}
=
require
(
"./download-core"
);
const
{
batchDownloadByStr
,
batchDownloadByList
}
=
require
(
"./download-core"
);
/* ===================== 原有命名逻辑(完全保留) ===================== */
/* ===================== 原有命名逻辑(完全保留) ===================== */
function
formatTime
()
{
function
formatTime
()
{
...
@@ -67,7 +67,7 @@ function broadcastStatus() {
...
@@ -67,7 +67,7 @@ function broadcastStatus() {
* 提交下载任务(异步执行,立即返回)
* 提交下载任务(异步执行,立即返回)
*/
*/
function
submitTask
(
params
)
{
function
submitTask
(
params
)
{
const
{
urlStr
,
targetPath
,
batchArrangeNum
}
=
params
;
const
{
urlStr
,
targetPath
,
batchArrangeNum
,
extraFiles
=
[]
}
=
params
;
taskState
.
currentBatchNo
=
batchArrangeNum
;
taskState
.
currentBatchNo
=
batchArrangeNum
;
// 全局互斥:有任务在跑直接拒绝
// 全局互斥:有任务在跑直接拒绝
if
(
taskState
.
isRunning
)
{
if
(
taskState
.
isRunning
)
{
...
@@ -89,7 +89,24 @@ function submitTask(params) {
...
@@ -89,7 +89,24 @@ function submitTask(params) {
// 后台异步执行下载,不阻塞 IPC 返回
// 后台异步执行下载,不阻塞 IPC 返回
batchDownloadUrls
(
urlStr
,
targetPath
)
batchDownloadUrls
(
urlStr
,
targetPath
)
.
then
(
result
=>
{
.
then
(
async
result
=>
{
if
(
Array
.
isArray
(
extraFiles
)
&&
extraFiles
.
length
)
{
const
extraResult
=
await
batchDownloadByList
(
extraFiles
,
targetPath
,
{
baseUrl
:
getHostApi
().
fileApiUrl
});
taskState
.
latestResult
=
{
success
:
[
...((
result
&&
result
.
success
)
||
[]),
...((
extraResult
&&
extraResult
.
success
)
||
[])
],
failed
:
[
...((
result
&&
result
.
failed
)
||
[]),
...((
extraResult
&&
extraResult
.
failed
)
||
[])
]
};
return
;
}
taskState
.
latestResult
=
result
;
taskState
.
latestResult
=
result
;
})
})
.
catch
(
err
=>
{
.
catch
(
err
=>
{
...
...
src/views/dtf-batch-detail/components/detailHead.vue
View file @
be92fa13
...
@@ -191,23 +191,44 @@ export default {
...
@@ -191,23 +191,44 @@ export default {
this
.
dialogVisible
=
true
;
this
.
dialogVisible
=
true
;
this
.
radio
=
""
;
this
.
radio
=
""
;
},
},
async
downloadAbnormalMaterials
(
targetDir
)
{
try
{
const
{
data
:
materials
}
=
await
this
.
$api
.
post
(
pathMap
[
"listMaterialsByBatch"
],
{
batchArrangeNum
:
this
.
curBatchArrangeNum
}
);
const
list
=
Array
.
isArray
(
materials
)
?
materials
:
[];
const
extraFiles
=
list
.
filter
(
item
=>
item
&&
item
.
abnormal
)
.
map
(
item
=>
({
url
:
item
.
fileUrl
,
fileName
:
`异常素材
${
item
.
fileName
}
`
}));
if
(
!
extraFiles
.
length
)
return
;
console
.
log
(
`[详情排版] 批次
${
this
.
curBatchArrangeNum
}
异常素材
${
extraFiles
.
length
}
个`
);
const
res
=
await
submitDownload
({
urls
:
extraFiles
,
targetPath
:
targetDir
,
batchArrangeNum
:
this
.
curBatchArrangeNum
});
if
(
res
.
code
!==
200
)
{
console
.
warn
(
"异常素材下载提交失败:"
,
res
.
msg
);
}
}
catch
(
err
)
{
console
.
warn
(
"获取/下载异常素材失败"
,
err
);
}
},
async
submit
()
{
async
submit
()
{
try
{
try
{
if
(
!
this
.
radio
)
{
if
(
!
this
.
radio
)
{
return
this
.
$message
.
error
(
"请选择排版宽度"
);
return
this
.
$message
.
error
(
"请选择排版宽度"
);
}
}
const
payload
=
{
ids
:
this
.
selection
,
type
:
"png"
,
templateWidth
:
this
.
radio
,
targetDir
:
path
.
join
(
getDTFSetting
().
downloadDir
,
`批次号:
${
this
.
curBatchArrangeNum
}
`
,
"手动排版素材"
)
};
if
(
this
.
dtfSetting
.
widthStrategy
==
3
&&
this
.
radio
==
60
)
{
if
(
this
.
dtfSetting
.
widthStrategy
==
3
&&
this
.
radio
==
60
)
{
this
.
$confirm
(
try
{
await
this
.
$confirm
(
"由于排版设置中选择“按更大规格排版”仅适用于40+2,选60时,默认超60的规格不排版"
,
"由于排版设置中选择“按更大规格排版”仅适用于40+2,选60时,默认超60的规格不排版"
,
"提示"
,
"提示"
,
{
{
...
@@ -215,22 +236,31 @@ export default {
...
@@ -215,22 +236,31 @@ export default {
type
:
"warning"
type
:
"warning"
}
}
);
);
const
{
data
}
=
await
this
.
$api
.
post
(
}
catch
{
pathMap
[
"replenishmentComposingDesignImages"
],
return
;
payload
}
);
}
console
.
log
(
"submit"
,
data
);
this
.
$message
.
success
(
"DTF排版成功,请到手动排版素材中查看"
);
const
targetDir
=
path
.
join
(
}
else
{
getDTFSetting
().
downloadDir
,
`批次号:
${
this
.
curBatchArrangeNum
}
`
,
"手动排版素材"
);
const
payload
=
{
ids
:
this
.
selection
,
type
:
"png"
,
templateWidth
:
this
.
radio
,
targetDir
};
const
{
data
}
=
await
this
.
$api
.
post
(
const
{
data
}
=
await
this
.
$api
.
post
(
pathMap
[
"replenishmentComposingDesignImages"
],
pathMap
[
"replenishmentComposingDesignImages"
],
payload
payload
);
);
console
.
log
(
"submit"
,
data
);
console
.
log
(
"submit"
,
data
);
await
this
.
downloadAbnormalMaterials
(
targetDir
);
this
.
$message
.
success
(
"DTF排版成功,请到手动排版素材中查看"
);
this
.
$message
.
success
(
"DTF排版成功,请到手动排版素材中查看"
);
}
this
.
dialogVisible
=
false
;
this
.
dialogVisible
=
false
;
this
.
getDataInfo
();
this
.
getDataInfo
();
}
catch
(
error
)
{
}
catch
(
error
)
{
...
...
src/views/dtf-list/index.vue
View file @
be92fa13
...
@@ -397,15 +397,49 @@ export default {
...
@@ -397,15 +397,49 @@ export default {
{
id
:
task
.
templateId
},
{
id
:
task
.
templateId
},
{
skipLoading
:
true
}
{
skipLoading
:
true
}
);
);
await
submitTypesettingDownload
({
const
targetPath
=
path
.
join
(
urlStr
:
data
.
data
.
spUrl
,
targetPath
:
path
.
join
(
getDTFSetting
().
downloadDir
,
getDTFSetting
().
downloadDir
,
`批次号:
${
task
.
batchArrangeNum
}
`
,
`批次号:
${
task
.
batchArrangeNum
}
`
,
"手动排版素材"
"手动排版素材"
),
);
let
extraFiles
=
[];
try
{
const
{
data
:
materials
}
=
await
this
.
$api
.
post
(
pathMap
[
"listMaterialsByBatch"
],
{
batchArrangeNum
:
task
.
batchArrangeNum
},
{
skipLoading
:
true
}
);
const
list
=
Array
.
isArray
(
materials
)
?
materials
:
[];
extraFiles
=
list
.
filter
(
item
=>
item
&&
item
.
abnormal
)
.
map
(
item
=>
({
url
:
item
.
fileUrl
,
fileName
:
`异常素材
${
item
.
fileName
}
`
}));
console
.
log
(
`[手动排版] 批次
${
task
.
batchArrangeNum
}
异常素材
${
extraFiles
.
length
}
个`
);
}
catch
(
err
)
{
console
.
warn
(
"获取异常素材列表失败,跳过 abnormal 下载"
,
err
);
extraFiles
=
[];
}
await
submitTypesettingDownload
({
urlStr
:
data
.
data
.
spUrl
,
targetPath
,
batchArrangeNum
:
task
.
batchArrangeNum
,
extraFiles
});
if
(
extraFiles
.
length
)
{
const
abnormalRes
=
await
submitDownload
({
urls
:
extraFiles
,
targetPath
,
batchArrangeNum
:
task
.
batchArrangeNum
batchArrangeNum
:
task
.
batchArrangeNum
});
});
if
(
abnormalRes
.
code
!==
200
)
{
console
.
warn
(
"异常素材下载提交失败:"
,
abnormalRes
.
msg
);
}
}
task
.
progress
=
"素材下载中..."
;
task
.
progress
=
"素材下载中..."
;
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
error
);
console
.
error
(
error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment