优化样式
This commit is contained in:
@@ -1,10 +1,5 @@
|
||||
import path from "path";
|
||||
import { app, BrowserWindow, ipcMain } from "electron";
|
||||
const { SerialPort } = require("serialport");
|
||||
|
||||
SerialPort.list().then(res => {
|
||||
console.log(res);
|
||||
});
|
||||
|
||||
let win;
|
||||
app.whenReady().then(() => {
|
||||
@@ -47,7 +42,6 @@ app.whenReady().then(() => {
|
||||
// 创建打印小票子窗口
|
||||
const printWin = new BrowserWindow({
|
||||
show: false,
|
||||
width: 580,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
@@ -62,18 +56,27 @@ app.whenReady().then(() => {
|
||||
printWin.loadFile(path.resolve(__dirname, "../dist/print.html")); // 打包后使用文件路径访问应用
|
||||
}
|
||||
|
||||
// win.webContents.getPrintersAsync().then(res => {
|
||||
// console.log('list', res)
|
||||
// })
|
||||
|
||||
ipcMain.on("printerInfoSync", (event, params) => {
|
||||
// console.log(JSON.parse(params))
|
||||
printWin.webContents.send("getParams", params);
|
||||
});
|
||||
|
||||
// 执行打印操作
|
||||
// ipcMain.on('printStart', () => {
|
||||
// console.log('开始打印')
|
||||
// printWin.webContents.print({
|
||||
// silent: true
|
||||
// })
|
||||
// })
|
||||
ipcMain.on('printStart', () => {
|
||||
console.log('开始打印')
|
||||
|
||||
let name = 'RONGTA 80mm Series Printer'
|
||||
|
||||
// printWin.webContents.print({
|
||||
// silent: true,
|
||||
// printBackground: true,
|
||||
// deviceName: name
|
||||
// })
|
||||
})
|
||||
});
|
||||
|
||||
app.on("window-all-closed", () => {
|
||||
|
||||
Reference in New Issue
Block a user