更新
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
const path = require("path");
|
||||
const electron = require("electron");
|
||||
const { PosPrinter } = require("electron-pos-printer-vue");
|
||||
let win;
|
||||
electron.app.whenReady().then(() => {
|
||||
win = new electron.BrowserWindow({
|
||||
@@ -19,7 +20,6 @@ electron.app.whenReady().then(() => {
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
win.loadURL(process.env.VITE_DEV_SERVER_URL);
|
||||
win.webContents.openDevTools();
|
||||
} else {
|
||||
win.loadFile(path.resolve(__dirname, "../dist/index.html"));
|
||||
}
|
||||
@@ -32,6 +32,100 @@ electron.app.whenReady().then(() => {
|
||||
electron.app.quit();
|
||||
});
|
||||
electron.ipcMain.on("printStart", (event, arg) => {
|
||||
console.log("开始打印", arg);
|
||||
let name = "Xprinter XP-365B";
|
||||
const options = {
|
||||
silent: true,
|
||||
preview: false,
|
||||
// width of content body
|
||||
margin: "0 0 0 0",
|
||||
// margin of content body
|
||||
copies: 1,
|
||||
// Number of copies to print
|
||||
printerName: name,
|
||||
// printerName: string, check with webContent.getPrinters()
|
||||
// timeOutPerLine: 400,
|
||||
pageSize: { height: 22860, width: 30480 }
|
||||
// page size
|
||||
};
|
||||
const data = [
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table
|
||||
value: "#B5 B6",
|
||||
style: { "font-weight": "700", "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table'
|
||||
value: "喔喔奶茶 x100",
|
||||
style: { "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table'
|
||||
value: "麻辣味",
|
||||
style: { "font-size": "18px" }
|
||||
},
|
||||
{
|
||||
type: "text",
|
||||
// 'text' | 'barCode' | 'qrCode' | 'image' | 'table'
|
||||
value: "03-08 16:32 ¥123.00",
|
||||
style: { "font-size": "18px" }
|
||||
}
|
||||
];
|
||||
PosPrinter.print(data, options).then(() => {
|
||||
}).catch((error) => {
|
||||
console.error(error);
|
||||
});
|
||||
});
|
||||
});
|
||||
electron.app.on("window-all-closed", () => {
|
||||
|
||||
Reference in New Issue
Block a user