From a1c8757aaf56ff125be6f52f67e5a07996bc41d3 Mon Sep 17 00:00:00 2001 From: gyq <875626088@qq.com> Date: Thu, 6 Jun 2024 17:44:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- electron/main.js | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/electron/main.js b/electron/main.js index 7ff6091..7beed3d 100644 --- a/electron/main.js +++ b/electron/main.js @@ -40,11 +40,11 @@ app.whenReady().then(() => { }); // 给渲染进程返回打印机列表 - ipcMain.on('getPrintList', () => { - win.webContents.getPrintersAsync().then(res => { - win.webContents.send('printList', res) - }) - }) + ipcMain.on("getPrintList", () => { + win.webContents.getPrintersAsync().then((res) => { + win.webContents.send("printList", res); + }); + }); // 创建打印小票子窗口 const printWin = new BrowserWindow({ @@ -66,22 +66,22 @@ app.whenReady().then(() => { } // 接收订单页面发过来的参数发送给打印页 - ipcMain.on('printerInfoSync', (event, arg) => { - printWin.webContents.send('getParams', arg) - }) + ipcMain.on("printerInfoSync", (event, arg) => { + printWin.webContents.send("getParams", arg); + }); // 执行打印操作 - ipcMain.on('printStart', (event, arg) => { + ipcMain.on("printStart", (event, arg) => { console.log(arg); - const _parmas = JSON.parse(arg) + const _parmas = JSON.parse(arg); // console.log(_parmas) - let name = _parmas.deviceName + let name = _parmas.deviceName; printWin.webContents.print({ silent: true, deviceName: name, pageSize: { width: 58000, - height: 216000 + height: 216000, }, scaleFactor: 80, landscape: false, @@ -90,14 +90,14 @@ app.whenReady().then(() => { top: 0, bottom: 0, left: 0, - right: 0 + right: 0, }, dpi: { horizontal: 203, - vertical: 203 - } - }) - }) + vertical: 203, + }, + }); + }); }); app.on("window-all-closed", () => {