Merge branch 'gyq' of https://e.coding.net/g-cphe0354/pczhuomianduan/cashierdesktop into wwz
This commit is contained in:
commit
fae65b2e2a
|
|
@ -1,134 +1 @@
|
||||||
"use strict";
|
"use strict";const p=require("path"),e=require("electron"),{PosPrinter:r}=require("electron-pos-printer-vue");let t;e.app.whenReady().then(()=>{t=new e.BrowserWindow({title:"银收客",width:1024,height:768,fullscreenable:!0,fullscreen:!process.env.VITE_DEV_SERVER_URL,simpleFullscreen:!0,frame:!!process.env.VITE_DEV_SERVER_URL,webPreferences:{nodeIntegration:!0,contextIsolation:!1}}),process.env.VITE_DEV_SERVER_URL?t.loadURL(process.env.VITE_DEV_SERVER_URL):t.loadFile(p.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(i,n)=>{e.app.quit()}),e.ipcMain.on("printStart",(i,n)=>{console.log("开始打印",n);const s={silent:!0,preview:!1,margin:"0 0 0 0",copies:1,printerName:"Xprinter XP-365B",pageSize:{height:22860,width:30480}},o=[{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"#B5 B6",style:{"font-weight":"700","font-size":"18px"}},{type:"text",value:"喔喔奶茶 x100",style:{"font-size":"18px"}},{type:"text",value:"麻辣味",style:{"font-size":"18px"}},{type:"text",value:"03-08 16:32 ¥123.00",style:{"font-size":"18px"}}];r.print(o,s).then(()=>{}).catch(l=>{console.error(l)})})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()});
|
||||||
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({
|
|
||||||
title: "银收客",
|
|
||||||
width: 1024,
|
|
||||||
height: 768,
|
|
||||||
fullscreenable: true,
|
|
||||||
fullscreen: process.env.VITE_DEV_SERVER_URL ? false : true,
|
|
||||||
simpleFullscreen: true,
|
|
||||||
frame: process.env.VITE_DEV_SERVER_URL ? true : false,
|
|
||||||
webPreferences: {
|
|
||||||
// 集成网页和 Node.js,也就是在渲染进程中,可以调用 Node.js 方法
|
|
||||||
nodeIntegration: true,
|
|
||||||
contextIsolation: false
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (process.env.VITE_DEV_SERVER_URL) {
|
|
||||||
win.loadURL(process.env.VITE_DEV_SERVER_URL);
|
|
||||||
} else {
|
|
||||||
win.loadFile(path.resolve(__dirname, "../dist/index.html"));
|
|
||||||
}
|
|
||||||
electron.app.on("activate", () => {
|
|
||||||
if (electron.BrowserWindow.getAllWindows().length === 0) {
|
|
||||||
createWindow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
electron.ipcMain.on("quitHandler", (_, msg) => {
|
|
||||||
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", () => {
|
|
||||||
if (process.platform !== "darwin")
|
|
||||||
electron.app.quit();
|
|
||||||
});
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "vite-electron",
|
"name": "vite-electron",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.0.9",
|
"version": "1.0.12",
|
||||||
"main": "dist-electron/main.js",
|
"main": "dist-electron/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "chcp 65001 && vite",
|
"dev": "chcp 65001 && vite",
|
||||||
|
|
|
||||||
|
|
@ -164,10 +164,9 @@ const menus = ref([
|
||||||
/* 继承父元素的颜色 */
|
/* 继承父元素的颜色 */
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
/* 修改鼠标指针样式 */
|
/* 修改鼠标指针样式 */
|
||||||
|
border: none;
|
||||||
&:first-child {
|
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
||||||
border-bottom: 1px solid #666;
|
-webkit-tap-highlight-color: transparent;
|
||||||
}
|
|
||||||
|
|
||||||
&.online {
|
&.online {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue