新增添加网口打印机

This commit is contained in:
gyq
2026-03-28 08:56:00 +08:00
parent 33be9f2cef
commit 5fab9a857a
10 changed files with 11330 additions and 1197 deletions

View File

@@ -5,6 +5,7 @@ import axios from "axios";
import os from "os";
import fs from "fs";
import { exec } from "child_process";
import { printReceipt } from "./printService";
// ===== 核心配置:单文件缓存 =====
// 固定的缓存文件路径永远只存这1个文件
@@ -106,6 +107,19 @@ app.whenReady().then(() => {
});
});
ipcMain.on('networkPrint', async (event, arg) => {
try {
let _parmas = JSON.parse(arg);
console.log(_parmas);
console.log(_parmas.orderData.carts);
await printReceipt(_parmas.printerIp, _parmas.orderData);
return { ok: true }
} catch (e) {
console.log(e);
return { ok: false, msg: e.message }
}
})
app.on("activate", () => {
// 在 macOS 系统内, 如果没有已开启的应用窗口
// 点击托盘图标时通常会重新创建一个新窗口