fix: 路由地址增加问号导致websocket报错

This commit is contained in:
fit2cloud-chenyw 2024-08-29 15:14:44 +08:00
parent b7286db7b4
commit fffe3471bf

View File

@ -36,12 +36,15 @@ export default {
if (window.DataEaseBi?.baseUrl) { if (window.DataEaseBi?.baseUrl) {
prefix = window.DataEaseBi.baseUrl prefix = window.DataEaseBi.baseUrl
} else { } else {
const href = window.location.href // const href = window.location.href
prefix = href.substring(0, href.indexOf('#')) prefix = location.origin + location.pathname
if (env.MODE === 'dev') { if (env.MODE === 'dev') {
prefix = dev.server.proxy[basePath].target + '/' prefix = dev.server.proxy[basePath].target + '/'
} }
} }
if (!prefix.endsWith('/')) {
prefix += '/'
}
const socket = new SockJS(prefix + 'websocket?userId=' + wsCache.get('user.uid')) const socket = new SockJS(prefix + 'websocket?userId=' + wsCache.get('user.uid'))
stompClient = Stomp.over(socket) stompClient = Stomp.over(socket)
const heads = { const heads = {