Ver Fonte

:bug: 增加token传递

396264893 há 6 anos atrás
pai
commit
65ce7d6b7a
1 ficheiros alterados com 4 adições e 7 exclusões
  1. 4 7
      src/page/index/index.vue

+ 4 - 7
src/page/index/index.vue

@@ -42,7 +42,7 @@
   import {getStore} from '@/util/store.js';
   import SockJS from 'sockjs-client';
   import Stomp from 'stompjs';
-
+  import store from "@/store";
   export default {
     components: {
       top,
@@ -125,17 +125,14 @@
         }, 5000);
       },
       connection() {
-        // const token = getStore({
-        //   name: 'access_token',
-        //   debug: true,
-        // });
+        let token =  store.getters.access_token
         const TENANT_ID = getStore({name: 'tenantId'})
         // 建立连接对象
         this.socket = new SockJS('http://localhost:9999/auth/ws');//连接服务端提供的通信接口,连接以后才可以订阅广播消息和个人消息
         // 获取STOMP子协议的客户端对象
         this.stompClient = Stomp.over(this.socket);
         var headers = {
-          //'Authorization':'Bearer '+token.toString()
+          'Authorization':'Bearer '+token
         };
         // 向服务器发起websocket连接
         this.stompClient.connect(headers, (frame) => {
@@ -145,7 +142,7 @@
             this.$notify({
               title: "用户登陆通知",
               dangerouslyUseHTMLString: true,
-              message: '用户' + msg.body + '登陆',
+              message: '用户 <strong>' + msg.body + '</strong> 登陆',
               offset: 60
             });
           });