This commit is contained in:
gyq 2024-06-06 17:44:51 +08:00
parent b6030331ff
commit a1c8757aaf
1 changed files with 17 additions and 17 deletions

View File

@ -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", () => {