This commit is contained in:
parent
ac469cbc32
commit
efb7dd3e57
|
|
@ -2,10 +2,10 @@
|
|||
ENV = test
|
||||
|
||||
#测试ws
|
||||
# VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client'
|
||||
VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client'
|
||||
|
||||
# 正式ws
|
||||
VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
||||
# VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
||||
|
||||
# 正式 php
|
||||
VITE_API_PHP_URL = 'https://czgdoumei.sxczgkj.com/index.php/api'
|
||||
|
|
@ -17,7 +17,7 @@ VITE_API_PHP_URL = 'https://czgdoumei.sxczgkj.com/index.php/api'
|
|||
VITE_API_KP_URL = 'https://invoice.sxczgkj.cn/api'
|
||||
|
||||
# 测试
|
||||
# VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
|
||||
VITE_API_URL = 'https://cashier-client.sxczgkj.cn/cashier-client'
|
||||
|
||||
# 正式
|
||||
VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
|
||||
# VITE_API_URL = 'https://cashierclient.sxczgkj.cn/cashier-client'
|
||||
|
|
@ -1 +1,115 @@
|
|||
"use strict";const s=require("path"),e=require("electron"),a=require("os");let n;e.app.whenReady().then(()=>{n=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?n.loadURL(process.env.VITE_DEV_SERVER_URL):n.loadFile(s.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(t,o)=>{n=null,e.app.exit()}),e.ipcMain.on("getPrintList",()=>{n.webContents.getPrintersAsync().then(t=>{n.webContents.send("printList",t)})}),e.ipcMain.on("getOSmacSync",()=>{let t="";a.networkInterfaces().WLAN?(t=a.networkInterfaces().WLAN[0].mac,console.log("wlan.mac===",t)):(t=a.networkInterfaces().以太网[0].mac,console.log("以太网.mac===",t)),n.webContents.send("getOSmacRes",t)});const i=new e.BrowserWindow({show:!1,width:360,height:240,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?i.loadFile(s.join(__dirname,"../public/tag_print.html")):i.loadFile(s.resolve(__dirname,"../dist/tag_print.html")),e.ipcMain.on("printerTagSync",(t,o)=>{console.log(o),i.webContents.send("getParams",o)}),e.ipcMain.on("printTagStart",(t,o)=>{let l=JSON.parse(o).deviceName;i.webContents.print({silent:!0,deviceName:l,pageSize:{width:45e3,height:3e4},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})}),e.app.requestSingleInstanceLock()?e.app.on("second-instance",(t,o,r)=>{n&&(n.isMinimized()&&n.restore(),n.focus(),n.show())}):e.app.quit(),n.on("close",t=>{t.preventDefault(),n.webContents.send("showCloseDialog")})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()});
|
||||
"use strict";
|
||||
const path = require("path");
|
||||
const electron = require("electron");
|
||||
const os = require("os");
|
||||
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) => {
|
||||
win = null;
|
||||
electron.app.exit();
|
||||
});
|
||||
electron.ipcMain.on("getPrintList", () => {
|
||||
win.webContents.getPrintersAsync().then((res) => {
|
||||
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 tagPrintWin = new electron.BrowserWindow({
|
||||
show: false,
|
||||
width: 360,
|
||||
height: 240,
|
||||
webPreferences: {
|
||||
nodeIntegration: true,
|
||||
contextIsolation: false
|
||||
}
|
||||
});
|
||||
if (process.env.VITE_DEV_SERVER_URL) {
|
||||
tagPrintWin.loadFile(path.join(__dirname, "../public/tag_print.html"));
|
||||
} else {
|
||||
tagPrintWin.loadFile(path.resolve(__dirname, "../dist/tag_print.html"));
|
||||
}
|
||||
electron.ipcMain.on("printerTagSync", (event, arg) => {
|
||||
console.log(arg);
|
||||
tagPrintWin.webContents.send("getParams", arg);
|
||||
});
|
||||
electron.ipcMain.on("printTagStart", (event, arg) => {
|
||||
const _parmas = JSON.parse(arg);
|
||||
let name = _parmas.deviceName;
|
||||
tagPrintWin.webContents.print({
|
||||
silent: true,
|
||||
deviceName: name,
|
||||
pageSize: {
|
||||
width: 45e3,
|
||||
height: 3e4
|
||||
},
|
||||
scaleFactor: 80,
|
||||
landscape: false,
|
||||
margins: {
|
||||
marginType: "none",
|
||||
top: 0,
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
right: 0
|
||||
},
|
||||
dpi: {
|
||||
horizontal: 203,
|
||||
vertical: 203
|
||||
}
|
||||
});
|
||||
});
|
||||
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();
|
||||
}
|
||||
});
|
||||
}
|
||||
win.on("close", (e) => {
|
||||
e.preventDefault();
|
||||
win.webContents.send("showCloseDialog");
|
||||
});
|
||||
});
|
||||
electron.app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin")
|
||||
electron.app.quit();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "1.4.12",
|
||||
"version": "1.4.13",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
|
|
|
|||
|
|
@ -165,13 +165,14 @@ const isPrint = ref(true)
|
|||
// 开始交班
|
||||
const exit = async () => {
|
||||
try {
|
||||
let data = {}
|
||||
// 获取交班打印小票数据
|
||||
data = await handoverData({
|
||||
id: infoData.value.id
|
||||
})
|
||||
|
||||
if (printStore.deviceNoteList.length) {
|
||||
loading.value = true;
|
||||
let data = {}
|
||||
// 获取交班打印小票数据
|
||||
data = await handoverData({
|
||||
id: infoData.value.id
|
||||
})
|
||||
|
||||
data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
data.printShop = isPrint.value
|
||||
|
|
@ -194,46 +195,6 @@ const exit = async () => {
|
|||
});
|
||||
}, 1000);
|
||||
loading.value = false;
|
||||
// console.log('本地打印');
|
||||
// if (!checkLocalPrint(printList.value[0].config.deviceName)) {
|
||||
// loading.value = true;
|
||||
// let res = await loginlogout({
|
||||
// status: 1
|
||||
// })
|
||||
// // useStorage.clear()
|
||||
// useStorage.del('userInfo')
|
||||
// useStorage.del('token')
|
||||
// useStorage.del('douyin')
|
||||
// useStorage.del('categorysActive')
|
||||
// ElMessage.success("交班成功");
|
||||
// setTimeout(() => {
|
||||
// router.replace({
|
||||
// name: "login",
|
||||
// });
|
||||
// }, 1000);
|
||||
// loading.value = false;
|
||||
// } else {
|
||||
// // 获取交班打印小票数据
|
||||
// const data = await handoverData({
|
||||
// id: infoData.value.id
|
||||
// })
|
||||
// data.deviceName = printList.value[0].config.deviceName
|
||||
// data.printTime = dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
// ipcRenderer.send("printerWorkSync", JSON.stringify(data));
|
||||
// // return
|
||||
// // useStorage.clear()
|
||||
// useStorage.del('userInfo')
|
||||
// useStorage.del('token')
|
||||
// useStorage.del('douyin')
|
||||
// useStorage.del('categorysActive')
|
||||
// ElMessage.success("交班成功");
|
||||
// setTimeout(() => {
|
||||
// router.replace({
|
||||
// name: "login",
|
||||
// });
|
||||
// }, 1000);
|
||||
// loading.value = false;
|
||||
// }
|
||||
} else {
|
||||
console.log('云打印交班数据');
|
||||
loading.value = true;
|
||||
|
|
|
|||
Loading…
Reference in New Issue