Browse Source

websocket 请求连接

chenlei1231 4 months ago
parent
commit
4c04cde860
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/layouts/default/header/components/notify/index.vue

+ 2 - 1
src/layouts/default/header/components/notify/index.vue

@@ -48,6 +48,7 @@
       const instance: any = getCurrentInstance();
       const userStore = useUserStore();
       const glob = useGlobSetting();
+      const websocketUrl = ref(glob.domainUrl + glob.apiUrl);
       const dynamicNoticeProps = reactive({ path: '', formData: {} });
       const [registerDetail, detailModal] = useModal();
       const listData = ref(tabListData);
@@ -126,7 +127,7 @@
         let wsClientId = md5(token);
         let userId = unref(userStore.getUserInfo).id + '_' + wsClientId;
         // WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https
-        let url = glob.domainUrl?.replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId;
+        let url = websocketUrl.value?.replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId;
         connectWebSocket(url);
         onWebSocket(onWebSocketMessage);
       }