优化各项
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user