This commit is contained in:
gyq
2024-07-12 16:36:28 +08:00
parent bb554a28d2
commit 8c1e1d3fbc
12 changed files with 304 additions and 342 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
const path = require("path");
const electron = require("electron");
const os = require("os");
let win;
electron.app.whenReady().then(() => {
win = new electron.BrowserWindow({
@@ -35,6 +36,17 @@ electron.app.whenReady().then(() => {
win.webContents.send("printList", res);
});
});
electron.ipcMain.on("getOSmacSync", () => {
let mac = "";
if (os.networkInterfaces().WLAN) {
mac = os.networkInterfaces().WLAN[0].mac;
console.log("wlan.mac===", mac);
} else {
mac = os.networkInterfaces()["以太网"][0].mac;
console.log("以太网.mac===", mac);
}
win.webContents.send("getOSmacRes", mac);
});
const printWin = new electron.BrowserWindow({
show: false,
width: 464,
@@ -123,7 +135,7 @@ electron.app.whenReady().then(() => {
});
const tagPrintWin = new electron.BrowserWindow({
show: false,
width: 320,
width: 360,
height: 240,
webPreferences: {
nodeIntegration: true,
@@ -146,7 +158,7 @@ electron.app.whenReady().then(() => {
silent: true,
deviceName: name,
pageSize: {
width: 4e4,
width: 45e3,
height: 3e4
},
scaleFactor: 80,
@@ -164,6 +176,19 @@ electron.app.whenReady().then(() => {
}
});
});
const gotTheLock = electron.app.requestSingleInstanceLock();
if (!gotTheLock) {
electron.app.quit();
} else {
electron.app.on("second-instance", (event, commandLine, workingDirectory) => {
if (win) {
if (win.isMinimized())
win.restore();
win.focus();
win.show();
}
});
}
});
electron.app.on("window-all-closed", () => {
if (process.platform !== "darwin")