优化
This commit is contained in:
@@ -22,7 +22,7 @@ app.whenReady().then(() => {
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
win.loadURL(process.env.VITE_DEV_SERVER_URL);
|
||||
// 使用vite开发服务的url路径访问应用
|
||||
// win.webContents.openDevTools();
|
||||
win.webContents.openDevTools();
|
||||
} else {
|
||||
win.loadFile(path.resolve(__dirname, "../dist/index.html")); // 打包后使用文件路径访问应用
|
||||
}
|
||||
@@ -40,36 +40,37 @@ app.whenReady().then(() => {
|
||||
});
|
||||
|
||||
// 创建打印小票子窗口
|
||||
const printWin = new BrowserWindow({
|
||||
show: false,
|
||||
webPreferences: {
|
||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false,
|
||||
},
|
||||
});
|
||||
// const printWin = new BrowserWindow({
|
||||
// show: false,
|
||||
// webPreferences: {
|
||||
// // 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
||||
// nodeIntegration: true,
|
||||
// contextIsolation: false,
|
||||
// },
|
||||
// });
|
||||
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
// 加载打印的html文件
|
||||
printWin.loadFile(path.join(__dirname, "../public/print.html"));
|
||||
} else {
|
||||
printWin.loadFile(path.resolve(__dirname, "../dist/print.html")); // 打包后使用文件路径访问应用
|
||||
}
|
||||
// if (process.env.VITE_DEV_SERVER_URL) {
|
||||
// // 加载打印的html文件
|
||||
// printWin.loadFile(path.join(__dirname, "../public/print.html"));
|
||||
// } else {
|
||||
// printWin.loadFile(path.resolve(__dirname, "../dist/print.html")); // 打包后使用文件路径访问应用
|
||||
// }
|
||||
|
||||
// win.webContents.getPrintersAsync().then(res => {
|
||||
// console.log('list', res)
|
||||
// // console.log('list', res)
|
||||
// })
|
||||
|
||||
ipcMain.on("printerInfoSync", (event, params) => {
|
||||
// console.log(JSON.parse(params))
|
||||
printWin.webContents.send("getParams", params);
|
||||
});
|
||||
// ipcMain.on("printerInfoSync", (event, params) => {
|
||||
// // console.log(JSON.parse(params))
|
||||
// printWin.webContents.send("getParams", params);
|
||||
// });
|
||||
|
||||
// 执行打印操作
|
||||
ipcMain.on('printStart', () => {
|
||||
console.log('开始打印')
|
||||
ipcMain.on('printStart', (event, arg) => {
|
||||
// console.log('开始打印', arg)
|
||||
|
||||
let name = 'RONGTA 80mm Series Printer'
|
||||
// let name = 'Xprinter XP-365B'
|
||||
// // let name = 'Generic / Text Only'
|
||||
|
||||
// printWin.webContents.print({
|
||||
// silent: true,
|
||||
|
||||
Reference in New Issue
Block a user