优化新增串口

This commit is contained in:
gyq
2024-03-07 18:29:19 +08:00
parent fc810fd02f
commit 58993e00ee
9 changed files with 186 additions and 188 deletions

View File

@@ -1,8 +1,13 @@
"use strict";
const electron = require("electron");
const path = require("path");
const electron = require("electron");
const { SerialPort } = require("serialport");
SerialPort.list().then((res) => {
console.log(res);
});
let win;
electron.app.whenReady().then(() => {
const win = new electron.BrowserWindow({
win = new electron.BrowserWindow({
title: "银收客",
width: 1024,
height: 768,
@@ -46,15 +51,6 @@ electron.app.whenReady().then(() => {
electron.ipcMain.on("printerInfoSync", (event, params) => {
printWin.webContents.send("getParams", params);
});
electron.ipcMain.on("printStart", () => {
printWin.webContents.printToPDF({}, (error, data) => {
if (!error && data) {
console.log("成功生成PDF");
} else {
console.error("无法生成PDF", error);
}
});
});
});
electron.app.on("window-all-closed", () => {
if (process.platform !== "darwin")