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', () => { ipcMain.on("getPrintList", () => {
win.webContents.getPrintersAsync().then(res => { win.webContents.getPrintersAsync().then((res) => {
win.webContents.send('printList', res) win.webContents.send("printList", res);
}) });
}) });
// 创建打印小票子窗口 // 创建打印小票子窗口
const printWin = new BrowserWindow({ const printWin = new BrowserWindow({
@ -66,22 +66,22 @@ app.whenReady().then(() => {
} }
// 接收订单页面发过来的参数发送给打印页 // 接收订单页面发过来的参数发送给打印页
ipcMain.on('printerInfoSync', (event, arg) => { ipcMain.on("printerInfoSync", (event, arg) => {
printWin.webContents.send('getParams', arg) printWin.webContents.send("getParams", arg);
}) });
// 执行打印操作 // 执行打印操作
ipcMain.on('printStart', (event, arg) => { ipcMain.on("printStart", (event, arg) => {
console.log(arg); console.log(arg);
const _parmas = JSON.parse(arg) const _parmas = JSON.parse(arg);
// console.log(_parmas) // console.log(_parmas)
let name = _parmas.deviceName let name = _parmas.deviceName;
printWin.webContents.print({ printWin.webContents.print({
silent: true, silent: true,
deviceName: name, deviceName: name,
pageSize: { pageSize: {
width: 58000, width: 58000,
height: 216000 height: 216000,
}, },
scaleFactor: 80, scaleFactor: 80,
landscape: false, landscape: false,
@ -90,14 +90,14 @@ app.whenReady().then(() => {
top: 0, top: 0,
bottom: 0, bottom: 0,
left: 0, left: 0,
right: 0 right: 0,
}, },
dpi: { dpi: {
horizontal: 203, horizontal: 203,
vertical: 203 vertical: 203,
} },
}) });
}) });
}); });
app.on("window-all-closed", () => { app.on("window-all-closed", () => {