From 55a024618a448458f3f385a7aa37dbd36aade70e Mon Sep 17 00:00:00 2001 From: niushuai233 Date: Tue, 3 Jan 2023 10:39:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=81=BF=E5=85=8D=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E5=A4=9A=E6=96=9C=E7=BA=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/tools/HeaderNotice.vue | 8 ++++++-- src/config/index.js | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/tools/HeaderNotice.vue b/src/components/tools/HeaderNotice.vue index 3bad73a..3466b88 100644 --- a/src/components/tools/HeaderNotice.vue +++ b/src/components/tools/HeaderNotice.vue @@ -202,8 +202,12 @@ initWebSocket: function () { // WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https var userId = store.getters.userInfo.id; - var url = window._CONFIG['domianURL'].replace("https://","wss://").replace("http://","ws://")+"/websocket/"+userId; - //console.log(url); + let domainUrl = window._CONFIG['domianURL']; + if (!domainUrl.endsWith('/')) { + domainUrl = domainUrl + '/'; + } + var url = domainUrl.replace("https://","wss://").replace("http://","ws://") + "websocket/" + userId; + console.log(url); //update-begin-author:taoyan date:2022-4-22 for: v2.4.6 的 websocket 服务端,存在性能和安全问题。 #3278 let token = Vue.ls.get(ACCESS_TOKEN) this.websock = new WebSocket(url, [token]); diff --git a/src/config/index.js b/src/config/index.js index 1843b2a..169b5b7 100644 --- a/src/config/index.js +++ b/src/config/index.js @@ -6,5 +6,9 @@ window._CONFIG['domianURL'] = Vue.prototype.API_BASE_URL //单点登录地址 window._CONFIG['casPrefixUrl'] = window._CONFIG.VUE_APP_CAS_BASE_URL?window._CONFIG.VUE_APP_CAS_BASE_URL:process.env.VUE_APP_CAS_BASE_URL window._CONFIG['onlinePreviewDomainURL'] = window._CONFIG.VUE_APP_ONLINE_BASE_URL?window._CONFIG.VUE_APP_ONLINE_BASE_URL:process.env.VUE_APP_ONLINE_BASE_URL -window._CONFIG['staticDomainURL'] = Vue.prototype.API_BASE_URL + '/sys/common/static' -window._CONFIG['pdfDomainURL'] = Vue.prototype.API_BASE_URL+ '/sys/common/pdf/pdfPreviewIframe' \ No newline at end of file +let _API_BASE_URL = Vue.prototype.API_BASE_URL; +if(!_API_BASE_URL.endsWith('/')) { + _API_BASE_URL = _API_BASE_URL + '/' +} +window._CONFIG['staticDomainURL'] = _API_BASE_URL + 'sys/common/static' +window._CONFIG['pdfDomainURL'] = _API_BASE_URL + 'sys/common/pdf/pdfPreviewIframe' \ No newline at end of file