优化各项

This commit is contained in:
gyq
2024-07-15 09:46:40 +08:00
parent e00feb82ec
commit 38366601d4
7 changed files with 36 additions and 14 deletions

View File

@@ -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)
// // 监听网络离线

View File

@@ -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:

View File

@@ -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",