优化各项
This commit is contained in:
parent
e00feb82ec
commit
38366601d4
|
|
@ -2,16 +2,16 @@
|
|||
ENV = production
|
||||
|
||||
# 正式ws
|
||||
# VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
||||
VITE_API_WSS = 'wss://cashier.sxczgkj.cn/client'
|
||||
|
||||
#测试ws
|
||||
VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client'
|
||||
# VITE_API_WSS = 'wss://wxcashiertest.sxczgkj.cn/client'
|
||||
|
||||
# 测试 php
|
||||
VITE_API_PHP_URL = 'http://192.168.2.33:1666/index.php/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 @@
|
|||
"use strict";const o=require("path"),e=require("electron"),p=require("os");let i;e.app.whenReady().then(()=>{i=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?i.loadURL(process.env.VITE_DEV_SERVER_URL):i.loadFile(o.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(n,t)=>{e.app.quit()}),e.ipcMain.on("getPrintList",()=>{i.webContents.getPrintersAsync().then(n=>{i.webContents.send("printList",n)})}),e.ipcMain.on("getOSmacSync",()=>{let n="";p.networkInterfaces().WLAN?(n=p.networkInterfaces().WLAN[0].mac,console.log("wlan.mac===",n)):(n=p.networkInterfaces().以太网[0].mac,console.log("以太网.mac===",n)),i.webContents.send("getOSmacRes",n)});const a=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?a.loadFile(o.join(__dirname,"../public/print.html")):a.loadFile(o.resolve(__dirname,"../dist/print.html")),e.ipcMain.on("printerInfoSync",(n,t)=>{a.webContents.send("getParams",t)}),e.ipcMain.on("printStart",(n,t)=>{console.log(t);let r=JSON.parse(t).deviceName;a.webContents.print({silent:!0,deviceName:r,pageSize:{width:58e3,height:216e3},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})});const s=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?s.loadFile(o.join(__dirname,"../public/work_print.html")):s.loadFile(o.resolve(__dirname,"../dist/work_print.html")),e.ipcMain.on("printerWorkSync",(n,t)=>{s.webContents.send("getParams",t)}),e.ipcMain.on("printWorkStart",(n,t)=>{let r=JSON.parse(t).deviceName;s.webContents.print({silent:!0,deviceName:r,pageSize:{width:58e3,height:216e3},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})});const l=new e.BrowserWindow({show:!1,width:360,height:240,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?l.loadFile(o.join(__dirname,"../public/tag_print.html")):l.loadFile(o.resolve(__dirname,"../dist/tag_print.html")),e.ipcMain.on("printerTagSync",(n,t)=>{console.log(t),l.webContents.send("getParams",t)}),e.ipcMain.on("printTagStart",(n,t)=>{let r=JSON.parse(t).deviceName;l.webContents.print({silent:!0,deviceName:r,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",(n,t,c)=>{i&&(i.isMinimized()&&i.restore(),i.focus(),i.show())}):e.app.quit()});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()});
|
||||
"use strict";const o=require("path"),e=require("electron"),p=require("os");let i;e.app.whenReady().then(()=>{i=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?i.loadURL(process.env.VITE_DEV_SERVER_URL):i.loadFile(o.resolve(__dirname,"../dist/index.html")),e.app.on("activate",()=>{e.BrowserWindow.getAllWindows().length===0&&createWindow()}),e.ipcMain.on("quitHandler",(n,t)=>{i=null,e.app.exit()}),e.ipcMain.on("getPrintList",()=>{i.webContents.getPrintersAsync().then(n=>{i.webContents.send("printList",n)})}),e.ipcMain.on("getOSmacSync",()=>{let n="";p.networkInterfaces().WLAN?(n=p.networkInterfaces().WLAN[0].mac,console.log("wlan.mac===",n)):(n=p.networkInterfaces().以太网[0].mac,console.log("以太网.mac===",n)),i.webContents.send("getOSmacRes",n)});const r=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?r.loadFile(o.join(__dirname,"../public/print.html")):r.loadFile(o.resolve(__dirname,"../dist/print.html")),e.ipcMain.on("printerInfoSync",(n,t)=>{r.webContents.send("getParams",t)}),e.ipcMain.on("printStart",(n,t)=>{console.log(t);let a=JSON.parse(t).deviceName;r.webContents.print({silent:!0,deviceName:a,pageSize:{width:58e3,height:216e3},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})});const s=new e.BrowserWindow({show:!1,width:464,height:1726,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?s.loadFile(o.join(__dirname,"../public/work_print.html")):s.loadFile(o.resolve(__dirname,"../dist/work_print.html")),e.ipcMain.on("printerWorkSync",(n,t)=>{s.webContents.send("getParams",t)}),e.ipcMain.on("printWorkStart",(n,t)=>{let a=JSON.parse(t).deviceName;s.webContents.print({silent:!0,deviceName:a,pageSize:{width:58e3,height:216e3},scaleFactor:80,landscape:!1,margins:{marginType:"none",top:0,bottom:0,left:0,right:0},dpi:{horizontal:203,vertical:203}})});const l=new e.BrowserWindow({show:!1,width:360,height:240,webPreferences:{nodeIntegration:!0,contextIsolation:!1}});process.env.VITE_DEV_SERVER_URL?l.loadFile(o.join(__dirname,"../public/tag_print.html")):l.loadFile(o.resolve(__dirname,"../dist/tag_print.html")),e.ipcMain.on("printerTagSync",(n,t)=>{console.log(t),l.webContents.send("getParams",t)}),e.ipcMain.on("printTagStart",(n,t)=>{let a=JSON.parse(t).deviceName;l.webContents.print({silent:!0,deviceName:a,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",(n,t,c)=>{i&&(i.isMinimized()&&i.restore(),i.focus(),i.show())}):e.app.quit(),i.on("close",n=>{n.preventDefault(),i.webContents.send("showCloseDialog")})});e.app.on("window-all-closed",()=>{process.platform!=="darwin"&&e.app.quit()});
|
||||
|
|
|
|||
|
|
@ -38,7 +38,8 @@ app.whenReady().then(() => {
|
|||
});
|
||||
|
||||
ipcMain.on("quitHandler", (_, msg) => {
|
||||
app.quit();
|
||||
win = null;
|
||||
app.exit();
|
||||
});
|
||||
|
||||
// 给渲染进程返回打印机列表
|
||||
|
|
@ -242,6 +243,12 @@ app.whenReady().then(() => {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 阻止默认关闭
|
||||
win.on("close", (e) => {
|
||||
e.preventDefault();
|
||||
win.webContents.send("showCloseDialog");
|
||||
});
|
||||
});
|
||||
app.on("window-all-closed", () => {
|
||||
if (process.platform !== "darwin") app.quit();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "vite-electron",
|
||||
"private": true,
|
||||
"version": "1.3.54",
|
||||
"version": "1.3.56",
|
||||
"main": "dist-electron/main.js",
|
||||
"scripts": {
|
||||
"dev": "chcp 65001 && vite",
|
||||
|
|
@ -19,6 +19,7 @@
|
|||
"js-md5": "^0.8.3",
|
||||
"lodash": "^4.17.21",
|
||||
"pinia": "^2.1.7",
|
||||
"pinia-plugin-persistedstate": "^3.2.1",
|
||||
"qrcode": "^1.5.3",
|
||||
"reconnecting-websocket": "^4.4.0",
|
||||
"serialport": "^12.0.0",
|
||||
|
|
|
|||
14
src/App.vue
14
src/App.vue
|
|
@ -28,10 +28,11 @@ import { useRouter, useRoute } from "vue-router";
|
|||
import leftMenu from "@/components/leftMenu.vue";
|
||||
import useStorage from "@/utils/useStorage";
|
||||
import { useUser } from "@/store/user.js";
|
||||
import { dayjs, ElMessage } from "element-plus";
|
||||
import { dayjs, ElMessage, ElMessageBox } from "element-plus";
|
||||
import { scanSendMessage } from "@/api/order/index";
|
||||
import { useGlobal } from "@/store/global.js";
|
||||
import { useSocket } from "@/store/socket.js";
|
||||
import { ipcRenderer } from 'electron';
|
||||
const socket = useSocket();
|
||||
|
||||
const global = useGlobal();
|
||||
|
|
@ -191,6 +192,17 @@ onMounted(() => {
|
|||
socket.init();
|
||||
}
|
||||
|
||||
ipcRenderer.on('showCloseDialog', (event, arg) => {
|
||||
console.log('阻止系统关闭软件');
|
||||
ElMessageBox.confirm("确定要关闭软件吗?")
|
||||
.then(() => {
|
||||
ipcRenderer.send("quitHandler", "退出吧");
|
||||
})
|
||||
.catch(() => { });
|
||||
})
|
||||
|
||||
// listnerCloseDialog()
|
||||
|
||||
// // 监听网络在线状态
|
||||
// window.addEventListener("onLine", updateInfo)
|
||||
// // 监听网络离线
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ async function passwordSuccess(e) {
|
|||
shopId: store.userInfo.shopId,
|
||||
memberId: props.userInfo.id,
|
||||
amount: money.value,
|
||||
// pwd: md5(e),
|
||||
pwd: md5(e),
|
||||
});
|
||||
payLoading.value = false;
|
||||
ElMessage.success("支付成功");
|
||||
|
|
@ -175,8 +175,8 @@ async function confirmOrder() {
|
|||
emit("paySuccess");
|
||||
} else {
|
||||
// 会员充值
|
||||
// takeFoodCodeRef.value.show();
|
||||
passwordSuccess()
|
||||
takeFoodCodeRef.value.show();
|
||||
// passwordSuccess()
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import ReconnectingWebSocket from "reconnecting-websocket";
|
|||
import { ipcRenderer } from "electron";
|
||||
|
||||
export const useSocket = defineStore({
|
||||
id: "socket",
|
||||
id: uuidv4(),
|
||||
state: () => ({
|
||||
online: false, // 在线状态
|
||||
ws: null, // websocket实例
|
||||
|
|
@ -33,7 +33,7 @@ export const useSocket = defineStore({
|
|||
close() {
|
||||
console.log("关闭ws");
|
||||
this.ws.close(1000);
|
||||
// this.ws = null;
|
||||
this.ws = null;
|
||||
this.clearHeartBeat();
|
||||
},
|
||||
wsReconnect: _.throttle(
|
||||
|
|
@ -48,7 +48,6 @@ export const useSocket = defineStore({
|
|||
// 初始化
|
||||
init(wsUrl = import.meta.env.VITE_API_WSS) {
|
||||
this.createUUID();
|
||||
|
||||
const store = useUser();
|
||||
const printStore = usePrint();
|
||||
|
||||
|
|
@ -67,6 +66,9 @@ export const useSocket = defineStore({
|
|||
this.online = true;
|
||||
// 清除心跳
|
||||
this.clearHeartBeat();
|
||||
|
||||
console.log(this);
|
||||
|
||||
this.ws.send(
|
||||
JSON.stringify({
|
||||
type: "connect",
|
||||
|
|
|
|||
Loading…
Reference in New Issue