Skip to content

Commit

Permalink
fix 打印回调问题
Browse files Browse the repository at this point in the history
  • Loading branch information
CcSimple committed Dec 7, 2023
1 parent 3c48e03 commit f3b2ef8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "electron-hiprint",
"version": "1.0.8",
"version": "1.0.9",
"description": "vue-plugin-hiprint client",
"main": "main.js",
"author": "CcSimple<[email protected]>",
Expand Down
46 changes: 28 additions & 18 deletions src/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,15 @@ function initPrintEvent() {
fs.writeFileSync(pdfPath, pdfData);
printPdf(pdfPath, deviceName, data)
.then(() => {
socket &&
socket.emit("success", {
if (socket) {
const result = {
msg: "打印成功",
templateId: data.templateId,
replyId: data.replyId
});
};
socket.emit("successs", result); // 兼容 vue-plugin-hiprint 0.0.56 之前包
socket.emit("success", result);
}
})
.catch((err) => {
socket &&
Expand Down Expand Up @@ -152,12 +155,15 @@ function initPrintEvent() {
if (isUrlPdf) {
printPdf(data.pdf_path, deviceName, data)
.then(() => {
socket &&
socket.emit("success", {
if (socket) {
const result = {
msg: "打印成功",
templateId: data.templateId,
replyId: data.replyId
});
replyId: data.replyId,
};
socket.emit("successs", result); // 兼容 vue-plugin-hiprint 0.0.56 之前包
socket.emit("success", result);
}
})
.catch((err) => {
socket &&
Expand Down Expand Up @@ -204,17 +210,21 @@ function initPrintEvent() {
},
(success, failureReason) => {
if (socket) {
success
? socket.emit("success", {
msg: "打印成功",
templateId: data.templateId,
replyId: data.replyId
})
: socket.emit("error", {
msg: failureReason,
templateId: data.templateId,
replyId: data.replyId
});
if (success) {
const result = {
msg: "打印成功",
templateId: data.templateId,
replyId: data.replyId,
};
socket.emit("successs", result); // 兼容 vue-plugin-hiprint 0.0.56 之前包
socket.emit("success", result);
} else {
socket.emit("error", {
msg: failureReason,
templateId: data.templateId,
replyId: data.replyId,
});
}
}
// 通过 taskMap 调用 task done 回调
PRINT_RUNNER_DONE[data.taskId]();
Expand Down

0 comments on commit f3b2ef8

Please sign in to comment.