Ver Fonte

Merge branch 'dev' of http://1.94.207.143:3000/xyy/xyy-web into dev

songzhen há 1 mês atrás
pai
commit
9cfd76b594
2 ficheiros alterados com 16 adições e 16 exclusões
  1. 11 11
      src/plugins/websocket.js
  2. 5 5
      src/stores/chat.js

+ 11 - 11
src/plugins/websocket.js

@@ -3,18 +3,18 @@
 import {useChatStore} from '@/stores/chat'
 
 export default defineNuxtPlugin((nuxtApp) => {
-    const chatStore = useChatStore()
-    chatStore.messages = '嘿嘿嘿'
-    const { messages } = storeToRefs(chatStore)
-    const uuid = new Date().getTime()
-    const socket = new WebSocket('ws://192.168.1.43:8080?uuid=' + uuid)
-    socket.onopen = function (e) {
+    // const chatStore = useChatStore()
+    // chatStore.messages = '嘿嘿嘿'
+    // const { messages } = storeToRefs(chatStore)
+    // const uuid = new Date().getTime()
+    // const socket = new WebSocket('ws://192.168.1.43:8080?uuid=' + uuid)
+    // socket.onopen = function (e) {
         
-    }
-    socket.onmessage = function (e) {
+    // }
+    // socket.onmessage = function (e) {
         
-    }
-    nuxtApp.provide('socket', socket)
-    nuxtApp.provide('messages', messages)
+    // }
+    // nuxtApp.provide('socket', socket)
+    // nuxtApp.provide('messages', messages)
     
 })

+ 5 - 5
src/stores/chat.js

@@ -22,11 +22,11 @@ export const useChatStore = defineStore('chat', () => {
     // 创建webboteSocket连接
     const ws = ref(null)
     function createConnection(token) {
-        if(!process.client){
-            console.log('非浏览器环境不支持websocket')
-            reject('仅在客户端可连接')
-            return
-        }
+        // if(!process.client){
+        //     console.log('非浏览器环境不支持websocket')
+        //     reject('仅在客户端可连接')
+        //     return
+        // }
         return new Promise((resolve, reject) => {
             if (connectSta.value == 2) {
                 console.log('连接已存在,请不要重复连接')