Browse Source

ChatPanel-2-2025-7-17

CaoGQ123 3 days ago
parent
commit
bf6af3ddca
1 changed files with 11 additions and 2 deletions
  1. 11 2
      src/layout/components/Chat/ChatPanel.vue

+ 11 - 2
src/layout/components/Chat/ChatPanel.vue

@@ -1278,6 +1278,7 @@
     name: "ChatPanel",
     data() {
       return {
+        token:'',
         ones:0,
         messageContent:{},
         avatar:this.$store.state.user.avatar,
@@ -3076,7 +3077,7 @@
       console.log("用户头像信息:",this.$store.state.user.avatar)
       //开启websocket连接 start---------------------------------------->
       //1.获取admin-token
-      const adminToken = document.cookie.split('; ').find(row => row.startsWith('Admin-Token=')).split('=')[1];
+      const adminToken = this.token;
       console.log("Admin-Token:", adminToken);
   
       //2.连接websocket 
@@ -3187,7 +3188,15 @@
           console.log('user_id 变化了:', newVal);
           // 你的逻辑...
         }
-      }
+      },
+      '$store.state.user.token': {  
+        handler(newValue, oldValue) {  
+          this.token = newValue
+        },  
+        immediate: true, 
+      } 
+
+
     }
   };
   </script>