Selaa lähdekoodia

fix:修改消息通知长链接

贾宇博 1 kuukausi sitten
vanhempi
commit
7da3d3637d
3 muutettua tiedostoa jossa 26 lisäystä ja 5 poistoa
  1. 3 3
      src/store/modules/sidebar.js
  2. 21 0
      src/views/login.vue
  3. 2 2
      vite.config.js

+ 3 - 3
src/store/modules/sidebar.js

@@ -15,9 +15,9 @@ const useSidebarStore = defineStore(
       actions: {
         getOnList(badgeObj) {
           MessaGeUnreadMessageCount().then(res=>{
-            if(res.code == 200){
-              this.badgeObj.xxtzGqxxtzNum = res.data;
-            }
+            // if(res.code == 200){
+            //   this.badgeObj.xxtzGqxxtzNum = res.data;
+            // }
           })
         }
       }

+ 21 - 0
src/views/login.vue

@@ -107,6 +107,27 @@ function handleLogin() {
           return acc;
         }, {});
         router.push({ path: redirect.value || "/", query: otherQueryParams });
+
+        // 建立 WebSocket 连接
+        const ws = new WebSocket("ws://192.168.100.119:8080/websocket");
+          
+        ws.onopen = () => { // 连接建立后执行
+          console.log("WebSocket connection established");
+        };
+
+        ws.onmessage = (event) => {
+          const { data } = event;
+          console.log(data, '>>>>>>>event长连接data')
+        }
+
+        ws.onerror = (error) => {
+          console.error("WebSocket error:", error);
+        };
+
+        ws.onclose = () => {
+          console.log("WebSocket connection closed");
+        };
+	      
       }).catch(() => {
         loading.value = false;
         // 重新获取验证码

+ 2 - 2
vite.config.js

@@ -33,8 +33,8 @@ export default defineConfig(({ mode, command }) => {
         '/dev-api': { // 代理后缀
           // target: 'http://192.168.100.84:8080',
           // target: 'http://1.95.212.35:8080',
-          // target: 'http://192.168.100.103:8080', // 王文龙代理地址
-          target: 'http://192.168.100.145:8080', // 李荣代理地址
+          target: 'http://192.168.100.119:8080', // 王文龙代理地址
+          // target: 'http://192.168.100.145:8080', // 李荣代理地址
           // target: 'https://api.wzs.pub/mock/13',
           changeOrigin: true,
           rewrite: (p) => p.replace(/^\/dev-api/, '')